1
votes

I am trying to do a getFeature request using a CQL_FILTER. The filter has two components a spatial filter defined as Within(geometry,POLYGON((144.9085 -37.8540,144.9085 -37.7756,145.0129 -37.7756,145.0129 -37.8540,144.9085 -37.8540))) plus an attribute filter component persons_usually_resident > 400. This should return over 100 polygon features. I get zero returns. Is there something obviously wrong here?

http://13.55.5.169:8008/geoserver/abs/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.0&TYPENAME=2016MBmeshblocks&srsName=EPSG:4326&OUTPUTFORMAT=application/json&DRAPEID=5445&CQL_FILTER=Within(geometry,POLYGON((144.9085 -37.8540,144.9085 -37.7756,145.0129 -37.7756,145.0129 -37.8540,144.9085 -37.8540))) AND persons_usually_resident > 400

2
do the two filters work on their own? - Ian Turton

2 Answers

0
votes

You need to urlencode the CQL_FILTER parameter, for example this works for me:

curl -v -G --data-urlencode "CQL_FILTER=Within(geometry,POLYGON((144.9085 -37.8540,144.9085 -37.7756,145.0129 -37.7756,145.0129 -37.8540,144.9085 -37.8540))) AND persons_usually_resident > 400"  \
"http://13.55.5.169:8008/geoserver/abs/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.0&TYPENAME=2016MBmeshblocks&srsName=EPSG:4326&OUTPUTFORMAT=application/json&DRAPEID=5445"
0
votes

Thanks Ian, but I'm afraid I have already tested that.

I know the spatial data is correct as I have used a BBOX CQL_FILTER with the same geometry and it works fine returning the correct data number of featuress and no urlencoding. That also validates we are looking at the correct layer and geometry. This also returns about the same number of features as the spatial filters should be returning - there will be minor differences tho due to the Within is a little different to BBOX.

http://13.55.5.169:8008/geoserver/abs/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=1.0.0&TYPENAME=2016MBmeshblocks&OUTPUTFORMAT=application/json&CQL_FILTER=BBOX(geometry,144.7434,-37.9707,145.1608,-37.6572)%20AND%20persons_usually_resident%20%3E%20400

I have also checked the syntax of the WKT POLYGON((144.7434 -37.9707,144.7434 -37.6572,145.1608 -37.6572,145.1608 -37.9707,144.7434 -37.9707)) via https://arthur-e.github.io/Wicket/sandbox-gmaps3.html so I feel confident that is correct.

In addition I tried an OGC filter with no luck.

http://13.55.5.169:8008/geoserver/abs/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.0&TYPENAME=2016MBmeshblocks&OUTPUTFORMAT=application/json&FILTER=<Filter><And><PropertyIsGreaterThan><PropertyName>persons_usually_resident</PropertyName><Literal>400</Literal></PropertyIsGreaterThan><Within><PropertyName>geometry</PropertyName><Polygon><outerBoundaryIs><LinearRing><coordinates decimal='.' cs=':' ts=' '>144.7434:-37.9707 144.7434:-37.6572 145.1608:-37.6572 145.1608:-37.9707 144.7434:-37.9707</coordinates></LinearRing></outerBoundaryIs></Polygon></Within></And></Filter>

I need to be able to support either a OGC or CQL spatial filter with a variable sized search polygon which could be a circle or a user digitized area. I can do this on a Cubewerx WFS service but am really struggling with Geoserver 2.11.2.

The only thing I can think of is that the access control setting on our geoserver may be set incorrectly. Can you advise there?

http://13.55.5.169:8008/geoserver/abs/wfs?request=getcapabilities&service=WFS

specifically...

<fes:Constraint name="ImplementsSpatialFilter">
<ows:NoValues/>
<ows:DefaultValue>FALSE</ows:DefaultValue>
</fes:Constraint>

If this is a problem how can I change this default constraint?

We are also thinking of upgrading to a newer version of geoserver.

Thanks again for your help. Brad....