WPS Manager - geosolutions-it/MapStore GitHub Wiki

Needed Files

In order to use the WPS plugin in MapStore you need to be sure that the files below are included in the buildjs.cfg file:

  • openlayers-ext/lib/OpenLayers/Format/WCSGetCoverage.js
  • openlayers-ext/lib/OpenLayers/Format/OGCExceptionReport.js
  • openlayers-ext/lib/OpenLayers/Format/XML/VersionedOGC.js
  • openlayers-ext/lib/OpenLayers/Format/OWSCommon.js
  • openlayers-ext/lib/OpenLayers/Format/OWSCommon/v1_ext.js
  • openlayers-ext/lib/OpenLayers/Format/WFST/v1_1_0_ext.js
  • openlayers-ext/lib/OpenLayers/Format/OWSCommon/v1_1_0_ext.js
  • openlayers-ext/lib/OpenLayers/Format/GeoStore.js
  • openlayers-ext/lib/OpenLayers/RequestExt.js
  • openlayers-ext/lib/OpenLayers/EventsExt.js
  • openlayers-ext/lib/OpenLayers/RequestExt/XMLHttpRequestExt.js
  • openlayers-ext/lib/OpenLayers/GeoStore.js
  • openlayers-ext/lib/OpenLayers/WPSClient.js
  • openlayers-ext/lib/OpenLayers/WPSProcess.js
  • openlayers-ext/lib/OpenLayers/Format/WPSDescribeProcess.js
  • openlayers-ext/lib/OpenLayers/Format/WPSExecute.js
  • openlayers-ext/lib/OpenLayers/Format/WPSExecuteRequest.js
  • gxp/src/script/plugins/wpsmanager/lib/WPSManager.js
  • gxp/src/script/plugins/client/lib/GeoStoreClient.js

NOTE: In the default configuration this is already done.

##Plugin Description

The WPS Manager Plugin provides a high level API to interact with Web Processing Services (WPS) and manage the Process instances.

The gxp.plugins.WPSManager plugin uses a OpenLayersExt.WPSClient for the WPS interaction and a gxp.plugins.GeoStoreClient to store the Execute instances.

When the WPSManager plugin is instantiated a "Geostore Category" named as the plugin id is created. The WPS Manager Plugin supports synchronous and asynchronus Execute requests. For each Execute request a "Geostore Resource" is created.

For asynchronous requests, the status update response is supported, for the synchronous requests the "raw" data output is supported.

The resource description contains the execute status information and the output type (raw or not raw). The resource store data contains directly the output if the output type is raw or a JSON Object which contains the Execute response information. To parse the Execute response, the OpenLayersExt.Format.WPSExecute object is used.

##Configuration Example

Besides the plugin configuration, the following script import must be uncommented in the composer.html file:

<!-- Externals OpenLayers libraries to manage WPS processes  --> 
<script type="text/javascript" src="script/OpenLayersExt.js"></script>

Then you have to specify a valid plugin configuration, such as:

{
   "ptype": "gxp_wpsmanager",
   "id": "wpsSPM",
   "url": "http://localhost:8080/geoserver/wps",
   "geostoreUrl": "http://localhost:8080/geostore/rest",
   "geostoreUser": "admin",
   "geostorePassword": "admin",
   "geostoreProxy": "/http_proxy/proxy?url="
 }
  • ptype: ptype of the plugin
  • id: plugin identifier
  • url: URL of the WPS service
  • geostoreUrl: GeoStore REST base URL
  • geostoreUser: a valid user name to allow Categorty creation
  • geostorePassword: the corresponding user password
  • geostoreProxy: The proxy to use for Ajax cross domain requests.

##Send WPS Execute request In order to send an Execute Request with the WPSManager plugin you have to use the execute method:

wpsManager.execute(processName,executeRequest,callback,savedInfoCallback);

The processName is the WPS Process name.

The executeRequest can be an Object which contains the request properties or a String which contains directly the WPS Execute request. To parse the WPS Execute request, the OpenlayersExt.Format.WPSExecuteRequest object is used; this defines an object with the request properties. This object properties are:

  • storeExecuteResponse: Boolean Optional. Indicates if the execute response document shall be stored (if true Asynchronous instance).
  • lineage: Boolean Optional. Indicates if the Execute operation response shall include the DataInputs and OutputDefinitions elements.
  • status: Boolean Optional. Indicates if the stored execute response document shall be updated to provide ongoing reports on the status of execution.
  • type: String Optional. Type of output ("data" or "raw")
  • inputs: Object Mandatory. The inputs for the process, keyed by input identifier.The data input types currently supported are: OpenLayers.WPSProcess.LiteralData, OpenLayers.WPSProcess.ComplexData, OpenLayers.WPSProcess.BoundingBoxData, OpenLayers.WPSProcess.ReferenceData.
  • outputs: Array Mandatory. Array of OpenLayers.WPSProcess.Output Object

The optional callback is a function called when the execute response is retrieved.

The optional savedInfoCallback is a function called when the an asynchronous execute response is retrieved and the relatd status is stored on GeoStore (available from 1.5 release).

##WPS Execute Synchronous request An example of sending a WPS Execute synchronous request is the following:

wpsManager.execute('JTS:isValid',{
   "inputs": {
            geom: new OpenLayers.WPSProcess.ComplexData({
                  value: "POINT(6 40)",
                  mimeType: "application/wkt"
             })
   },
   "outputs": [{
        "identifier": "result",
        "mimeType" : "text/xml"
   }]
 });

The sequence of interactions is described on the following figure:

WPSManager -  Execute synchronous request - sequence of intercations

##WPS Execute Asynchronous request An example of sending a WPS Execute asynchronous request is the following:

wpsManager.execute('JTS:isValid',{
   "storeExecuteResponse": true,
   "lineage": true,
   "status": true,
   "inputs": {
            geom: new OpenLayers.WPSProcess.ComplexData({
                  value: "POINT(6 40)",
                  mimeType: "application/wkt"
             })
   },
   "outputs": [{
        "identifier": "result",
        "mimeType" : "text/xml"
   }]
 });

The sequence of interactions is described on the following figure:

WPSManager - Execute asynchronous request - sequence of intercations

##WPS Execute Asynchronous request with final download (available from 1.5 release) An example of sending a WPS Execute asynchronous request that returns a link to download the result is the following:

wpsManager.execute('JTS:pointN',{
   "storeExecuteResponse": true,
   "lineage": true,
   "status": true,
   "inputs": {
            geom: new OpenLayers.WPSProcess.ComplexData({
                  value: "LINESTRING(0 0, 1 1)",
                  mimeType: "application/wkt"
             }),
             index: new OpenLayers.WPSProcess.LiteralData({value:parseInt(document.getElementById("pointN").value, 10)})
   },
   "outputs": [{
        "identifier": "result",
        "mimeType": "text/xml; subtype=gml/3.1.1",
        "asReference": true

   }]
 }, function() {}, downloadCallback);

 function downloadCallback() {
        wpsManager.onDownloadReady(id, function(url) {     
             Ext.Msg.show({
                title: "Download" ,
                msg: '<a href="' + url + '" target="_blank">Click here to download</a>',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.INFO
             });
        }, function() {
            Ext.Msg.show({
                title: "Error" ,
                msg: 'Error executing process',
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR
             });
        });
 }
⚠️ **GitHub.com Fallback** ⚠️