8

Is it possible (and what is the recommended way) to use OpenLayers 3 to do the work of theOpenLayers.WPSClient?

As shown in the old WPS client example, OpenLayers 2 can be used to operate WPS.

There are OpenLayers 3 examples for using other web services like WFS and WMS, but not WPS (as of 3.2.1).

Is this temporary or by design?

7

As part of the WPS-GUI project that I did I created a WPS client "library" that closely models after the OpenLayers 2 interface. It uses JSONIX (http://confluence.highsource.org/display/JSNX/Jsonix) for the all OGC XML marshalling and unmarshalling.

You can check it out here:

https://github.com/boundlessgeo/wps-gui/blob/master/src/wpsclient.js

  • Thanks a lot for your answer! Is this js file stand-alone? This is a bit overwhelming for my js skills. There seems to be references in wpsclient.js to HTML elements and "global" variables. Could you please give a minimal example use, e.g. to call gs:AddCoverages or another wps in GeoServer/OpenGeo? – tinlyx Feb 24 '15 at 21:55
  • Have you looked at the OpenLayers 2 WPS example? The interface used here is very similar. – bartvde Feb 26 '15 at 18:39
  • Thanks, I'll take a look. I started with OpenLayers 3, and need to test OpenLayers 2. – tinlyx Feb 27 '15 at 18:42
  • @bartvde Can you give me example of buffer using wps service in openlayer 3.?? – Priyanka Jun 28 '17 at 10:40
3

I also reused the openlayers 2 client in a wps builder. I did have to implement the DefaultValue and ExecuteResponse objects.

There is some wider need for a mapping client independent wps client, as seen in this discussion on working towards a ows.js (based on jsonix, like @bartvde's implementation). Since that discussion work has started. The WPS implementation has not started yet. The idea of javascript ows.js is modelled after the convenient owslib library.

The main challenges in implementing a WPS client are:

  • defining the xml to object mapping. That's the role of jsonix and the OpenLayers (2) format readers.
  • defining a convenient api for executing requests. If you look at the owslib wps implementation as an example you'll see that implementing a convenient api for the WPS processes is not a trivial task. The wide variety of options (with/without status, raw response/reference response, etc...) make supporting all possible in- and outputs quite a challenge.
2

One possibility is to use the wps client from openlayers 2 in your openlayers 3 project. The response from the wps request is in WKT and you can easily format this to a openlayers 3 feature with the built in formatter.

http://openlayers.org/en/v3.9.0/apidoc/ol.format.WKT.html

(The response depending on what wps request you are using of course..)

I did this in a project as I did not have time to implement my own wps client.

2

You can do a trick like this. Geoserver has a WPS Builder that can generate Xml Request from inputs and outputs. Than you can take the generated xml and pass it in a string variable in javascript. Replace xml input values with variables. In my case i needed only one process, but you can do a switch function. You can use a simple xmlPost request to pass the xml string to geoserver.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.