diff --git a/examples/data/tazdem.tiff b/examples/data/tazdem.tiff new file mode 100644 index 0000000000..a1eee6c291 Binary files /dev/null and b/examples/data/tazdem.tiff differ diff --git a/examples/wps.html b/examples/wps.html index 11f297d97d..bbeeb0f74a 100644 --- a/examples/wps.html +++ b/examples/wps.html @@ -2,7 +2,7 @@ - + OpenLayers WPS Builder Example diff --git a/examples/wps.js b/examples/wps.js index 0fa213b4c7..093351cb9a 100644 --- a/examples/wps.js +++ b/examples/wps.js @@ -1,6 +1,7 @@ OpenLayers.ProxyHost = "proxy.cgi?url="; -var capabilities, // the capabilities, read by Format.WPSCapabilities::read +var wps = "http://suite.opengeo.org/geoserver/wps", + capabilities, // the capabilities, read by Format.WPSCapabilities::read process; // the process description from Format.WPSDescribeProcess::read // get some capabilities @@ -30,7 +31,7 @@ document.getElementById("processes").onchange = describeProcess; // using OpenLayers.Format.WPSCapabilities to read the capabilities function getCapabilities() { OpenLayers.Request.GET({ - url: "http://suite.opengeo.org/geoserver/wps/", + url: wps, params: { "SERVICE": "wps", "REQUEST": "GetCapabilities" @@ -57,7 +58,7 @@ function getCapabilities() { function describeProcess() { var selection = this.options[this.selectedIndex].value; OpenLayers.Request.GET({ - url: "http://suite.opengeo.org/geoserver/wps/", + url: wps, params: { "SERVICE": "wps", "REQUEST": "DescribeProcess", @@ -89,14 +90,21 @@ function buildForm() { addWKTInput(input); } else if (formats["text/xml; subtype=wfs-collection/1.0"]) { addWFSCollectionInput(input); + } else if (formats["image/tiff"]) { + addRasterInput(input); } else { supported = false; } + } else if (input.boundingBoxData) { + addBoundingBoxInput(input); } else if (input.literalData) { addLiteralInput(input); } else { supported = false; } + if (input.minOccurs > 0) { + document.getElementById("input").appendChild(document.createTextNode("* ")); + } } if (supported) { @@ -170,6 +178,38 @@ function addWFSCollectionInput(input) { document.getElementById("input").appendChild(field); } +// helper function to dynamically create a raster (GeoTIFF) url input +function addRasterInput(input) { + var name = input.identifier; + var field = document.createElement("input"); + field.title = input["abstract"]; + var url = window.location.href.split("?")[0]; + field.value = url.substr(0, url.lastIndexOf("/")+1) + "data/tazdem.tiff"; + document.getElementById("input").appendChild(field); + (field.onblur = function() { + input.reference = { + mimeType: "image/tiff", + href: field.value, + method: "GET" + }; + })(); +} + +// helper function to dynamically create a bounding box input +function addBoundingBoxInput(input) { + var name = input.identifier; + var field = document.createElement("input"); + field.title = input["abstract"]; + field.value = "left,bottom,right,top"; + document.getElementById("input").appendChild(field); + addValueHandlers(field, function() { + input.boundingBoxData = { + projection: "EPSG:4326", + bounds: OpenLayers.Bounds.fromString(field.value) + } + }); +} + // helper function to create a literal input textfield or dropdown function addLiteralInput(input, previousSibling) { var name = input.identifier; @@ -251,7 +291,7 @@ function execute() { // remove occurrences that the user has not filled out for (var i=process.dataInputs.length-1; i>=0; --i) { input = process.dataInputs[i]; - if (input.occurrence && !input.data && !input.reference) { + if ((input.minOccurs === 0 || input.occurrence) && !input.data && !input.reference) { OpenLayers.Util.removeItem(process.dataInputs, input); } } @@ -264,7 +304,7 @@ function execute() { process.responseForm.rawDataOutput.mimeType = "application/wkt"; } OpenLayers.Request.POST({ - url: "http://suite.opengeo.org/geoserver/wps", + url: wps, data: new OpenLayers.Format.WPSExecute().write(process), success: showOutput }); diff --git a/lib/OpenLayers/Format/OWSCommon/v1.js b/lib/OpenLayers/Format/OWSCommon/v1.js index 4abedd860b..b154d1f6b2 100644 --- a/lib/OpenLayers/Format/OWSCommon/v1.js +++ b/lib/OpenLayers/Format/OWSCommon/v1.js @@ -270,8 +270,8 @@ OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, { */ writers: { "ows": { - "BoundingBox": function(options) { - var node = this.createElementNSPlus("ows:BoundingBox", { + "BoundingBox": function(options, nodeName) { + var node = this.createElementNSPlus(nodeName || "ows:BoundingBox", { attributes: { crs: options.projection } diff --git a/lib/OpenLayers/Format/WFST/v1_0_0.js b/lib/OpenLayers/Format/WFST/v1_0_0.js index 41a4286d08..2deb394980 100644 --- a/lib/OpenLayers/Format/WFST/v1_0_0.js +++ b/lib/OpenLayers/Format/WFST/v1_0_0.js @@ -82,7 +82,7 @@ OpenLayers.Format.WFST.v1_0_0 = OpenLayers.Class( // Not the superclass, only the mixin classes inherit from // Format.GML.v2. We need this because we don't want to get readNode // from the superclass's superclass, which is OpenLayers.Format.XML. - return OpenLayers.Format.GML.v2.prototype.readNode.apply(this, [node, obj]); + return OpenLayers.Format.GML.v2.prototype.readNode.apply(this, arguments); }, /** diff --git a/lib/OpenLayers/Format/WFST/v1_1_0.js b/lib/OpenLayers/Format/WFST/v1_1_0.js index 71268441a9..67653160a9 100644 --- a/lib/OpenLayers/Format/WFST/v1_1_0.js +++ b/lib/OpenLayers/Format/WFST/v1_1_0.js @@ -81,7 +81,7 @@ OpenLayers.Format.WFST.v1_1_0 = OpenLayers.Class( // Not the superclass, only the mixin classes inherit from // Format.GML.v3. We need this because we don't want to get readNode // from the superclass's superclass, which is OpenLayers.Format.XML. - return OpenLayers.Format.GML.v3.prototype.readNode.apply(this, [node, obj]); + return OpenLayers.Format.GML.v3.prototype.readNode.apply(this, arguments); }, /** diff --git a/lib/OpenLayers/Format/WPSExecute.js b/lib/OpenLayers/Format/WPSExecute.js index de74ed9b93..75ffb8b1d9 100644 --- a/lib/OpenLayers/Format/WPSExecute.js +++ b/lib/OpenLayers/Format/WPSExecute.js @@ -175,6 +175,9 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, { if (input.reference) { this.writeNode("wps:Reference", input.reference, node); } + if (input.boundingBoxData) { + this.writeNode("wps:BoundingBoxData", input.boundingBoxData, node); + } return node; }, "Data": function(data) { @@ -228,6 +231,9 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, { } return node; }, + "BoundingBoxData": function(node, obj) { + this.writers['ows']['BoundingBox'].apply(this, [node, obj, "wps:BoundingBoxData"]); + }, "Body": function(body) { var node = this.createElementNSPlus("wps:Body", {}); if (body.wcs) {