1

I am trying to utilize Geoserver's geometric filters to show subsets of a large number of polygons, but am getting inconsistent results.

I am testing CQL statements in the 'Edit Layer' page on Geoserver, and viewing my changes on an OpenLayers layer preview page.

For example, the filter:

BBOX(geom, -11500000, 6500000, -11900000, 7260359)

works completely as expected, yet the filters:

BBOX(geom,-11200000, 6100000,-11300000,6200000)
DISJOINT(geom, POLYGON((-11800000 6550000, -11800000 6850000, -11500000 6850000, -11500000 6550000, -11800000 6550000)))
INTERSECTS(geom, POLYGON((-11800000 6550000, -11800000 6850000, -11500000 6850000, -11500000 6550000, -11800000 6550000)))
DWITHIN(geom, POINT(-11800000 6550000),100000,meters)

produce zero output even though they should all hit some polygons.

Geoserver accepts the filters as syntactically correct, and no errors are evident on the page, so I'm really at a loss as to why these sometimes work and sometimes do not.

Output from log after trying:

DWITHIN(geom, POINT(-11800000 6550000), 100000,meters)

2016-08-31 12:42:39,991 TRACE [org.geotools.factory] - ENTRY (CRSAuthorityFactory, CRS_AUTHORITY_FACTORY) 2016-08-31 12:42:39,993 TRACE [org.geotools.factory] - CHECK (CRSAuthorityFactory, CRS_AUTHORITY_FACTORY): user provided a Class. 2016-08-31 12:42:39,993 TRACE [org.geotools.factory] - CHECK (CRSAuthorityFactory, CRS_AUTHORITY_FACTORY): consider hint[last] AbstractEpsgMediator. 2016-08-31 12:42:39,993 TRACE [org.geotools.factory] - THROW (CRSAuthorityFactory, CRS_AUTHORITY_FACTORY): could not find implementation. 2016-08-31 12:42:39,994 DEBUG [org.geotools.util] - InterpolationConverterFactory can be applied from Strings to Interpolation only. 2016-08-31 12:42:39,994 DEBUG [org.geotools.util] - CRSConverterFactory can be applied from Strings to CRS only. 2016-08-31 12:42:40,005 INFO [org.geoserver.gwc] - Saving GeoSeverTileLayer sksoil:polygon_filter_layer 2016-08-31 12:42:44,869 INFO [org.geoserver.wms] - Request: getServiceInfo 2016-08-31 12:42:44,869 DEBUG [org.geotools.util] - InterpolationConverterFactory can be applied from Strings to Interpolation only. 2016-08-31 12:42:44,869 DEBUG [org.geotools.util] - CRSConverterFactory can be applied from Strings to CRS only. 2016-08-31 12:42:44,870 DEBUG [org.geotools.util] - InterpolationConverterFactory can be applied from Strings to Interpolation only. 2016-08-31 12:42:44,870 DEBUG [org.geotools.util] - CRSConverterFactory can be applied from Strings to CRS only. 2016-08-31 12:42:44,870 DEBUG [org.geotools.styling] - number of fts set 1 2016-08-31 12:42:44,873 DEBUG [org.geotools.jdbc] - CREATE CONNECTION 2016-08-31 12:42:44,879 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION 2016-08-31 12:42:44,883 DEBUG [org.geotools.parameter] - Axis length mismatch. 2016-08-31 12:42:44,884 INFO [org.geoserver.wms] - Request: getMap Exceptions = SE_XML Palette = null Tiled = false SRS = EPSG:3857 FeatureVersion = null Styles = [StyleImpl[ name=style_css_polygon]] MaxFeatures = null Layers = [org.geoserver.wms.MapLayerInfo@8db4c08f] Crs = PROJCS["WGS 84 / Pseudo-Mercator", GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4326"]], PROJECTION["Popular Visualisation Pseudo Mercator", AUTHORITY["EPSG","1024"]], PARAMETER["semi_minor", 6378137.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["central_meridian", 0.0], PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","3857"]] FormatOptions = {} BgColor = java.awt.Color[r=255,g=255,b=255] Angle = 0.0 Elevation = [] Bbox = SRSEnvelope[-1.22457799832824E7 : -1.12836283302401E7, 6274575.95160879 : 7260359.37192455] ViewParams = null Transparent = false StartIndex = null StyleFormat = sld RemoteOwsType = null RemoteOwsURL = null SldBody = null ValidateSchema = false Sld = null StyleUrl = null CQLFilter = null FeatureId = null Interpolations = [] TilesOrigin = null Env = {} StyleBody = null SldVersion = null StyleVersion = null ScaleMethod = null Width = 749 Height = 768 Filter = null Time = [] Buffer = 0 Format = application/openlayers Filters = null RawKvp = {REQUEST=GetMap, SRS=EPSG:3857, FORMAT=application/openlayers, BBOX=-1.22457799832824E7,6274575.95160879,-1.12836283302401E7,7260359.37192455, VERSION=1.1.0, STYLES=, SERVICE=WMS, WIDTH=749, HEIGHT=768, LAYERS=sksoil:polygon_filter_layer} RequestCharset = UTF-8 Get = true BaseUrl = Version = 1.1.0 Request = GetMap 2016-08-31 12:42:45,895 INFO [org.geoserver.wms] - Request: getServiceInfo 2016-08-31 12:42:45,896 DEBUG [org.geotools.util] - InterpolationConverterFactory can be applied from Strings to Interpolation only. 2016-08-31 12:42:45,896 DEBUG [org.geotools.util] - CRSConverterFactory can be applied from Strings to CRS only. 2016-08-31 12:42:45,896 DEBUG [org.geotools.util] - InterpolationConverterFactory can be applied from Strings to Interpolation only. 2016-08-31 12:42:45,896 DEBUG [org.geotools.util] - CRSConverterFactory can be applied from Strings to CRS only.

