Opened 3 weeks ago

Closed 11 days ago

#5777 closed defect (fixed)

st_intersects() throws exception when using geometrycollection as first argument

Reported by: cfischer Owned by: pramsey
Priority: medium Milestone: PostGIS GEOS
Component: postgis Version: 3.4.x
Keywords: relate st_intersects TopologyException Cc: cfischer

Description (last modified by cfischer)

PostGIS throws an exception with st_intersects on geometry collection as first parameter

SQL Error [XX000]: ERROR: GEOSIntersects: TopologyException: side location conflict at 725217.59322033904 6176386.5423728814. This can occur if the input geometry is invalid.

A have isolated the problem, shown below. The order of the arguments to st_intersects appears to be signifikant.

  • geom_1 : is a point
  • geom_2 : is a geometrycollection, containing two triangles
  • geom_3 : is a multipolygon-version of geom_2
  • st_intersects (geom_1, geom_2) → SUCCESS
  • st_intersects (geom_2, geom_1) → FAILS
  • st_intersects (geom_1, geom_3) → SUCCESS
  • st_intersects (geom_3, geom_1) → SUCCESS
WITH geom_1 AS (
  SELECT st_point(725220, 6176385, 25832) AS geom
),
geom_2 AS (
  SELECT
    st_geometryfromtext(
      'GEOMETRYCOLLECTION (
        POLYGON ((725210 6176386, 725220 6176382, 725224 6176387, 725210 6176386)),
        POLYGON ((725215 6176390, 725218 6176386, 725225 6176385, 725215 6176390))
      )'
    , 25832) AS geom
),
geom_3 AS (
  SELECT
    st_geometryfromtext(
      'MULTIPOLYGON (
                ((725210 6176386, 725220 6176382, 725224 6176387, 725210 6176386)),
                ((725215 6176390, 725218 6176386, 725225 6176385, 725215 6176390))
      )'
    , 25832) AS geom
)
SELECT
  *
FROM
  geom_1
  JOIN geom_2 ON (st_intersects(geom_2.geom, geom_1.geom)) -- fails
--  JOIN geom_2 ON (st_intersects(geom_1.geom, geom_2.geom)) -- works
--  JOIN geom_3 ON (st_intersects(geom_1.geom, geom_3.geom)) -- works
--  JOIN geom_3 ON (st_intersects(geom_3.geom, geom_1.geom)) -- works
SELECT postgis_full_version();

POSTGIS="3.4.0 0874ea3" [EXTENSION] PGSQL="160" GEOS="3.12.0-CAPI-1.18.0" PROJ="8.0.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/rdsdbbin/postgres-16.1.R2/share/proj/proj.db" LIBXML="2.9.1" LIBJSON="0.15" LIBPROTOBUF="1.3.2" WAGYU="0.5.0 (Internal)"

Change History (6)

comment:1 by cfischer, 3 weeks ago

Description: modified (diff)

comment:2 by pramsey, 3 weeks ago

Milestone: PostGIS 3.4.3PostGIS 3.4.4

comment:3 by pramsey, 2 weeks ago

Milestone: PostGIS 3.4.4PostGIS GEOS

This exists in GEOS 3.12, but not in GEOS 3.13.

geosop \
-a "GEOMETRYCOLLECTION (POLYGON ((725210 6176386, 725220 6176382, 725224 6176387, 725210 6176386)), POLYGON ((725215 6176390, 725218 6176386, 725225 6176385, 725215 6176390)))" \
-b "POINT(725220 6176385)" \
intersects

The fix will end up being upgrading GEOS.

in reply to:  3 ; comment:4 by robe, 2 weeks ago

Replying to pramsey:

This exists in GEOS 3.12, but not in GEOS 3.13.

geosop \
-a "GEOMETRYCOLLECTION (POLYGON ((725210 6176386, 725220 6176382, 725224 6176387, 725210 6176386)), POLYGON ((725215 6176390, 725218 6176386, 725225 6176385, 725215 6176390)))" \
-b "POINT(725220 6176385)" \
intersects

The fix will end up being upgrading GEOS.

You mean the other way around I hope — exists in GEOS 3.13 and not in 3.12 and below

Now that GEOS 3.13 is released, is there a reason to keep this ticket open?

in reply to:  4 comment:5 by mdavis, 13 days ago

Replying to robe:

Replying to pramsey:

This exists in GEOS 3.12, but not in GEOS 3.13.

You mean the other way around I hope — exists in GEOS 3.13 and not in 3.12 and below

He means that the problem exists in GEOS 3.12 but not in 3.13.

Now that GEOS 3.13 is released, is there a reason to keep this ticket open?

Probably not.

comment:6 by robe, 11 days ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.