I got this very useful reply (below) from Andrea Aime recently on this issue: However, I would also say if the layer is projected it should be declared as such in the layer definition. Geoserver automatically projects to requested srs on request. ____________________________________
Hi Phil, ECQL has been supporting expression of filters in whatever CRS since late 2017, you can specify the geometry in EWKT, for example: INTERSECTS(the_geom, SRID=4326;POINT (1 2)) See also: https://docs.geotools.org/latest/userguide/library/cql/ecql.html I've updated the GeoServer reference docs to include a mention of that too, still in the build pipe, should show up in a few hours here, in the geometry literal syntax entry: https://docs.geoserver.org/latest/en/user/filter/ecql_reference.html#literal Cheers Andrea From: Cliff Patterson <[email protected]> Sent: Friday, 21 February 2020 03:22 To: [email protected] Subject: [Geoserver-users] CQL Spatial functions use native SRS not declared with Postgis layers I have a PG/PostGIS database containing layers in EPSG:26917 (UTM) and EPSG:4326. All layers are loaded into Geoserver and the declared SRS is 4326. For the layers in EPSG:26917 I reproject native to declared so all layers are in 4326 (Geoserver version: 2.15.1). I have a web application that loads the layers and I plan to use CQL filters to perform a range of functions, such as bbox selections. However, it seems that spatial CQL functions use the native SRS not the declared SRS. This presents a problem because before I can run any spatial filters, I have to first check the native SRS, then either use the imputed coordinates/measurements or transform them to the native SRS. Example: If the layer is natively in a projected coordinate system (e.g. EPSG:26917), then the CQL filter must use the projected coordinates, even if the declared SRS is EPSG:4326. So the following needs to be used, where the coordinates are UTM and the buffer distance is in meters. CQL_FILTER: "intersects(geom,BUFFER(POINT(335676.336 4684972.893),5000))" For a layer that is in EPSG:4326 natively in PG/PostGIS, the following needs to be used. CQL_FILTER:"intersects(geom,BUFFER(POINT(-83.03253 42.31526),0.0020))" Questions: 1) Is there any way in a CQL filter to use UTM coordinates and meters on layers that are in EPSG:4326 in the database? Perhaps a transform function, like in PostGIS? 2) Is there any ways to always query the layer in EPSG:4326? 3) Is this by design, or a limitation of Geoserver? Bonus question! 4) Is there a way to use lat/long coordinates and meters as buffer distance? Thanks! Cliff -- Cliff Patterson Ph.D. PSD | Senior GIS Consultant P: 519-690-2565 ext. 2616 www.psdrcs.com<http://www.psdrcs.com> London | 148 Fullarton St. 9th Floor [Image removed by sender.] Notice: This email and any attachments are confidential and may not be used, published or redistributed without the prior written consent of the Institute of Geological and Nuclear Sciences Limited (GNS Science). If received in error please destroy and immediately notify GNS Science. Do not copy or disclose the contents.
_______________________________________________ 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