... followed by about 400 lines of "CRSConverterFactory can be applied from Strings to CRS only", then:

2016-08-31 12:42:45,918 DEBUG [org.geotools.rendering] - Processing 1 stylers for http://sksoil.usask.ca:polygon_filter_layer 2016-08-31 12:42:45,918 DEBUG [org.geotools.rendering] - Expanding rendering area by 2 pixels to consider stroke width 2016-08-31 12:42:45,919 DEBUG [org.geotools.rendering] - Querying layer http://sksoil.usask.ca:polygon_filter_layer with bbox: ReferencedEnvelope[-1.2684108984285446E7 : -1.0844357212622067E7, 5824706.604963378 : 7710880.386819345] 2016-08-31 12:42:45,920 DEBUG [org.geotools.jdbc] - CREATE CONNECTION 2016-08-31 12:42:45,920 DEBUG [org.geotools.filter] - exporting LogicFilter 2016-08-31 12:42:45,920 DEBUG [org.geotools.filter] - exporting PropertyName 2016-08-31 12:42:45,920 DEBUG [org.geotools.filter] - exporting LiteralExpression 2016-08-31 12:42:45,920 DEBUG [org.geotools.util] - InterpolationConverterFactory can be applied from Strings to Interpolation only. 2016-08-31 12:42:45,920 DEBUG [org.geotools.util] - CRSConverterFactory can be applied from Strings to CRS only. 2016-08-31 12:42:45,921 DEBUG [org.geotools.filter] - exporting PropertyName 2016-08-31 12:42:45,921 DEBUG [org.geotools.filter] - exporting LiteralExpression 2016-08-31 12:42:45,921 DEBUG [org.geotools.util] - InterpolationConverterFactory can be applied from Strings to Interpolation only. 2016-08-31 12:42:45,921 DEBUG [org.geotools.util] - CRSConverterFactory can be applied from Strings to CRS only. 2016-08-31 12:42:45,921 DEBUG [org.geotools.jdbc] - SELECT "skv3_prt_mapunit",encode(ST_AsBinary(CASE WHEN ST_HasArc("geom") THEN "geom" ELSE ST_Simplify(ST_Force2D("geom"), 1951.9912696689369, true) END),'base64') as "geom" FROM (SELECT dss_v3_sk.poly_id, dss_v3_sk.geom, dss_v3_sk.hectares, dss_v3_sk_prt.text1, dss_v3_sk_prt.text2, dss_v3_sk_prt.phsym, dss_v3_sk_prt.pasteros, dss_v3_sk_prt.capblty, dss_v3_sk_prt.stone, dss_v3_sk_prt.zone, dss_v3_sk_prt.deeptill, dss_v3_sk_prt.stsym, dss_v3_sk_prt.sdgr, substr(dss_v3_sk_prt.mapunit::text, 1, 2) AS skv3_prt_mapunit, dss_v3_sk_prt.mapumod, dss_v3_sk_prt.slope_rg, dss_v3_sk_prt.surfex, dss_v3_sk_prt.slpl, dss_v3_sk_prt.irrig, dss_v3_sk_prt.water, dss_v3_sk_prt.wind, dss_v3_sk_prt.salsym FROM public.dss_v3_sk_prt, public.dss_v3_sk WHERE dss_v3_sk_prt.poly_id = dss_v3_sk.poly_id ) as "vtable" WHERE (ST_DWithin("geom",ST_GeomFromText('POINT (-11800000 6550000)', -1),100000.0) AND "geom" && ST_GeomFromText('POLYGON ((-12684108.984285446 5824706.604963378, -12684108.984285446 7710880.386819345, -10844357.212622067 7710880.386819345, -10844357.212622067 5824706.604963378, -12684108.984285446 5824706.604963378))', -1)) 2016-08-31 12:42:45,928 ERROR [org.geotools.jdbc] - Failed to execute statement SELECT "skv3_prt_mapunit",encode(ST_AsBinary(CASE WHEN ST_HasArc("geom") THEN "geom" ELSE ST_Simplify(ST_Force2D("geom"), 1951.9912696689369, true) END),'base64') as "geom" FROM (SELECT dss_v3_sk.poly_id, dss_v3_sk.geom, dss_v3_sk.hectares, dss_v3_sk_prt.text1, dss_v3_sk_prt.text2, dss_v3_sk_prt.phsym, dss_v3_sk_prt.pasteros, dss_v3_sk_prt.capblty, dss_v3_sk_prt.stone, dss_v3_sk_prt.zone, dss_v3_sk_prt.deeptill, dss_v3_sk_prt.stsym, dss_v3_sk_prt.sdgr, substr(dss_v3_sk_prt.mapunit::text, 1, 2) AS skv3_prt_mapunit, dss_v3_sk_prt.mapumod, dss_v3_sk_prt.slope_rg, dss_v3_sk_prt.surfex, dss_v3_sk_prt.slpl, dss_v3_sk_prt.irrig, dss_v3_sk_prt.water, dss_v3_sk_prt.wind, dss_v3_sk_prt.salsym FROM public.dss_v3_sk_prt, public.dss_v3_sk WHERE dss_v3_sk_prt.poly_id = dss_v3_sk.poly_id ) as "vtable" WHERE (ST_DWithin("geom",ST_GeomFromText('POINT (-11800000 6550000)', -1),100000.0) AND "geom" && ST_GeomFromText('POLYGON ((-12684108.984285446 5824706.604963378, -12684108.984285446 7710880.386819345, -10844357.212622067 7710880.386819345, -10844357.212622067 5824706.604963378, -12684108.984285446 5824706.604963378))', -1))

3
  • 1
    Turn up the logging level to GeoTools developer and add the output to the question
    – Ian Turton
    Commented Aug 31, 2016 at 18:49
  • does your geom column have a srid?
    – Ian Turton
    Commented Sep 1, 2016 at 7:53
  • Yes, the SRID is 3857 Commented Sep 2, 2016 at 15:51

2 Answers 2

1

Looks like you are using a "sql view" (otherwise the vtable construct would not be there). Did you correctly configure the srid in the geometry column of the sql view?

1

The problem was that my SRS handling setting (in Edit Layer) on GeoServer was set to 'Force declared'. And it did not get declared in my query, so GeoServer defaulted to -1, and tried to mix that with an SRID of 3857, resulting in the error about "mixed SRID geometries".

In any case, by changing the SRS handling setting to 'Keep native', the problem is avoided, and CQL queries work fine.

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.