I've scripted my own wps for GeoServer using the GeoScript Groovy API. I can make a request from inside GeoServer and the process runs smoothly. I'm now trying to use the process as a rendering transformation but am having trouble.

The GeoServer log says:

Caused by: java.sql.SQLException: org.postgresql.util.PSQLException: ERROR: parse error - invalid geometry Hint: "POLYGON ((-?" <-- parse error at position 12 within geometry

After doing some digging through the GeoServer docs, I found a section on query rewriting which mentions that this might be necessary for "controlling query optimizations (for instance, ensuring that geometry decimation does not prevent point features from being read)". However, there is no example on how to do this.

I looked in the geotools heatmap code and found an invertQuery method, but this is only my second time writing code and I don't understand what it's doing or how it's used. I tried putting the following in my script but it didn't help.

public Query invertQuery(

        Query targetQuery, GridGeometry targetGridGeometry) throws ProcessException {


    Hints hints = targetQuery.getHints()
    hints.put(Hints.GEOMETRY_DISTANCE, 0.0)

    return targetQuery

So, what the heck is geometry decimation? and how can I amend the above code to avoid the invalid geometry error?

The geometry is in PostGIS if that helps


When using the GEOTOOLS_DEVELOPER_LOGGING properties I find the following request:

SELECT "id","name","species","bto_code","mass","incubation_days","rearing_days","ad_inc_dist","fid_inc_dist","ad_rer_dist","fid_rer_dist","buff_inc_dist","buff_rer_dist","date_start","date_end","live_dist","conservation_score","legal_dist",encode(ST_AsEWKB("the_geom"),'base64') as "the_geom" FROM "birds_other"."birds_tst_view" WHERE "the_geom" && ST_GeomFromText('POLYGON ((-? -?, -? ?, ? ?, ? -?, -? -?))', 27700)

So it does indeed look like a bad query as I'm styling a points layer. How do I fix this? The query is automatically generated, so it's not obvious to me.

  • 1
    Can you print out the Polygon geometry that the error is referring to? It looks like it has a question mark instead of a number for one of the coordinates.
    – jonnyhuck
    Commented Jul 1, 2017 at 8:53
  • Thanks @jonnyhuck probably should have mentioned that I'm calling this on a points layer. I think the underlying geometry is fine as the script runs fine as a wps called on the same points layer Commented Jul 1, 2017 at 9:04
  • 1
    I don't think decimation is your issue, it looks more like a badly formed query - turn logging up to geotools dev and see if it prints the whole query for you.
    – Ian Turton
    Commented Jul 1, 2017 at 11:00

2 Answers 2


Geometry Decimation is the process of removing vertices that would be drawn on the same pixel when rendered. It uses the JTS decimator class.

The name comes from the Roman punishment of executing one in ten legionnaires.

  • Thanks for the information @iant. If you could help me solve my invalid geometry problem too I'll gladly mark this as my answer Commented Jul 1, 2017 at 12:36

Cracked it. I was using the geoscript.layer class as an input. As soon as I changed it to a GeoTools SimpleFeatureCollection it works 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.