WPS example; support for BoundingBox in WPS format

This commit is contained in:
ahocevar
2012-03-30 18:02:24 -07:00
parent 81b67db101
commit c3fe359fa6
7 changed files with 56 additions and 10 deletions
Binary file not shown.
+1 -1
View File
@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers WPS Builder Example</title> <title>OpenLayers WPS Builder Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css"> <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
+45 -5
View File
@@ -1,6 +1,7 @@
OpenLayers.ProxyHost = "proxy.cgi?url="; 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 process; // the process description from Format.WPSDescribeProcess::read
// get some capabilities // get some capabilities
@@ -30,7 +31,7 @@ document.getElementById("processes").onchange = describeProcess;
// using OpenLayers.Format.WPSCapabilities to read the capabilities // using OpenLayers.Format.WPSCapabilities to read the capabilities
function getCapabilities() { function getCapabilities() {
OpenLayers.Request.GET({ OpenLayers.Request.GET({
url: "http://suite.opengeo.org/geoserver/wps/", url: wps,
params: { params: {
"SERVICE": "wps", "SERVICE": "wps",
"REQUEST": "GetCapabilities" "REQUEST": "GetCapabilities"
@@ -57,7 +58,7 @@ function getCapabilities() {
function describeProcess() { function describeProcess() {
var selection = this.options[this.selectedIndex].value; var selection = this.options[this.selectedIndex].value;
OpenLayers.Request.GET({ OpenLayers.Request.GET({
url: "http://suite.opengeo.org/geoserver/wps/", url: wps,
params: { params: {
"SERVICE": "wps", "SERVICE": "wps",
"REQUEST": "DescribeProcess", "REQUEST": "DescribeProcess",
@@ -89,14 +90,21 @@ function buildForm() {
addWKTInput(input); addWKTInput(input);
} else if (formats["text/xml; subtype=wfs-collection/1.0"]) { } else if (formats["text/xml; subtype=wfs-collection/1.0"]) {
addWFSCollectionInput(input); addWFSCollectionInput(input);
} else if (formats["image/tiff"]) {
addRasterInput(input);
} else { } else {
supported = false; supported = false;
} }
} else if (input.boundingBoxData) {
addBoundingBoxInput(input);
} else if (input.literalData) { } else if (input.literalData) {
addLiteralInput(input); addLiteralInput(input);
} else { } else {
supported = false; supported = false;
} }
if (input.minOccurs > 0) {
document.getElementById("input").appendChild(document.createTextNode("* "));
}
} }
if (supported) { if (supported) {
@@ -170,6 +178,38 @@ function addWFSCollectionInput(input) {
document.getElementById("input").appendChild(field); 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 // helper function to create a literal input textfield or dropdown
function addLiteralInput(input, previousSibling) { function addLiteralInput(input, previousSibling) {
var name = input.identifier; var name = input.identifier;
@@ -251,7 +291,7 @@ function execute() {
// remove occurrences that the user has not filled out // remove occurrences that the user has not filled out
for (var i=process.dataInputs.length-1; i>=0; --i) { for (var i=process.dataInputs.length-1; i>=0; --i) {
input = process.dataInputs[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); OpenLayers.Util.removeItem(process.dataInputs, input);
} }
} }
@@ -264,7 +304,7 @@ function execute() {
process.responseForm.rawDataOutput.mimeType = "application/wkt"; process.responseForm.rawDataOutput.mimeType = "application/wkt";
} }
OpenLayers.Request.POST({ OpenLayers.Request.POST({
url: "http://suite.opengeo.org/geoserver/wps", url: wps,
data: new OpenLayers.Format.WPSExecute().write(process), data: new OpenLayers.Format.WPSExecute().write(process),
success: showOutput success: showOutput
}); });
+2 -2
View File
@@ -270,8 +270,8 @@ OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
*/ */
writers: { writers: {
"ows": { "ows": {
"BoundingBox": function(options) { "BoundingBox": function(options, nodeName) {
var node = this.createElementNSPlus("ows:BoundingBox", { var node = this.createElementNSPlus(nodeName || "ows:BoundingBox", {
attributes: { attributes: {
crs: options.projection crs: options.projection
} }
+1 -1
View File
@@ -82,7 +82,7 @@ OpenLayers.Format.WFST.v1_0_0 = OpenLayers.Class(
// Not the superclass, only the mixin classes inherit from // Not the superclass, only the mixin classes inherit from
// Format.GML.v2. We need this because we don't want to get readNode // Format.GML.v2. We need this because we don't want to get readNode
// from the superclass's superclass, which is OpenLayers.Format.XML. // 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);
}, },
/** /**
+1 -1
View File
@@ -81,7 +81,7 @@ OpenLayers.Format.WFST.v1_1_0 = OpenLayers.Class(
// Not the superclass, only the mixin classes inherit from // Not the superclass, only the mixin classes inherit from
// Format.GML.v3. We need this because we don't want to get readNode // Format.GML.v3. We need this because we don't want to get readNode
// from the superclass's superclass, which is OpenLayers.Format.XML. // 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);
}, },
/** /**
+6
View File
@@ -175,6 +175,9 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, {
if (input.reference) { if (input.reference) {
this.writeNode("wps:Reference", input.reference, node); this.writeNode("wps:Reference", input.reference, node);
} }
if (input.boundingBoxData) {
this.writeNode("wps:BoundingBoxData", input.boundingBoxData, node);
}
return node; return node;
}, },
"Data": function(data) { "Data": function(data) {
@@ -228,6 +231,9 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, {
} }
return node; return node;
}, },
"BoundingBoxData": function(node, obj) {
this.writers['ows']['BoundingBox'].apply(this, [node, obj, "wps:BoundingBoxData"]);
},
"Body": function(body) { "Body": function(body) {
var node = this.createElementNSPlus("wps:Body", {}); var node = this.createElementNSPlus("wps:Body", {});
if (body.wcs) { if (body.wcs) {