[Geoserver-users] How to use Geometry intersection correctly in GeoServer SLD?

I need to place my piechart on Geoserver WMS SLD as for my multipolygon layer (PostGIS table). But rather than using centroid of each row as placement, I need to use centroid of [intersection [my polygon geom, wms_bbox] ]. Hence the piechart shall be placed on centroid of appearing part of polygon.

My old question (https://gis.stackexchange.com/a/273534/18383) asked about this and I got a brilliant answer saying that I have to use instead of . The answer even suggests a element in SLD to achieve what I want. It works!

Below is the proof (using US States map included in Geoserver as SHP).

PANNING_US_STATE.png

The problem is, it works when I tried it with US States map (included in Geoserver as SHP).

But it does not work with:

  1. US States PostGIS table (imported from the SHP included in Geoserver), even all rows are valid geometry
  2. My multipolygon PostGIS table (all rows are valid geometry as well)
  3. My SHP exported from my above multipolygon PostGIS table

The error with my multipolygon PostGIS table is as follows
code="internalError"Rendering process failed side location conflict [(136.81917785227373, -4.9082450034714, NaN) ]

The error with US States PostGIS table is slightly different:
code="internalError"Rendering process failed found non-noded
intersection between LINESTRING ( -76.446869 37.457966, -76.461136 37.255432 ) and LINESTRING ( -76.704681 37.418491, -76.337318 37.177009999999996 ) [ (-76.46093617561398, 37.25826870233377, NaN) ]

So to nail down the problem I tried to dig into the log of GeoServer and PostgreSQL. First I set GeoServer log to VERBOSE_LOGGING and set PostgreSQL log_statement = ‘all’.

Then I re-create the thing in GeoServer layer preview and got the above error message. Then I check PostgreSQL log to find what did GeoServer query to Postgres. Interestingly if I run the logged query, there’s no error at all in PostGIS, smooth. But GeoServer log got error on that point.

So conclusion so far:

  1. there’s error in GeoServer rendering engine while getting normal/valid response from PostGIS
  2. SHP has better success rate than PostGIS table (proven by using the same US State map as explained above).
    Now the question: how to fix this? Did i miss something?

My playing ground:

  • GeoServer 2.14.3 (with chart extension)
  • Apache Tomcat 8.5.32 Server
  • Windows 10 Pro 64-bit on Xeon E5-1660 3GHz, 32GB memory
  • PostgreSQL 9.6.11, PostGIS 2.5

That is interesting, can you try changing your PostGIS connection parameter settings and uncheck “Support on the fly geometry simplification” ? Perhaps the simplification is dynamically producing an invalid geometry which is failing to intersect?

···


Jody Garnett

Having a look at the docs I did not see information about the parameter I was asking you to change.

Pull request updating the docs is here (page is here) if you would like to provide your feedback (and the page


Jody Garnett

On Mon, 3 Jun 2019 at 10:27, Jody Garnett <jody.garnett@anonymised.com> wrote:

That is interesting, can you try changing your PostGIS connection parameter settings and uncheck “Support on the fly geometry simplification” ? Perhaps the simplification is dynamically producing an invalid geometry which is failing to intersect?


Jody Garnett

On Fri, 31 May 2019 at 01:24, Riga n <riga0078@anonymised.com> wrote:

I need to place my piechart on Geoserver WMS SLD as for my multipolygon layer (PostGIS table). But rather than using centroid of each row as placement, I need to use centroid of [intersection [my polygon geom, wms_bbox] ]. Hence the piechart shall be placed on centroid of appearing part of polygon.

My old question (https://gis.stackexchange.com/a/273534/18383) asked about this and I got a brilliant answer saying that I have to use instead of . The answer even suggests a element in SLD to achieve what I want. It works!

Below is the proof (using US States map included in Geoserver as SHP).

The problem is, it works when I tried it with US States map (included in Geoserver as SHP).

But it does not work with:

  1. US States PostGIS table (imported from the SHP included in Geoserver), even all rows are valid geometry
  2. My multipolygon PostGIS table (all rows are valid geometry as well)
  3. My SHP exported from my above multipolygon PostGIS table

The error with my multipolygon PostGIS table is as follows
code="internalError"Rendering process failed side location conflict [(136.81917785227373, -4.9082450034714, NaN) ]

The error with US States PostGIS table is slightly different:
code="internalError"Rendering process failed found non-noded
intersection between LINESTRING ( -76.446869 37.457966, -76.461136 37.255432 ) and LINESTRING ( -76.704681 37.418491, -76.337318 37.177009999999996 ) [ (-76.46093617561398, 37.25826870233377, NaN) ]

So to nail down the problem I tried to dig into the log of GeoServer and PostgreSQL. First I set GeoServer log to VERBOSE_LOGGING and set PostgreSQL log_statement = ‘all’.

Then I re-create the thing in GeoServer layer preview and got the above error message. Then I check PostgreSQL log to find what did GeoServer query to Postgres. Interestingly if I run the logged query, there’s no error at all in PostGIS, smooth. But GeoServer log got error on that point.

So conclusion so far:

  1. there’s error in GeoServer rendering engine while getting normal/valid response from PostGIS
  2. SHP has better success rate than PostGIS table (proven by using the same US State map as explained above).
    Now the question: how to fix this? Did i miss something?

My playing ground:

  • GeoServer 2.14.3 (with chart extension)
  • Apache Tomcat 8.5.32 Server
  • Windows 10 Pro 64-bit on Xeon E5-1660 3GHz, 32GB memory
  • PostgreSQL 9.6.11, PostGIS 2.5

Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

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

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Jody,
I tried your suggestion anyway. I made a new store connecting to the exactly
the same PostgreSQL schema, but now with "Support on the fly geometry
simplification" unchecked. I left my first store (used in my question)
unchanged.
Then I published the 2 table (US_States and my own table) under the new
store.

With these 2 new layers, the piechart SLD works! I mean the SLD with
intersection between geometry columnd and WMS_BBOX in its <Geometry> SLD
element. The piechart shown as expected (placed on centroid of the appearing
part of polygon).

This was a quick try. I am sure that Geoserver sends different query to
PostgreSQL on the 2 stores (with different option on "Support on the fly
geometry simplification"), but I haven't check to that extent.

I shall post again with more observation on this.

--
Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html