WPS example; support for BoundingBox in WPS format
This commit is contained in:
BIN
examples/data/tazdem.tiff
Normal file
BIN
examples/data/tazdem.tiff
Normal file
Binary file not shown.
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<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">
|
||||
<title>OpenLayers WPS Builder Example</title>
|
||||
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
|
||||
|
||||
@@ -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
|
||||
});
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user