Merge pull request #632 from ahocevar/wps-client

WPS Client. r=@bartvde,@tschaub
This commit is contained in:
ahocevar
2012-08-18 10:01:01 -07:00
9 changed files with 1135 additions and 3 deletions

31
examples/wps-client.html Normal file
View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<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="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers WPS Client Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="../lib/OpenLayers.js"></script>
<script src="wps-client.js"></script>
</head>
<body onload="init()">
<h1 id="title">WPS Client Example</h1>
<div id="tags">
wps
</div>
<div id="shortdesc">Shows the usage of the WPS Client</div>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>This example shows how simple it is to use the WPS Client. It
buffers an intersection of a geometry and a feature, which is
accomplished by chaining two processes. See
<a href="wps-client.js">wps-client.js</a> to see how this is done.</p>
</div>
</body>
</html>

75
examples/wps-client.js Normal file
View File

@@ -0,0 +1,75 @@
OpenLayers.ProxyHost = 'proxy.cgi?url=';
var map, client, intersect, buffer;
function init() {
map = new OpenLayers.Map('map', {
allOverlays: true,
center: [114, 16],
zoom: 4,
layers: [new OpenLayers.Layer.Vector()]
});
var features = [new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT(
'LINESTRING(117 22,112 18,118 13, 115 8)'
))];
var geometry = OpenLayers.Geometry.fromWKT(
'POLYGON((110 20,120 20,120 10,110 10,110 20),(112 17,118 18,118 16,112 15,112 17))'
);
map.baseLayer.addFeatures(features);
map.baseLayer.addFeatures([new OpenLayers.Feature.Vector(geometry)]);
client = new OpenLayers.WPSClient({
servers: {
opengeo: 'http://demo.opengeo.org/geoserver/wps'
}
});
// Create a process and configure it
intersect = client.getProcess('opengeo', 'JTS:intersection');
intersect.configure({
// spatial input can be a feature or a geometry or an array of
// features or geometries
inputs: {
a: features,
b: geometry
}
});
// Create another process which chains the previous one and execute it
buffer = client.getProcess('opengeo', 'JTS:buffer');
buffer.execute({
inputs: {
geom: intersect.output(),
distance: 1
},
success: function(outputs) {
// outputs.result is a feature or an array of features for spatial
// processes.
map.baseLayer.addFeatures(outputs.result);
}
});
// Instead of creating a process and executing it, we could call execute on
// the client directly if we are only dealing with a single process:
/*
client.execute({
server: "opengeo",
process: "JTS:intersection",
// spatial input can be a feature or a geometry or an array of
// features or geometries
inputs: {
a: features,
b: geometry
},
success: function(outputs) {
// outputs.result is a feature or an array of features for spatial
// processes.
map.baseLayer.addFeatures(outputs.result);
}
});
*/
}

View File

@@ -50,7 +50,9 @@
<p>This example shows WPS in action by using the WPSCapabilities,
WPSDescribeProcess and WPSExecute formats. See
<a target="_blank" href="wps.js">wps.js</a> for the
source code.</p>
source code. <b>Note: For applications using WPS, the high level
approach shown in the <a href="wps-client.html">wps-client</a> example
is recommended instead.</b></p>
<ol>
<li>Select a process from the list below the map. The list is
populated with the result of a WPS GetCapabilities request, parsed