[PostGIS] #5777: st_intersects() throws exception when using geometrycollection as first argument

PostGIS trac at osgeo.org
Tue Sep 3 05:37:25 PDT 2024


#5777: st_intersects() throws exception when using geometrycollection as first
argument
-------------------------+-------------------------------------------------
  Reporter:  cfischer    |      Owner:  pramsey
      Type:  defect      |     Status:  new
  Priority:  medium      |  Milestone:  PostGIS 3.4.3
 Component:  postgis     |    Version:  3.4.x
Resolution:              |   Keywords:  relate st_intersects
                         |  TopologyException
-------------------------+-------------------------------------------------
Description changed by cfischer:

Old description:

> 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
> }}}

New description:

 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)"
 }}}

--
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5777#comment:1>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list