[Geoserver-users] MAX function in filter

Hi

I try to use a function in filter of a WFS getFeature Request but it doesn't works .

<!-- Performs a get feature. Feel free to play with the Filter elements, -->
<!-- to get different results. No filter will get all features, and you -->
<!-- can do filtering on spatial and non-spatial attributes. See the ogc -->
<!-- filter specification http://www.opengis.org/docs/02-059.pdf for the -->
<!-- the complete syntax and examples. -->
<!--

  -->
<wfs:GetFeature service="WFS" version="1.0.0"
  outputFormat="GML2"
  xmlns:topp="http://www.openplans.org/topp&quot;
  xmlns:wfs="http://www.opengis.net/wfs&quot;
  xmlns:ogc="http://www.opengis.net/ogc&quot;
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation="http://www.opengis.net/wfs
                      http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd&quot;&gt;
  <wfs:Query typeName="topp:states">
    <Filter>
       <Function name="MAX">
       <PropertyName>WORKERS</PropertyName>
</Function>
    </Filter>
    </wfs:Query>
</wfs:GetFeature>

the max function is in the WFS getcapabilities but i've a null pointer exception as server answer.

I use the example requests of geoserver 1-5-0.

Anybody knows where is the problem?

olivier.terral ha scritto:

Hi

I try to use a function in filter of a WFS getFeature Request but it doesn't works .

<!-- Performs a get feature. Feel free to play with the Filter elements, -->
<!-- to get different results. No filter will get all features, and you -->
<!-- can do filtering on spatial and non-spatial attributes. See the ogc -->
<!-- filter specification http://www.opengis.org/docs/02-059.pdf for the -->
<!-- the complete syntax and examples. -->
<!--

  -->
<wfs:GetFeature service="WFS" version="1.0.0"
  outputFormat="GML2"
  xmlns:topp="http://www.openplans.org/topp&quot;
  xmlns:wfs="http://www.opengis.net/wfs&quot;
  xmlns:ogc="http://www.opengis.net/ogc&quot;
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation="http://www.opengis.net/wfs
                      http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd&quot;&gt;
  <wfs:Query typeName="topp:states">
    <Filter>
       <Function name="MAX">
       <PropertyName>WORKERS</PropertyName>
</Function>
    </Filter>
    </wfs:Query>
</wfs:GetFeature>

the max function is in the WFS getcapabilities but i've a null pointer exception as server answer.

I use the example requests of geoserver 1-5-0.

Anybody knows where is the problem?

The problem is that the above one is not a filter... MAX computes just
the maximum value of the two integer arguments you pass to it.
MAX_2, 3 and 4 are variants accepting other data types.

If you need the sql aggregate function, in order to extract the state
with the most workers, you'll have to move your data to a dbms, and then
build a view that does the query you want, and register it as a feature type... not very nice, I know.

Afaik the filter specification does not have any support for aggregated
functions... it would be nice to, but it's a non trivial task, since we
would have to do a custom extension, and rewrite most non sql datastore
filtering to do a two pass loading, the first to compute the aggregate
functions, the second to use them as filter... ugh...

Might be easier to allow JDBC data stores to define on the fly new feature types defined with custom sql... (to avoid having to setup
a long lived view in the database).

Cheers
Andrea