Hi, Let’s try to be logical and systematic. Here is my incremental test with an open WFS server that is serving the well-known topp:states layer.
1. Read the whole layer because se know it is not so big https://demo.geo-solutions.it/geoserver/wfs?service=WFS&version=1.1.0&TypeName=topp:states&request=GetFeature Result= OK 1. Test with attribute filter https://demo.geo-solutions.it/geoserver/wfs?service=WFS&version=1.1.0&TypeName=topp:states&request=GetFeature&CQL_FILTER=STATE_NAME='Illinois' Result=OK 1. Test with within filter with polygon POLYGON (( -112.95 33.18, -112.95 46.15, -89.44 46.15, -89.44 33.18, -112.95 33.18 )) https://demo.geo-solutions.it/geoserver/wfs?service=WFS&version=1.1.0&TypeName=topp:states&request=GetFeature&CQL_FILTER=Within(the_geom,POLYGON%20((%20-112.95%2033.18,%20-112.95%2046.15,%20-89.44%2046.15,%20-89.44%2033.18,%20-112.95%2033.18%20))) Result: no hit 1. Because the geometry is in EPSG:4326 and WFS version is 1.1.0 we guess where the problem is. So try with VERSION=1.0.0 https://demo.geo-solutions.it/geoserver/wfs?service=WFS&version=1.0.0&TypeName=topp:states&request=GetFeature&CQL_FILTER=Within(the_geom,POLYGON%20((%20-112.95%2033.18,%20-112.95%2046.15,%20-89.44%2046.15,%20-89.44%2033.18,%20-112.95%2033.18%20))) Result: We get hits 1. If we want to use WFS version 1.1.0 we must turn the coordinates and use POLYGON (( 33.18 -112.95, 46.15 -112.95, 46.15 -89.44, 33.18 -89.44, 33.18 -112.95 )) https://demo.geo-solutions.it/geoserver/wfs?service=WFS&version=1.0.0&TypeName=topp:states&request=GetFeature&CQL_FILTER=Within(the_geom,POLYGON%20((%20-112.95%2033.18,%20-112.95%2046.15,%20-89.44%2046.15,%20-89.44%2033.18,%20-112.95%2033.18%20))) Result: We get hits again 1. Now we have a working attribute filter and working spatial filter and we can combine them. Illinois is not within the box so I use Colorado instead https://demo.geo-solutions.it/geoserver/wfs?service=WFS&version=1.1.0&TypeName=topp:states&request=GetFeature&CQL_FILTER=Within(the_geom,POLYGON%20((%2033.18%20-112.95,%2046.15%20-112.95,%2046.15%20-89.44,%2033.18%20-89.44,%2033.18%20-112.95%20)))AND%20STATE_NAME=%27Colorado%27 Result: OK. I can’t test with your server because out firewall does not accept your certificate but tells that it is not valid for 13.55.5.169:8010. Anyway it seems that you have coordinates in wrong order for WFS 1.1.0 and the CRS of your feature type. -Jukka Rahkonen- Lähettäjä: Brad Spencer <[email protected]> Lähetetty: maanantai 10. helmikuuta 2020 13.43 Vastaanottaja: Jody Garnett <[email protected]> Kopio: GeoServer Users <[email protected]> Aihe: Re: [Geoserver-users] Geoserver 2.11.2 See below Sent from my iPhone On 10 Feb 2020, at 22:14, Jody Garnett <[email protected]<mailto:[email protected]>> wrote: bbox spatial filter uses the && operator (working on the index) rather than within which uses the geometries. I don’t understand what you are saying here? Can you elaborate a tad please? Check the WMS spec for ImplementsSpatialFilter, think this is a flag indicating spatial filters are available. The getcapabilities shows this set to false. How can I change this in geoserver? -- Jody Garnett On Mon, 10 Feb 2020 at 11:29, Brad Spencer <[email protected]<mailto:[email protected]>> wrote: Ok we are using postgis. Re the typename, we could look at renaming these layers as we are on development right now, however, how come the CQL filter using a BBOX spatial filter works? Also, have any thoughts about the Getcapabilities constraints settings? <fes:Constraint name="ImplementsSpatialFilter"> Sent from my iPhone On 10 Feb 2020, at 20:40, Jody Garnett <[email protected]<mailto:[email protected]>> wrote: The data source is internal to your configuration of geoserver (shapefile, postgis, geomesa, etc...). - I don't think you are doing something wrong, I am suspecting that the data source is not doing a good job of combining a within filter and an attribute filter. I can see something unusual, your time name may not be valid for WFS: - abs:2016meshblocks - XML Element names must start with a letter or underscore, and this one starts with "2" -- Jody Garnett On Mon, 10 Feb 2020 at 10:26, Brad Spencer <[email protected]<mailto:[email protected]>> wrote: See below.... Sent from my iPhone On 10 Feb 2020, at 20:11, Jody Garnett <[email protected]<mailto:[email protected]>> wrote: No worries, in this case it was me making the initial mistake :P As for this trouble with CQL, please keep in mind that once the filter is parsed for your request, it is then packaged up by the data source (for example translated to SQL for a database request). So we really need to know what data source you are using to have a better idea what is going on :) The other common thing is to make sure the coordinates in your request match the coordinates in your Did you try my URL links? Won’t the data source be specified in the full link that includes the CQL filter. Also be aware that one of these links shows a BBOX spatial filter in the CQL which works correctly. The BBOX filter’s geometry is used in the CQL Within filter to create a wkt Polygon that does not work. This makes no sense to me. I must be doing something wrong? brad... -- Jody Garnett On Mon, 10 Feb 2020 at 09:45, Brad Spencer <[email protected]<mailto:[email protected]>> wrote: Jody, Sorry about that I was not aware of these rules. Cheers, Brad…. From: Jody Garnett <[email protected]<mailto:[email protected]>> Sent: 10 February 2020 16:55 To: Brad Spencer <[email protected]<mailto:[email protected]>> Subject: Re: [Geoserver-users] Geoserver 2.11.2 Please keep our policy in mind about keeping communication on the list. I am sorry I accidentally replied to you directly (made a mistake using my phone). Many folks, including my employer, offer direct email support commercially. By keeping thing on the list, like how to figure out the logs, we help people doing a web search and participate in the community. On Mon, Feb 10, 2020 at 5:06 AM Brad Spencer <[email protected]<mailto:[email protected]>> wrote: Jody, I simply do not understand the Geoserver logs. They make no sense to me. Would it help if I just cut and pasted to you into an email? Cheers, Brad…. From: Jody Garnett <[email protected]<mailto:[email protected]>> Sent: 10 February 2020 12:23 To: Brad Spencer <[email protected]<mailto:[email protected]>> Cc: [email protected]<mailto:[email protected]> Subject: Re: [Geoserver-users] Geoserver 2.11.2 Can you increase the logging and check what query is being generated. What data store are you using? On Sun, Feb 9, 2020 at 11:48 PM Brad Spencer <[email protected]<mailto:[email protected]>> wrote: Guys, Can anyone please shed some light on this geoserver problem for me? Cheers, Brad…. From: Brad Spencer <[email protected]<mailto:[email protected]>> Sent: 06 February 2020 10:44 To: '[email protected]<mailto:[email protected]>' <[email protected]<mailto:[email protected]>> Subject: Geoserver 2.11.2 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.7434 -37.9707,144.7434 -37.6572,145.1608 -37.6572,145.1608 -37.9707,144.7434 -37.9707))) plus an attribute filter component persons_usually_resident > 400. This should return over 100 polygon features. I get zero features returned when I should get over 100 returned. http://13.55.5.169:8008/geoserver/abs/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.0&TYPENAME=2016MBmeshblocks&OUTPUTFORMAT=application/json&CQL_FILTER=Within(geometry,POLYGON((144.7434 -37.9707,144.7434 -37.6572,145.1608 -37.6572,145.1608 -37.9707,144.7434 -37.9707))) AND persons_usually_resident > 400 I have also trued URL encoded CQL_Filter: http://13.55.5.169:8008/geoserver/abs/wms?REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.0&TYPENAME=2016MBmeshblocks&OUTPUTFORMAT=application/json&CQL_FILTER=Within(geometry%2CPOLYGON((144.7434%20-37.9707%2C144.7434%20-37.6572%2C145.1608%20-37.6572%2C145.1608%20-37.9707%2C144.7434%20-37.9707)))%20AND%20component%20persons_usually_resident%20%3E%20400 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 features 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<http://13.55.5.169:8008/geoserver/abs/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.0&TYPENAME=2016MBmeshblocks&OUTPUTFORMAT=application/json&FILTER=%3cFilter%3e%3cAnd%3e%3cPropertyIsGreaterThan%3e%3cPropertyName%3epersons_usually_resident%3c/PropertyName%3e%3cLiteral%3e400%3c/Literal%3e%3c/PropertyIsGreaterThan%3e%3cWithin%3e%3cPropertyName%3egeometry%3c/PropertyName%3e%3cPolygon%3e%3couterBoundaryIs%3e%3cLinearRing%3e%3ccoordinates> 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 of 40 points or a user digitized arbitrary area. I can do this on a Cubewerx WFS service using OGC Filter 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. 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 but cannot understand why these requests are ignoring the spatial filters? Cheers, Brad Spencer Managing Director <image001.png> http://www.numaps.com.au/ mob: 0404 841 131 BradArt<https://www.facebook.com/pg/numaps.com.au/photos/?ref=page_internal> _______________________________________________ Geoserver-users mailing list Please make sure you read the following two resources before posting to this list: - Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/ - The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer [email protected]<mailto:[email protected]> https://lists.sourceforge.net/lists/listinfo/geoserver-users -- -- Jody Garnett -- -- Jody Garnett
_______________________________________________ Geoserver-users mailing list Please make sure you read the following two resources before posting to this list: - Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/ - The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer [email protected] https://lists.sourceforge.net/lists/listinfo/geoserver-users
