0

I have data in the GeoServer coming from Microsoft's SQL server. I want to use CQL filter with WMS to query and get 4000k records as a result. I need to know is there any way my CQl filter with WMS or WFS or WPS can return extent for the selected 4k records in the resultant response?If the result is 2k records, then it should return the extent for those.For ex,

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=getfeature&typename=topp:states&CQL_FILTER=STATE_NAME=%27Idaho%27&resulttype=hits

returns 1 record as below in XML

<wfs:FeatureCollection xmlns:it.geosolutions="http://www.geo-solutions.it"    xmlns:cite="http://www.opengeospatial.net/cite" xmlns:ogc="http://www.opengis.net/ogc" xmlns:tiger="http://www.census.gov" xmlns:sde="http://geoserver.sf.net" xmlns:topp="http://www.openplans.org/topp" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:KFRI="http://www.kfri.res.in/" xmlns:sf="http://www.openplans.org/spearfish" xmlns:gml="http://www.opengis.net/gml" xmlns:nurc="http://www.nurc.nato.int" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfFeatures="1" timeStamp="2016-08-01T11:45:42.443Z" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"/>

In addition,i need the extent also for the feature in the response. And please note that if the response returns 4 features also then it should return one extent for all those 4 features instead of returning extent for each feature.

1 Answer 1

2

The question was cross posted on geoserver-users and geoserver-devel too, and was replied to on geoserver-users.

For the record, one cannot use WFS, but WPS in GeoServer has a suitable process, "gs:Bounds", doing this very job. E.g., this is an example request against the local tiger:roads layer:

<?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" xlink:href="http://geoserver/wfs" method="POST"> <wps:Body> <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2" xmlns:tiger="http://www.census.gov"> <wfs:Query typeName="tiger:tiger_roads"/> </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>

If I save it into a file in /tmp/bounds.xml and post it to the GeoSolutions demo GeoServer like this:

curl -H "Content-type: text/xml" -d @/tmp/bounds.xml "http://demo.geo-solutions.it/geoserver/ows"

then the response is a single bounding box for the entire layer:

<?xml version="1.0" encoding="UTF-8"?><ows:BoundingBox xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows/1.1" crs="EPSG:4326"><ows:LowerCorner>-74.02722 40.684221</ows:LowerCorner><ows:UpperCorner>-73.907005 40.878178</ows:UpperCorner></ows:BoundingBox>

You can modify the WFS request embedded in the WPS one (acting as the data source) in order to filter the features being used to compute the bbox

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.