10

I'm receiving the following error on a query:

ERROR: GEOSIntersects: TopologyException: side location conflict at -121.12159399072365 36.206327556592377

I've tried running ST_isValidReason() as suggested in the accepted answer on a related question here but all of the geometry fields are returned as valid. I don't have any null geometry either.

How else can I troubleshoot what may be causing this error?

2 Answers 2

9

I found a solution that worked for me. The error was occurring as a result of a ST_Intersects(a.geom, b.geom) in the query as mentioned here. Using ST_makeValid() on the new geometry ST_Intersects(a.geom, ST_makeValid(b.geom)) resolved the issue.

1
  • 2
    To avoid a long wait, don't forget to create an index that includes st_makevalid(geom): create index index_name on table_name using gist(st_makevalid(geom));
    – vinh
    May 28, 2021 at 11:09
1

I encountered this very case today when sending an intersection query to GeoServer 2.18.0 (backed by a PostgreSQL / PostGIS). The query in full was:

<?xml version="1.0"?>
<GetFeature xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="1.1.0" outputFormat="application/json" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
  <Query xmlns:coredb="https://geoserver.iacs.lab.synelixis.com/" typeName="coredb:spatial_ilot" srsName="EPSG:3857">
    <Filter xmlns="http://www.opengis.net/ogc">
      <Intersects>
        <PropertyName>geom</PropertyName>
        <MultiPolygon xmlns="http://www.opengis.net/gml" srsName="EPSG:3857">
          <polygonMember>
            <Polygon srsName="EPSG:3857">
              <exterior>
                <LinearRing srsName="EPSG:3857">
                  <posList srsDimension="2">2411669.2262 4893602.4466 2410817.4378 4893425.9063 2411573.8372160397 4893967.673796828 2411669.2262 4893602.4466</posList>
                </LinearRing>
              </exterior>
              <interior>
                <LinearRing srsName="EPSG:3857">
                  <posList srsDimension="2">2411267.2692 4893722.3491 2411084.23 4893542.9344 2411468.4311 4893597.3026 2411267.2692 4893722.3491</posList>
                </LinearRing>
              </interior>
              <interior>
                <LinearRing srsName="EPSG:3857">
                  <posList srsDimension="2">2411460.719925169 4893841.935569927 2411386.76716229 4893781.973765118 2411518.682945001 4893757.989150548 2411460.719925169 4893841.935569927</posList>
                </LinearRing>
              </interior>
              <interior>
                <LinearRing srsName="EPSG:3857">
                  <posList srsDimension="2">2411646.7059705583 4893688.672492439 2411578.332479239 4893583.608112964 2411669.064977344 4893602.413185251 2411646.7059705583 4893688.672492439</posList>
                </LinearRing>
              </interior>
            </Polygon>
          </polygonMember>
        </MultiPolygon>
      </Intersects>
    </Filter>
  </Query>
</GetFeature>

The error response was:

<?xml version="1.0" encoding="UTF-8"?><ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows http://geoserver.iacs.lab.synelixis.com/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd">
<ows:Exception exceptionCode="NoApplicableCode">
    <ows:ExceptionText>java.lang.RuntimeException: java.io.IOException
    java.io.IOExceptionERROR: GEOSIntersects: TopologyException: side location conflict at 300957.09788959642 4451171.1388148665</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>

My assumption is that this was due to the MultiPolygon (Polygon, really) in question having a hole that ran, for some distance, along the side of the exterior ring. This is how the above polygon looks in qgis:

enter image description here

The polygon has three holes, two of them innocuous, the offending one is easy to see. I have verified that such geometries cause problems when doing an intersect query against GeoServer 2.18.0 / PostGIS but I don't know how to detect that on the client side (I'm using Javascript and JSTS) or how to fix it automatically (or even whether it is a good idea to fix such issues automatically).

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.