From d1009b92add144eb4c3c13c29574fad50c8b652f Mon Sep 17 00:00:00 2001 From: bartvde Date: Wed, 22 Jun 2011 15:20:01 +0000 Subject: [PATCH] add Format for writing out Web Coverage Service (WCS) requests, r=ahocevar (closes #3375) git-svn-id: http://svn.openlayers.org/trunk/openlayers@12125 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers.js | 1 + lib/OpenLayers/Format/WCSGetCoverage.js | 198 ++++++++++++++++++++++++ lib/OpenLayers/Format/WPSExecute.js | 11 +- tests/Format/WCSGetCoverage.html | 80 ++++++++++ tests/Format/WPSExecute.html | 105 +++++++++++++ tests/list-tests.html | 1 + 6 files changed, 394 insertions(+), 2 deletions(-) create mode 100644 lib/OpenLayers/Format/WCSGetCoverage.js create mode 100644 tests/Format/WCSGetCoverage.html diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 2e5e1bb7ac..1d95ad98de 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -316,6 +316,7 @@ "OpenLayers/Format/WMC/v1.js", "OpenLayers/Format/WMC/v1_0_0.js", "OpenLayers/Format/WMC/v1_1_0.js", + "OpenLayers/Format/WCSGetCoverage.js", "OpenLayers/Format/WMSCapabilities.js", "OpenLayers/Format/WMSCapabilities/v1.js", "OpenLayers/Format/WMSCapabilities/v1_1.js", diff --git a/lib/OpenLayers/Format/WCSGetCoverage.js b/lib/OpenLayers/Format/WCSGetCoverage.js new file mode 100644 index 0000000000..ecc6989807 --- /dev/null +++ b/lib/OpenLayers/Format/WCSGetCoverage.js @@ -0,0 +1,198 @@ +/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for + * full list of contributors). Published under the Clear BSD license. + * See http://svn.openlayers.org/trunk/openlayers/license.txt for the + * full text of the license. */ + +/** + * @requires OpenLayers/Format/XML.js + */ + +/** + * Class: OpenLayers.Format.WCSGetCoverage version 1.1.0 + * + * Inherits from: + * - + */ +OpenLayers.Format.WCSGetCoverage = OpenLayers.Class(OpenLayers.Format.XML, { + + /** + * Property: namespaces + * {Object} Mapping of namespace aliases to namespace URIs. + */ + namespaces: { + ows: "http://www.opengis.net/ows/1.1", + wcs: "http://www.opengis.net/wcs/1.1", + xlink: "http://www.w3.org/1999/xlink", + xsi: "http://www.w3.org/2001/XMLSchema-instance" + }, + + /** + * Property: regExes + * Compiled regular expressions for manipulating strings. + */ + regExes: { + trimSpace: (/^\s*|\s*$/g), + removeSpace: (/\s*/g), + splitSpace: (/\s+/), + trimComma: (/\s*,\s*/g) + }, + + /** + * Constant: VERSION + * {String} 1.1.2 + */ + VERSION: "1.1.2", + + /** + * Property: schemaLocation + * {String} Schema location + */ + schemaLocation: "http://www.opengis.net/wcs/1.1 http://schemas.opengis.net/wcs/1.1/wcsGetCoverage.xsd", + + /** + * Constructor: OpenLayers.Format.WCSGetCoverage + * + * Parameters: + * options - {Object} An optional object whose properties will be set on + * this instance. + */ + + /** + * Method: write + * + * Parameters: + * options - {Object} Optional object. + * + * Returns: + * {String} A WCS GetCoverage request XML string. + */ + write: function(options) { + var node = this.writeNode("wcs:GetCoverage", options); + this.setAttributeNS( + node, this.namespaces.xsi, + "xsi:schemaLocation", this.schemaLocation + ); + return OpenLayers.Format.XML.prototype.write.apply(this, [node]); + }, + + /** + * Property: writers + * As a compliment to the readers property, this structure contains public + * writing functions grouped by namespace alias and named like the + * node names they produce. + */ + writers: { + "wcs": { + "GetCoverage": function(options) { + var node = this.createElementNSPlus("wcs:GetCoverage", { + attributes: { + version: options.version || this.VERSION, + service: 'WCS' + } + }); + this.writeNode("ows:Identifier", options.identifier, node); + this.writeNode("wcs:DomainSubset", options.domainSubset, node); + this.writeNode("wcs:Output", options.output, node); + return node; + }, + "DomainSubset": function(domainSubset) { + var node = this.createElementNSPlus("wcs:DomainSubset", {}); + this.writeNode("ows:BoundingBox", domainSubset.boundingBox, node); + if (domainSubset.temporalSubset) { + this.writeNode("wcs:TemporalSubset", domainSubset.temporalSubset, node); + } + return node; + }, + "TemporalSubset": function(temporalSubset) { + var node = this.createElementNSPlus("wcs:TemporalSubset", {}); + for (var i=0, len=temporalSubset.timePeriods.length; i + + + + + + + diff --git a/tests/Format/WPSExecute.html b/tests/Format/WPSExecute.html index dc68af74dc..fc731e8900 100644 --- a/tests/Format/WPSExecute.html +++ b/tests/Format/WPSExecute.html @@ -3,6 +3,111 @@