[Geoserver-users] retrieving the feature with the maximum property value

Hi,

I suspect the following cannot be expressed in a single WFS request, not sure if there is a GeoServer extension that supports this?

“Give me the feature of type X that has the maximum value for property Y among all features of type X”

Thanks,
Alex

Alex Milanovic ha scritto:

Hi,

I suspect the following cannot be expressed in a single WFS request, not sure if there is a GeoServer extension that supports this?

"Give me the feature of type X that has the maximum value for property Y among all features of type X"

Indeed it cannot be expressed as a single WFS request, it could probably
be part of a WPS request instead, but our WPS is only a prototype
for the moment.
Right now we don't have any way to support such a request, sorry.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Alex Milanovic ha scritto:

Hi,

I suspect the following cannot be expressed in a single WFS request, not sure if there is a GeoServer extension that supports this?

"Give me the feature of type X that has the maximum value for property Y among all features of type X"

Ah, btw, a cheap way to get that could be to create a view that resolves that request for all x values.

create view myPublicGeoServerType as select *
from table t1
where t1.id = (select t2.id
   from table t2
   where t2.x = t1.x
   and y = (select max(y) from table t3 where t3.x = t2.x))

And the thru wfs you just add the x = somevalue predicate,
the sql optimizer should be smart enough to recognize the
overall structure of the query and optimize it so that
only the records with x = somevalue are scanned.

Just a thought
Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Wonder, if property Y is of a numeric type, shouldn't a sortby Y descending and maxFeatures=1 do the trick?

2c.-

Gabriel
Andrea Aime escribió:

Alex Milanovic ha scritto:
  

Hi,

I suspect the following cannot be expressed in a single WFS request, not sure if there is a GeoServer extension that supports this?

"Give me the feature of type X that has the maximum value for property Y among all features of type X"
    
Indeed it cannot be expressed as a single WFS request, it could probably
be part of a WPS request instead, but our WPS is only a prototype
for the moment.
Right now we don't have any way to support such a request, sorry.

Cheers
Andrea

Gabriel Roldan ha scritto:

Wonder, if property Y is of a numeric type, shouldn't a sortby Y descending and maxFeatures=1 do the trick?

Oh, you're right indeed, good thinking.
Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Both good ideas, thanks. :slight_smile:
Alex

On Mon, Nov 3, 2008 at 3:12 PM, Andrea Aime <aaime@anonymised.com> wrote:

Gabriel Roldan ha scritto:

Wonder, if property Y is of a numeric type, shouldn’t a sortby Y descending and maxFeatures=1 do the trick?

Oh, you’re right indeed, good thinking.

Cheers
Andrea


Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.