[Geoserver-users] Problem with GetMap request with an ogc:Filter with only Polygon geometry

Hello ,

We noticed a problem with an ogc:filter getMap request. ( GeoServer 2.24.2 )

It is only if you have a Within Filter without another extra filter option.

So what is wrong:

FILTER=

<ogc:Filter xmlns:gml=http://www.opengis.net/gml xmlns:ogc=http://www.opengis.net/ogc>ogc:Withinogc:PropertyNamegeom</ogc:PropertyName><gml:Polygon srsName=http://www.opengis.net/def/crs/EPSG/0/28992>gml:exteriorgml:LinearRinggml:posList154852 464024 155048 463679 155303 463736 155082 464086 154852 464024</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></ogc:Within></ogc:Filter>

https://workshop.kaartviewer.nl/geoserver/wms?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&FORMAT=image%2Fpng&STYLES=&TRANSPARENT=true&LAYERS=geonovation%3Aenergielabels_amersfoort&&WIDTH=2133&HEIGHT=1103&CRS=EPSG%3A28992&BBOX=154103.54602300984%2C463421.92378041224%2C156015.80503340586%2C464410.9202373514&FILTER=%3Cogc:Filter%20xmlns:gml=%22http://www.opengis.net/gml%22%20xmlns:ogc=%22http://www.opengis.net/ogc%22%3E%3Cogc:Within%3E%3Cogc:PropertyName%3Egeom%3C/ogc:PropertyName%3E%3Cgml:Polygon%20srsName=%22http://www.opengis.net/def/crs/EPSG/0/28992%22%3E%3Cgml:exterior%3E%3Cgml:LinearRing%3E%3Cgml:posList%3E154852%20464024%20155048%20463679%20155303%20463736%20155082%20464086%20154852%20464024%3C/gml:posList%3E%3C/gml:LinearRing%3E%3C/gml:exterior%3E%3C/gml:Polygon%3E%3C/ogc:Within%3E%3C/ogc:Filter%3E

This url gives an error in geoserver ( Rendering process failed. Layers: geonovation:energielabels_amersfoort → Caused by: java.lang.NullPointerException at org.geotools.filter.spatial.ReprojectingFilterVisitor$GeometryFilterTransformer.transform(ReprojectingFilterVisitor.java:437)

But when I have the following URL, with added on ogc:And and a random extra filter ( in this case 0>=0), then it is working OK!

Filter=

<ogc:Filter xmlns:gml=http://www.opengis.net/gml xmlns:ogc=http://www.opengis.net/ogc>ogc:Andogc:Withinogc:PropertyNamegeom</ogc:PropertyName>gml:Polygongml:exteriorgml:LinearRinggml:posList154852.87672948933 464024.4568953283 155048.54203767146 463679.5184417369 155303.4218767874 463736.1500901585 155082.0111295965 464086.23693005764 154852.87672948933 464024.4568953283</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></ogc:Within>ogc:PropertyIsGreaterThanOrEqualToogc:Literal0</ogc:Literal>ogc:Literal0</ogc:Literal></ogc:PropertyIsGreaterThanOrEqualTo></ogc:And></ogc:Filter>

https://workshop.kaartviewer.nl/geoserver/wms?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&FORMAT=image%2Fpng&STYLES=&TRANSPARENT=true&LAYERS=geonovation%3Aenergielabels_amersfoort&&WIDTH=2133&HEIGHT=1103&CRS=EPSG%3A28992&BBOX=154103.54602300984%2C463421.92378041224%2C156015.80503340586%2C464410.9202373514&FILTER=%3Cogc:Filter%20xmlns:gml=%22http://www.opengis.net/gml%22%20xmlns:ogc=%22http://www.opengis.net/ogc%22%3E%3Cogc:And%3E%3Cogc:Within%3E%3Cogc:PropertyName%3Egeom%3C/ogc:PropertyName%3E%3Cgml:Polygon%3E%3Cgml:exterior%3E%3Cgml:LinearRing%3E%3Cgml:posList%3E154852.87672948933%20464024.4568953283%20155048.54203767146%20463679.5184417369%20155303.4218767874%20463736.1500901585%20155082.0111295965%20464086.23693005764%20154852.87672948933%20464024.4568953283%3C/gml:posList%3E%3C/gml:LinearRing%3E%3C/gml:exterior%3E%3C/gml:Polygon%3E%3C/ogc:Within%3E%3Cogc:PropertyIsGreaterThanOrEqualTo%3E%3Cogc:Literal%3E0%3C/ogc:Literal%3E%3Cogc:Literal%3E0%3C/ogc:Literal%3E%3C/ogc:PropertyIsGreaterThanOrEqualTo%3E%3C/ogc:And%3E%3C/ogc:Filter%3E

What could be the problem here?

Peter-Paul Koonings

GeoNovation B.V.

Looking at

if (!(filter.getExpression1() instanceof PropertyName)) {
throw new IllegalArgumentException(
"Binary geometry filter, but first expression "

  • "is not a property name? (it’s a "
  • filter.getExpression1().getClass()
  • “)”);
    }

The null pointer exception is from filter.getExpression1() return null.

  • The check should be changed to check for null - and indicate the first expression is missing

So the error message is not helpful, but you did say you are missing a filter option :slightly_smiling_face:

If you are comfortable making the change I encourage you to make a pull-request (it seems straightforward to provide a better error message).

···


Jody Garnett