Using the WPS process builder

In the previous recipe, you installed the WPS module. It's now time to have a look at what it offers you and what can be done with its operations. As it is the easiest way, we will use the WPS request builder to explore geoprocessing operations.

How to do it…

  1. Open the GeoServer administrative interface and open the WPS process builder page.
  2. The first control in the page is a list containing all processes published by the WPS to you. If you open it and scroll down, you will see that it is a very long list and there are several different process grouped in categories.
    How to do it…
  3. Select the JTS:buffer item. The page loads some controls where you can input the operation's parameters. The first one is about the geometry on which you want to apply the buffer operation. Leave the TEXT type in the first list and select the application/wkt in the other list. This will allow you to insert geometry in a simple and well readable format. Insert a point geometry, as shown in the following screenshot:
    How to do it…
  4. Now switch to distance and insert 0.01. As stated by the Help option, the units have to be the same you used when specifying the geometry. In this example, you're using decimal degrees.
    How to do it…
  5. Leave the other parameters unchanged, scroll down to the bottom of the page, and press the Execute Process button. GeoServer will show you the result in a new panel.
    How to do it…

How it works…

The WPS process builder is an easy way to use geoprocessing operations. It builds the XML requests for you. This is very useful not only to learn but also to build requests that you may use in another application.

How does the process builder work? It parses the WPS capabilities and renders the information contained in it to a form human-readable. Point your browser to http://localhost/geoserver/ows?service=wps&version=1.0.0&request=GetCapabilities, and you will see a long XML containing all the operations supported. The following fragment shows the basic operations and the info for JTS:buffer:

<ows:OperationsMetadata>
  <ows:Operation name="GetCapabilities">
    <ows:DCP>
      <ows:HTTP>
        <ows:Get xlink:href="http://localhost/geoserver/wps"/>
        <ows:Post xlink:href="http://localhost/geoserver/wps"/>
      </ows:HTTP>
    </ows:DCP>
  </ows:Operation>
  <ows:Operation name="DescribeProcess">
    <ows:DCP>
      <ows:HTTP>
        <ows:Get xlink:href="http://localhost/geoserver/wps"/>
        <ows:Post xlink:href="http://localhost/geoserver/wps"/>
      </ows:HTTP>
    </ows:DCP>
  </ows:Operation>
  <ows:Operation name="Execute">
    <ows:DCP>
      <ows:HTTP>
        <ows:Get xlink:href="http://localhost/geoserver/wps"/>
        <ows:Post xlink:href="http://localhost/geoserver/wps"/>
      </ows:HTTP>
    </ows:DCP>
  </ows:Operation>
</ows:OperationsMetadata>
…
<wps:Process wps:processVersion="1.0.0">
  <ows:Identifier>JTS:buffer</ows:Identifier>
  <ows:Title>Buffer</ows:Title>
  <ows:Abstract>Returns a polygonal geometry representing the input geometry enlarged by a given distance around its exterior.</ows:Abstract>
</wps:Process>
…

So when you select JTS:buffer from the list, a DescribeProcess request is created and forwarded to GeoServer:

http://localhost/geoserver/ows?service=wps&version=1.0.0&request=DescribeProcess&Identifier=JTS:buffer

The WPS process builder receive an XML like the following and it parses it to build the interface to populate processing parameters:

…
<ows:Identifier>JTS:buffer</ows:Identifier>
  <ows:Title>Buffer</ows:Title>
  <ows:Abstract>Returns a polygonal geometry representing the input geometry enlarged by a given distance around its exterior.</ows:Abstract>
  <DataInputs>
    <Input maxOccurs="1" minOccurs="1">
      <ows:Identifier>geom</ows:Identifier>
      <ows:Title>geom</ows:Title>
      <ows:Abstract>Input geometry</ows:Abstract>
      <ComplexData>
        <Default>
          <Format>
            <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
          </Format>
        </Default>
        <Supported>
          <Format>
            <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
          </Format>
          <Format>
            <MimeType>text/xml; subtype=gml/2.1.2</MimeType>
          </Format>
          <Format>
            <MimeType>application/wkt</MimeType>
          </Format>
          <Format>
            <MimeType>application/gml-3.1.1</MimeType>
          </Format>
          <Format>
            <MimeType>application/gml-2.1.2</MimeType>
          </Format>
        </Supported>
      </ComplexData>
…

The described process response contains all information needed to build a proper Process request. If your input is correct, when you press the Execute Process button, the WPS process builder sends a POST request with a body similar to this one:

<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
    <ows:Identifier>JTS:buffer</ows:Identifier>
    <wps:DataInputs>
        <wps:Input>
            <ows:Identifier>geom</ows:Identifier>
            <wps:Data>
                <wps:ComplexData mimeType="application/wkt">
                    <![CDATA[POINT(12.33 42.24)]]>
                </wps:ComplexData>
            </wps:Data>
        </wps:Input>
        <wps:Input>
            <ows:Identifier>distance</ows:Identifier>
            <wps:Data>
                <wps:LiteralData>0.01</wps:LiteralData>
            </wps:Data>
        </wps:Input>
    </wps:DataInputs>
    <wps:ResponseForm>
        <wps:RawDataOutput mimeType="text/xml; subtype=gml/3.1.1">
            <ows:Identifier>result</ows:Identifier>
        </wps:RawDataOutput>
    </wps:ResponseForm>
</wps:Execute>

The result of this operation is the XML showed in the previous screenshot.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.173.199