On Wed, Jul 27, 2011 at 5:24 AM, Adam Ratcliffe
<adam.ratcli...@geosmart.co.nz> wrote:
> Hi,
>
> Is it possible to do this with GeoServer?
>
> My use case is that I have an OpenLayers client which uses a WMS layer for
> data display. The user can set an OGC filter on the layer to restrict the
> features displayed. I would like to provide a function to allow the user to
> zoom the map to the extent of the currently filtered layer.
WFS does not have such functionality, in order to have the bbox you
still have to get the features with at least one property in
> If not possible in GeoServer, I'm thinking of implementing a standalone web
> service to calculate the bounding box. While not familiar with GeoTools I'm
> wondering if it would make sense to use it as it appears to have support for
> parsing OGC filters etc.
Yeah, you'd have to also setup filter parsing. You can find the code in the
WFS module, Filter_1_0_0_KvpParser and Filter_1_1_0_KvpParser.
Or, you can use WPS, there is a process that just returns the bounds
of a given feature collection.
The attached process will hit the internal WFS as the source of the
collection, skipping al GML handling and going directly into the
data souce, meaning that if your data source is a postgis db
it will actually run a select for bounds in SQL.
The process can be run against a vanilla GeoServer + WPS
extension with the following:
curl -XPOST -H 'Content-type: text/xml' -d @/tmp/box.xml
"http://localhost:8080/geoserver/wps"
and should result in:
<?xml version="1.0" encoding="UTF-8"?>
<ows:BoundingBox crs="EPSG:4326"
xmlns:ows="http://www.opengis.net/ows/1.1"><ows:LowerCorner>-79.763466
40.505898</ows:LowerCorner><ows:UpperCorner>-71.870476
45.0061</ows:UpperCorner
which are the bounds of the state of New York (the wfs request embedded
in the WPS call filters on the state name to get just that state).
The main advantage of using WPS is that you'll also get a raft of
other handy spatial
processing functions, the downside is that at the moment there is no
way to cherry
pick the processes you want to expose, you get all 79 of the default
built-in processes.
Hope this helps
Cheers
Andrea
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------
<?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:Bounds</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>features</ows:Identifier>
<wps:Reference mimeType="text/xml; subtype=wfs-collection/1.0" xlink:href="http://geoserver/wfs" method="POST">
<wps:Body>
<wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2">
<wfs:Query typeName="topp:states">
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>STATE_NAME</ogc:PropertyName>
<ogc:Literal>New York</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
</wps:Body>
</wps:Reference>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:RawDataOutput>
<ows:Identifier>bounds</ows:Identifier>
</wps:RawDataOutput>
</wps:ResponseForm>
</wps:Execute>
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users