[Pywps-commits] r1002 - trunk/doc/source/clients
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Sep 1 13:07:53 CEST 2010
Author: jachym
Date: 2010-09-01 13:07:53 +0200 (Wed, 01 Sep 2010)
New Revision: 1002
Modified:
trunk/doc/source/clients/javascript.rst
Log:
more documentation from Luca
Modified: trunk/doc/source/clients/javascript.rst
===================================================================
--- trunk/doc/source/clients/javascript.rst 2010-08-31 22:04:23 UTC (rev 1001)
+++ trunk/doc/source/clients/javascript.rst 2010-09-01 11:07:53 UTC (rev 1002)
@@ -4,7 +4,7 @@
`OpenLayers <http://openlayers.org>`_. The client *does not show any
results in the map*, but it enables you, as client coder, to program the
client in hopefully easy way. The client is located in
-:file:`pywps-source/webclient/WPS.js`. Beside this file, OpenLayers have to
+:file:`PyWPS-source/webclient/WPS.js`. Beside this file, OpenLayers have to
be included in the web page.
Initialization and GetCapabilities request
@@ -215,3 +215,60 @@
};
The rest was already defined before.
+
+Handling vector data
+......................................................
+A typical operation performed using OpenLayers and a WPS service,
+is to send data to the server and display the results directly over the map.
+For example consider a process that allows to generate a buffer starting from
+vector data and a number to use as buffer's value. From the DescribeProcess we
+see that those two inputs must be passed as "data" and "buffer".
+At this point we start with the configuration of OpenLayers:
+
+Add vector layer used for editing and the editing toolbar control:
+
+.. code-block:: javascript
+
+ vlayer = new OpenLayers.Layer.Vector("Editable");
+ edit = new OpenLayers.Control.EditingToolbar(vlayer);
+ map.addControl(edit);
+
+Now create the WPS object as defined before;a bit of attention to input/output parameters
+because we're going to use the featues drawn by the user (vlayer) and a literaldata inserted
+in a HTML text box with buffer as id.
+
+Input:
+.. code-block:: javascript
+
+ var dataInput = new OpenLayers.WPS.ComplexPut({
+ identifier:"data",
+ value: OpenLayers.Format.GML.prototype.write(vlayer.features)
+ });
+
+ var literalInput = new OpenLayers.WPS.LiteralPut({
+ identifier:"buffer",
+ value: document.getElementById("buffer").value
+ });
+
+Ouput:
+
+..code-block:: javascript
+ var complexOutput = new OpenLayers.WPS.ComplexPut({
+ identifier: "output",
+ asReference: "true"
+ });
+
+Now move to the onSuceedeed function, the one executed once the process has successfully run.
+Basically we need to add the output file to the list of layers in the map object. OpenLayers
+allows to add GML directly on the map, but watch out for file too big:
+
+..code-block:: javascript
+ var onWPSSussceeded = function(process) {
+ //We need to remove the layer generated by previous instance of the script
+ try {
+ map.removeLayer(rlayer);
+ rlayer.destroy();
+ } catch(e) {}
+ url = process.getOutput("output").value;
+ rlayer = new OpenLayers.Layer.GML("Result",url);
+ Pap.addLayer(rlayer);
More information about the Pywps-commits
mailing list