Opened 2 months ago

Last modified 2 months ago

#5777 new defect

st_intersects() throws exception when using geometrycollection as first argument — at Version 1

Reported by: cfischer Owned by: pramsey
Priority: medium Milestone: PostGIS 3.4.4
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 (1)

comment:1 by cfischer, 2 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.