I want to use WPS Aggregation process to get a pivot table based on some
attribute for a subset of the features of a layer.
[https://docs.geoserver.org/latest/en/user/services/wps/processes/gs.html#aggregation-process]
I started with a simple gs:CollectGeometries:
<?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>gs:CollectGeometries</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>features</ows:Identifier>
<wps:Reference mimeType="text/xml"
xlink:href="http://geoserver/wfs" method="POST">
<wps:Body>
<wfs:GetFeature service="WFS" version="1.0.0"
outputFormat="GML2" xmlns:bi="http://bi.org">
<wfs:Query typeName="bi:ways">
<ogc:PropertyIsEqualTo>
<ogc:Function name="strMatches">
<ogc:PropertyName>myField</ogc:PropertyName>
<ogc:Literal>.*\b(131)\b.*</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</wfs:Query>
</wfs:GetFeature>
</wps:Body>
</wps:Reference>
</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>
It works and I get a gml:MultiLineString with the features of the subset
as a result.
So I try the aggregate function with a simple filter:
<?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>gs:Aggregate</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>features</ows:Identifier>
<wps:Reference mimeType="text/xml"
xlink:href="http://geoserver/wfs" method="POST">
<wps:Body>
<wfs:GetFeature service="WFS" version="1.0.0"
outputFormat="GML2" xmlns:bicitalia="http://bi.org">
<wfs:Query typeName="bi:ways">
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>myField</ogc:PropertyName>
<ogc:Literal>131</ogc:Literal>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
</wps:Body>
</wps:Reference>
</wps:Input>
<wps:Input>
<ows:Identifier>aggregationAttribute</ows:Identifier>
<wps:Data>
<wps:LiteralData>length</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>function</ows:Identifier>
<wps:Data>
<wps:LiteralData>Sum</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>singlePass</ows:Identifier>
<wps:Data>
<wps:LiteralData>false</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>groupByAttributes</ows:Identifier>
<wps:Data>
<wps:LiteralData>surface</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>groupByAttributes</ows:Identifier>
<wps:Data>
<wps:LiteralData>width</wps:LiteralData>
</wps:Data>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:RawDataOutput mimeType="application/json">
<ows:Identifier>result</ows:Identifier>
</wps:RawDataOutput>
</wps:ResponseForm>
</wps:Execute>
It works as expected.
Now I dare to use strMatches with the aggregate function:
<?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>gs:Aggregate</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>features</ows:Identifier>
<wps:Reference mimeType="text/xml"
xlink:href="http://geoserver/wfs" method="POST">
<wps:Body>
<wfs:GetFeature service="WFS" version="1.0.0"
outputFormat="GML2" xmlns:bicitalia="http://bi.org">
<wfs:Query typeName="bi:ways">
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="strMatches">
<ogc:PropertyName>myField</ogc:PropertyName>
<ogc:Literal>.*\b(131)\b.*</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
</wps:Body>
</wps:Reference>
</wps:Input>
<wps:Input>
<ows:Identifier>aggregationAttribute</ows:Identifier>
<wps:Data>
<wps:LiteralData>length</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>function</ows:Identifier>
<wps:Data>
<wps:LiteralData>Sum</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>singlePass</ows:Identifier>
<wps:Data>
<wps:LiteralData>false</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>groupByAttributes</ows:Identifier>
<wps:Data>
<wps:LiteralData>surface</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>groupByAttributes</ows:Identifier>
<wps:Data>
<wps:LiteralData>width</wps:LiteralData>
</wps:Data>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:RawDataOutput mimeType="application/json">
<ows:Identifier>result</ows:Identifier>
</wps:RawDataOutput>
</wps:ResponseForm>
</wps:Execute>
Now I get an error:
<wps:ExecuteResponse xml:lang="en" service="WPS"
serviceInstance="https://bi.org/geoserver/ows?" version="1.0.0">
<wps:Process wps:processVersion="1.0.0">
<ows:Identifier>gs:Aggregate</ows:Identifier>
<ows:Title>Aggregate</ows:Title>
<ows:Abstract>
Computes one or more aggregation functions on a feature attribute.
Functions include Count, Average, Max, Median, Min, StdDev, and Sum.
</ows:Abstract>
</wps:Process>
<wps:Status creationTime="2022-06-09T07:44:02.223Z">
<wps:ProcessFailed>
<ows:ExceptionReport version="1.1.0">
<ows:Exception exceptionCode="NoApplicableCode">
<ows:ExceptionText>
Process failed during execution java.io.IOExceptionERROR: function
strmatches(character varying, unknown) does not exist Hint: No function
matches the given name and argument types. You might need to add
explicit type casts. Position: 108
</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>
</wps:ProcessFailed>
</wps:Status>
</wps:ExecuteResponse>
Why is that? Why does strMatches work with gs:CollectGeometries but not
with gs:Aggregate?
Any clue?
thank you
maxx