Thanks Andrea, I've tried with WPS and that's exactly what I was looking for.
Cheers Adam ________________________________________ From: andrea.a...@gmail.com [andrea.a...@gmail.com] On Behalf Of Andrea Aime [andrea.a...@geo-solutions.it] Sent: 27 July 2011 20:11 To: Adam Ratcliffe Cc: geoserver-users@lists.sourceforge.net Subject: Re: [Geoserver-users] How to get the bounding box only for a GetFeature request? 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 ------------------------------------------------------- ------------------------------------------------------------------------------ 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