diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 2351f0288c..2e5e1bb7ac 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -333,6 +333,10 @@ "OpenLayers/Format/OWSContext/v0_3_1.js", "OpenLayers/Format/WMTSCapabilities.js", "OpenLayers/Format/WMTSCapabilities/v1_0_0.js", + "OpenLayers/Format/WPSCapabilities.js", + "OpenLayers/Format/WPSCapabilities/v1_0_0.js", + "OpenLayers/Format/WPSDescribeProcess.js", + "OpenLayers/Format/WPSExecute.js", "OpenLayers/Format/XLS.js", "OpenLayers/Format/XLS/v1.js", "OpenLayers/Format/XLS/v1_1_0.js", diff --git a/lib/OpenLayers/Format/OWSCommon/v1.js b/lib/OpenLayers/Format/OWSCommon/v1.js index 924d25874e..7ee97593ce 100644 --- a/lib/OpenLayers/Format/OWSCommon/v1.js +++ b/lib/OpenLayers/Format/OWSCommon/v1.js @@ -232,6 +232,9 @@ OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, { delete obj.bottom; delete obj.right; delete obj.top; + }, + "Language": function(node, obj) { + obj.language = this.getChildValue(node); } } }, @@ -264,11 +267,21 @@ OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, { value: options.bounds.right + " " + options.bounds.top }); return node; }, + "Identifier": function(identifier) { + var node = this.createElementNSPlus("ows:Identifier", { + value: identifier }); + return node; + }, "Title": function(title) { var node = this.createElementNSPlus("ows:Title", { value: title }); return node; }, + "Abstract": function(abstractValue) { + var node = this.createElementNSPlus("ows:Abstract", { + value: abstractValue }); + return node; + }, "OutputFormat": function(format) { var node = this.createElementNSPlus("ows:OutputFormat", { value: format }); diff --git a/lib/OpenLayers/Format/OWSCommon/v1_1_0.js b/lib/OpenLayers/Format/OWSCommon/v1_1_0.js index 167d6dfc59..c3ccae5ab9 100644 --- a/lib/OpenLayers/Format/OWSCommon/v1_1_0.js +++ b/lib/OpenLayers/Format/OWSCommon/v1_1_0.js @@ -47,6 +47,9 @@ OpenLayers.Format.OWSCommon.v1_1_0 = OpenLayers.Class(OpenLayers.Format.OWSCommo "AnyValue": function(node, parameter) { parameter.anyValue = true; }, + "DataType": function(node, parameter) { + parameter.dataType = this.getChildValue(node); + }, "Range": function(node, allowedValues) { allowedValues.range = {}; this.readChildNodes(node, allowedValues.range); @@ -65,7 +68,46 @@ OpenLayers.Format.OWSCommon.v1_1_0 = OpenLayers.Class(OpenLayers.Format.OWSCommo } }, OpenLayers.Format.OWSCommon.v1.prototype.readers["ows"]) }, - + + /** + * 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: { + "ows": OpenLayers.Util.applyDefaults({ + "Range": function(range) { + var node = this.createElementNSPlus("ows:Range", { + attributes: { + 'ows:rangeClosure': range.closure + } + }); + this.writeNode("ows:MinimumValue", range.minValue, node); + this.writeNode("ows:MaximumValue", range.maxValue, node); + return node; + }, + "MinimumValue": function(minValue) { + var node = this.createElementNSPlus("ows:MinimumValue", { + value: minValue + }); + return node; + }, + "MaximumValue": function(maxValue) { + var node = this.createElementNSPlus("ows:MaximumValue", { + value: maxValue + }); + return node; + }, + "Value": function(value) { + var node = this.createElementNSPlus("ows:Value", { + value: value + }); + return node; + } + }, OpenLayers.Format.OWSCommon.v1.prototype.writers["ows"]) + }, + CLASS_NAME: "OpenLayers.Format.OWSCommon.v1_1_0" }); diff --git a/lib/OpenLayers/Format/WPSCapabilities.js b/lib/OpenLayers/Format/WPSCapabilities.js new file mode 100644 index 0000000000..5a6d4c33dc --- /dev/null +++ b/lib/OpenLayers/Format/WPSCapabilities.js @@ -0,0 +1,79 @@ +/* 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.WPSCapabilities + * Read WPS Capabilities. + * + * Inherits from: + * - + */ +OpenLayers.Format.WPSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, { + + /** + * APIProperty: defaultVersion + * {String} Version number to assume if none found. Default is "1.0.0". + */ + defaultVersion: "1.0.0", + + /** + * APIProperty: version + * {String} Specify a version string if one is known. + */ + version: null, + + /** + * Property: parser + * {} A cached versioned format used for reading. + */ + parser: null, + + /** + * Constructor: OpenLayers.Format.WPSCapabilities + * Create a new parser for WPS Capabilities. + * + * Parameters: + * options - {Object} An optional object whose properties will be set on + * this instance. + */ + + /** + * APIMethod: read + * Read capabilities data from a string, and return information about + * the service. + * + * Parameters: + * data - {String} or {DOMElement} data to read/parse. + * + * Returns: + * {Object} Info about the WPS + */ + read: function(data) { + if(typeof data == "string") { + data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); + } + var root = data.documentElement; + var version = this.version || root.getAttribute("version") || this.defaultVersion; + if(!this.parser || this.parser.version !== version) { + var constr = OpenLayers.Format.WPSCapabilities[ + "v" + version.replace(/\./g, "_") + ]; + if(!constr) { + throw "Can't find a WPS capabilities parser for version " + version; + } + var parser = new constr(this.options); + } + var capabilities = parser.read(data); + capabilities.version = version; + return capabilities; + }, + + CLASS_NAME: "OpenLayers.Format.WPSCapabilities" + +}); diff --git a/lib/OpenLayers/Format/WPSCapabilities/v1_0_0.js b/lib/OpenLayers/Format/WPSCapabilities/v1_0_0.js new file mode 100644 index 0000000000..80ef888476 --- /dev/null +++ b/lib/OpenLayers/Format/WPSCapabilities/v1_0_0.js @@ -0,0 +1,119 @@ +/* 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/WPSCapabilities.js + * @requires OpenLayers/Format/OWSCommon/v1_1_0.js + */ + +/** + * Class: OpenLayers.Format.WPSCapabilities.v1_0_0 + * Read WPS Capabilities version 1.0.0. + * + * Inherits from: + * - + */ +OpenLayers.Format.WPSCapabilities.v1_0_0 = OpenLayers.Class( + OpenLayers.Format.XML, { + + /** + * Property: namespaces + * {Object} Mapping of namespace aliases to namespace URIs. + */ + namespaces: { + ows: "http://www.opengis.net/ows/1.1", + wps: "http://www.opengis.net/wps/1.0.0", + xlink: "http://www.w3.org/1999/xlink" + }, + + /** + * Property: regExes + * Compiled regular expressions for manipulating strings. + */ + regExes: { + trimSpace: (/^\s*|\s*$/g), + removeSpace: (/\s*/g), + splitSpace: (/\s+/), + trimComma: (/\s*,\s*/g) + }, + + /** + * Constructor: OpenLayers.Format.WPSCapabilities.v1_0_0 + * Create a new parser for WPS capabilities version 1.0.0. + * + * Parameters: + * options - {Object} An optional object whose properties will be set on + * this instance. + */ + initialize: function(options) { + OpenLayers.Format.XML.prototype.initialize.apply(this, [options]); + }, + + /** + * APIMethod: read + * Read capabilities data from a string, and return info about the WPS. + * + * Parameters: + * data - {String} or {DOMElement} data to read/parse. + * + * Returns: + * {Object} Information about the WPS service. + */ + read: function(data) { + if(typeof data == "string") { + data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); + } + if(data && data.nodeType == 9) { + data = data.documentElement; + } + var capabilities = {}; + this.readNode(data, capabilities); + return capabilities; + }, + + /** + * Property: readers + * Contains public functions, grouped by namespace prefix, that will + * be applied when a namespaced node is found matching the function + * name. The function will be applied in the scope of this parser + * with two arguments: the node being read and a context object passed + * from the parent. + */ + readers: { + "wps": { + "Capabilities": function(node, obj) { + this.readChildNodes(node, obj); + }, + "ProcessOfferings": function(node, obj) { + obj.processOfferings = {}; + this.readChildNodes(node, obj.processOfferings); + }, + "Process": function(node, processOfferings) { + var processVersion = this.getAttributeNS(node, this.namespaces.wps, "processVersion"); + var process = {processVersion: processVersion}; + this.readChildNodes(node, process); + processOfferings[process.identifier] = process; + }, + "Languages": function(node, obj) { + obj.languages = []; + this.readChildNodes(node, obj.languages); + }, + "Default": function(node, languages) { + var language = {isDefault: true}; + this.readChildNodes(node, language); + languages.push(language); + }, + "Supported": function(node, languages) { + var language = {}; + this.readChildNodes(node, language); + languages.push(language); + } + }, + "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"] + }, + + CLASS_NAME: "OpenLayers.Format.WPSCapabilities.v1_0_0" + +}); diff --git a/lib/OpenLayers/Format/WPSDescribeProcess.js b/lib/OpenLayers/Format/WPSDescribeProcess.js new file mode 100644 index 0000000000..885b0ee7b1 --- /dev/null +++ b/lib/OpenLayers/Format/WPSDescribeProcess.js @@ -0,0 +1,180 @@ +/* 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.WPSDescribeProcess + * Read WPS DescribeProcess responses. + * + * Inherits from: + * - + */ +OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class( + OpenLayers.Format.XML, { + + /** + * Constant: VERSION + * {String} 1.0.0 + */ + VERSION: "1.0.0", + + /** + * Property: namespaces + * {Object} Mapping of namespace aliases to namespace URIs. + */ + namespaces: { + wps: "http://www.opengis.net/wps/1.0.0", + ows: "http://www.opengis.net/ows/1.1", + xsi: "http://www.w3.org/2001/XMLSchema-instance" + }, + + /** + * Property: schemaLocation + * {String} Schema location + */ + schemaLocation: "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd", + + /** + * Property: defaultPrefix + */ + defaultPrefix: "wps", + + /** + * Property: regExes + * Compiled regular expressions for manipulating strings. + */ + regExes: { + trimSpace: (/^\s*|\s*$/g), + removeSpace: (/\s*/g), + splitSpace: (/\s+/), + trimComma: (/\s*,\s*/g) + }, + + /** + * Constructor: OpenLayers.Format.WPSDescribeProcess + * + * Parameters: + * options - {Object} An optional object whose properties will be set on + * this instance. + */ + + /** + * APIMethod: read + * Parse a WPS DescribeProcess and return an object with its information. + * + * Parameters: + * data - {String} or {DOMElement} data to read/parse. + * + * Returns: + * {Object} + */ + read: function(data) { + if(typeof data == "string") { + data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); + } + if(data && data.nodeType == 9) { + data = data.documentElement; + } + var info = {}; + this.readNode(data, info); + return info; + }, + + /** + * Property: readers + * Contains public functions, grouped by namespace prefix, that will + * be applied when a namespaced node is found matching the function + * name. The function will be applied in the scope of this parser + * with two arguments: the node being read and a context object passed + * from the parent. + */ + readers: { + "wps": { + "ProcessDescriptions": function(node, obj) { + obj.processDescriptions = {}; + this.readChildNodes(node, obj.processDescriptions); + }, + "ProcessDescription": function(node, processDescriptions) { + var processVersion = this.getAttributeNS(node, this.namespaces.wps, "processVersion"); + var processDescription = { + processVersion: processVersion, + statusSupported: (node.getAttribute("statusSupported") === "true"), + storeSupported: (node.getAttribute("storeSupported") === "true") + }; + this.readChildNodes(node, processDescription); + processDescriptions[processDescription.identifier] = processDescription; + }, + "DataInputs": function(node, processDescription) { + processDescription.dataInputs = []; + this.readChildNodes(node, processDescription.dataInputs); + }, + "ProcessOutputs": function(node, processDescription) { + processDescription.processOutputs = []; + this.readChildNodes(node, processDescription.processOutputs); + }, + "Output": function(node, processOutputs) { + var output = {}; + this.readChildNodes(node, output); + processOutputs.push(output); + }, + "ComplexOutput": function(node, output) { + output.complexOutput = {}; + this.readChildNodes(node, output.complexOutput); + }, + "Input": function(node, dataInputs) { + var input = { + maxOccurs: parseInt(node.getAttribute("maxOccurs")), + minOccurs: parseInt(node.getAttribute("minOccurs")) + }; + this.readChildNodes(node, input); + dataInputs.push(input); + }, + "BoundingBoxData": function(node, input) { + input.boundingBoxData = {}; + this.readChildNodes(node, input.boundingBoxData); + }, + "CRS": function(node, obj) { + if (!obj.CRSs) { + obj.CRSs = {}; + } + obj.CRSs[this.getChildValue(node)] = true; + }, + "LiteralData": function(node, input) { + input.literalData = {}; + this.readChildNodes(node, input.literalData); + }, + "ComplexData": function(node, input) { + input.complexData = {}; + this.readChildNodes(node, input.complexData); + }, + "Default": function(node, complexData) { + complexData["default"] = {}; + this.readChildNodes(node, complexData["default"]); + }, + "Supported": function(node, complexData) { + complexData["supported"] = {}; + this.readChildNodes(node, complexData["supported"]); + }, + "Format": function(node, obj) { + var format = {}; + this.readChildNodes(node, format); + if (!obj.formats) { + obj.formats = {}; + } + obj.formats[format.mimeType] = true; + }, + "MimeType": function(node, format) { + format.mimeType = this.getChildValue(node); + } + }, + "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"] + }, + + CLASS_NAME: "OpenLayers.Format.WPSDescribeProcess" + +}); diff --git a/lib/OpenLayers/Format/WPSExecute.js b/lib/OpenLayers/Format/WPSExecute.js new file mode 100644 index 0000000000..82ab2e9936 --- /dev/null +++ b/lib/OpenLayers/Format/WPSExecute.js @@ -0,0 +1,243 @@ +/* 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.WPSExecute version 1.0.0 + * + * Inherits from: + * - + */ +OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, { + + /** + * Property: namespaces + * {Object} Mapping of namespace aliases to namespace URIs. + */ + namespaces: { + ows: "http://www.opengis.net/ows/1.1", + gml: "http://www.opengis.net/gml", + wps: "http://www.opengis.net/wps/1.0.0", + wfs: "http://www.opengis.net/wfs", + ogc: "http://www.opengis.net/ogc", + wcs: "http://www.opengis.net/wcs/1.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.0.0 + */ + VERSION: "1.0.0", + + /** + * Property: schemaLocation + * {String} Schema location + */ + schemaLocation: "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd", + + schemaLocationAttr: function(options) { + return undefined; + }, + + /** + * Constructor: OpenLayers.Format.WPSExecute + * + * Parameters: + * options - {Object} An optional object whose properties will be set on + * this instance. + */ + + /** + * Method: write + * + * Parameters: + * options - {Object} Optional object. + * + * Returns: + * {String} An WPS Execute request XML string. + */ + write: function(options) { + var doc; + if (window.ActiveXObject) { + doc = new ActiveXObject("Microsoft.XMLDOM"); + this.xmldom = doc; + } else { + doc = document.implementation.createDocument("", "", null); + } + var node = this.writeNode("wps:Execute", options, doc); + 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: { + "wps": { + "Execute": function(options) { + var node = this.createElementNSPlus("wps:Execute", { + attributes: { + version: this.VERSION, + service: 'WPS' + } + }); + this.writeNode("ows:Identifier", options.identifier, node); + this.writeNode("wps:DataInputs", options.dataInputs, node); + this.writeNode("wps:ResponseForm", options.responseForm, node); + return node; + }, + "ResponseForm": function(responseForm) { + var node = this.createElementNSPlus("wps:ResponseForm", {}); + if (responseForm.rawDataOutput) { + this.writeNode("wps:RawDataOutput", responseForm.rawDataOutput, node); + } + if (responseForm.responseDocument) { + this.writeNode("wps:ResponseDocument", responseForm.responseDocument, node); + } + return node; + }, + "ResponseDocument": function(responseDocument) { + var node = this.createElementNSPlus("wps:ResponseDocument", { + attributes: { + storeExecuteResponse: responseDocument.storeExecuteResponse, + lineage: responseDocument.lineage, + status: responseDocument.status + } + }); + if (responseDocument.output) { + this.writeNode("wps:Output", responseDocument.output, node); + } + return node; + }, + "Output": function(output) { + var node = this.createElementNSPlus("wps:Output", { + attributes: { + asReference: output.asReference + } + }); + this.writeNode("ows:Identifier", output.identifier, node); + this.writeNode("ows:Title", output.title, node); + this.writeNode("ows:Abstract", output["abstract"], node); + return node; + }, + "RawDataOutput": function(rawDataOutput) { + var node = this.createElementNSPlus("wps:RawDataOutput", { + attributes: { + mimeType: rawDataOutput.mimeType + } + }); + this.writeNode("ows:Identifier", rawDataOutput.identifier, node); + return node; + }, + "DataInputs": function(dataInputs) { + var node = this.createElementNSPlus("wps:DataInputs", {}); + for (var i=0, ii=dataInputs.length; i + + + + + + + + diff --git a/tests/Format/WPSCapabilities/v1_0_0.js b/tests/Format/WPSCapabilities/v1_0_0.js new file mode 100644 index 0000000000..19d12f2208 --- /dev/null +++ b/tests/Format/WPSCapabilities/v1_0_0.js @@ -0,0 +1,112 @@ +var doc = new OpenLayers.Format.XML().read( +'' + +'' + +' ' + +' Prototype GeoServer WPS' + +' ' + +' WPS' + +' 1.0.0' + +' ' + +' ' + +' The ancient geographes INC' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' gt:Intersect' + +' Intersection' + +' Intersection between two literal geometry' + +' ' + +' ' + +' JTS:length' + +' Returns the geometry perimeters, computed using cartesian geometry' + +' expressions in the same unit of measure as the geometry (will not return a valid' + +' perimeter for geometries expressed geographic coordinates' + +' Returns the geometry perimeters, computed using cartesian geometry' + +' expressions in the same unit of measure as the geometry (will not return a valid' + +' perimeter for geometries expressed geographic coordinates' + +' ' + +' ' + +' JTS:isEmpty' + +' Checks if the provided geometry is empty' + +' Checks if the provided geometry is empty' + +' ' + +' ' + +' JTS:contains' + +' Checks if a contains b' + +' Checks if a contains b' + +' ' + +' ' + +' JTS:disjoint' + +' Returns true if the two geometries have no points in common' + +' Returns true if the two geometries have no points in common' + +' ' + +' ' + +' JTS:intersects' + +' Returns true if the two geometries intersect, false otherwise' + +' Returns true if the two geometries intersect, false' + +' otherwise' + +' ' + +' ' + +' JTS:isClosed' + +' Returns true if the line is closed' + +' Returns true if the line is closed' + +' ' + +' ' + +' JTS:isValid' + +' Returns true if the geometry is topologically valid, false' + +' otherwise' + +' Returns true if the geometry is topologically valid, false' + +' otherwise' + +' ' + +' ' + +' JTS:buffer' + +' Buffers a geometry using a certain distance' + +' Buffers a geometry using a certain distance' + +' ' + +' ' + +' JTS:getY' + +' Returns the Y ordinate of the point' + +' Returns the Y ordinate of the point' + +' ' + +' ' + +' ' + +' ' + +' en-US' + +' ' + +' ' + +' en-US' + +' ' + +' ' + +'' +); diff --git a/tests/Format/WPSDescribeProcess.html b/tests/Format/WPSDescribeProcess.html new file mode 100644 index 0000000000..c411f6267b --- /dev/null +++ b/tests/Format/WPSDescribeProcess.html @@ -0,0 +1,196 @@ + + + + + + + + diff --git a/tests/Format/WPSExecute.html b/tests/Format/WPSExecute.html new file mode 100644 index 0000000000..dc68af74dc --- /dev/null +++ b/tests/Format/WPSExecute.html @@ -0,0 +1,364 @@ + + + + + + + + diff --git a/tests/list-tests.html b/tests/list-tests.html index a56c678896..fe63cacb8e 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -96,6 +96,9 @@
  • Format/WMSGetFeatureInfo.html
  • Format/WMTSCapabilities.html
  • Format/WMTSCapabilities/v1_0_0.html
  • +
  • Format/WPSCapabilities/v1_0_0.html
  • +
  • Format/WPSDescribeProcess.html
  • +
  • Format/WPSExecute.html
  • Format/CSWGetDomain.html
  • Format/CSWGetDomain/v2_0_2.html
  • Format/CSWGetRecords.html