In the previous recipe, you started working with geoprocessing requests. Looking at the supported operations, you see that it is a very long one. There are several different operations you can perform on the data. Most of these operations are quite simple, while in a real-world use case, you often need more complex ones. So, how can you translate a real-world use case into a task that GeoServer is able to execute? The elegant and efficient answer is chaining processes.
WPS lets you use the result of an operation as an input to another operation. While this may seem very simple, it offers you an incredible flexibility and power. By using the built-in operations as building blocks, you can create very complex geoprocessing tasks. The WPS process builder will let us try out this powerful idea.
In this recipe, your target is to find all populated places located inside Switzerland.
You created a relatively complex task by using three simple operations exposed by WPS.
Your target is to select all point features inside an area, that is, Switzerland. The first step is to set the geometry of Switzerland. You can input it by typing a WKT description, of course, but this may work only for a really simple and small geometry. In a real-world scenario, you'll have to type hundreds or thousands of vertices, which is also error-prone and time-consuming.
We already have a detailed representation of Switzerland boundaries in the EuropeCountries layer, so the first step is to filter it with the gs:Query
operation.
The query made use of a CQL filter to select Switzerland and resulted in an XML document containing the description of the extracted feature. The XML included the values of geometrical and alphanumerical attributes.
You only need the geometry part and in a form suitable to work as an input for a gs:Clip
operation. This transformation is what gs:CollectGeometries
performs.
You can try to build a simpler task by just using the gs:Query
and gs:CollectGeometries
operations. The result is an XML fragment shown in the following snippet:
<gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> <gml:polygonMember> <gml:Polygon> <gml:outerBoundaryIs> <gml:LinearRing> <gml:coordinates>8.617437378000076,47.757318624000085 8.62983972100005,47.76279632600007 … 8.607618856000105,47.76225372300012 8.617437378000076,47.757318624000085</gml:coordinates> </gml:LinearRing> </gml:outerBoundaryIs> </gml:Polygon> </gml:polygonMember> </gml:MultiPolygon>
This is exactly the input that gs:Clip
expects as clip geometry.
You can chain many different processes to fit your requirements. Of course, you can interact with WPS from an external app as we are going to see in the next recipe.
18.221.163.13