1

When doing a WFS Get Feature request, I am using the cql_filter option to do some more advanced spatial filtering/quering. I am looking for the centroids of the polygons in a database that intersect with a polygon that I specify.

However, when I try to do the following query: "INTERSECTS ( centroid( geom ), POLYGON(SomePoly) )

I get the following error:

<ows:ExceptionText xmlns:ows="http://www.opengis.net/ows/1.1">java.lang.IllegalArgumentException: Binary geometry filter, but first expression is not a property name? (it&amp;apos;s a class org.geotools.filter.function.FilterFunction_centroid)

Binary geometry filter, but first expression is not a property name? (it&apos;s a class org.geotools.filter.function.FilterFunction_centroid)

Does anyone know the correct way of formatting such queries?

1

It's happening because by OGC Filter specification the first element of an intersects filter must be a property name.

Now, that said, GeoServer should be able to deal with an expression as the first argument internally, it's just that there is one class in GeoServer that's still enforcing the the above limitation while processing the request. You can open a bug report on that.

Mind though, even with that fixed, the evaluation will happen in memory, the evaluation of the centroid function won't be sent down to the database, unless a second improvement in made in the SQL encoder (and the database in question actually supports centroid extraction).

  • "geoservertable:geom" was meant as an example refering to the geometry attribute of a table. I edited the question to make it more clear. Adding to this: the query works whenever I do not use the centroid() function. – S Hook Jun 13 '16 at 8:50
  • Updated my response based on your feedback and some tests I've made – Andrea Aime Jun 13 '16 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.