Opened 5 months ago

Last modified 4 months ago

#5672 new defect

Function ST_3DIntersects does not work for MULTILINESTRING and LINESTRING.

Reported by: Wenjing Owned by: pramsey
Priority: medium Milestone:
Component: postgis Version: 3.4.x
Keywords: Cc:

Description

For the following query:

SELECT ST_3DIntersects(b1, b2)
    FROM ST_GeomFromText('MULTILINESTRING Z ((1 0 0, 0 0 0))')
    As b1,
    ST_GeomFromText('LINESTRING Z (1 0 0, 0 0 0)')
    As b2;
-- actual{f}; expected{t}

Geometry b1 and b2 have the intersection of all points on the line LINESTRING Z (1 0 0, 0 0 0), but Postgis doesn't consider they intersect each other.

version:

POSTGIS="3.5.0dev 3.4.0rc1-705-g5c3ec8392" [EXTENSION] PGSQL="170" GEOS="3.13.0dev-CAPI-1.18.0" PROJ="8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org/
USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.13" PostgreSQL 17devel on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-
1ubuntu1~22.04) 11.4.0, 64-bit

Change History (2)

comment:1 by Wenjing, 4 months ago

Paul, did you have a chance to look at this one? It is very strange. @pramsey

The test cases with two same lines only containing two points trigger this kind of issue.

Replacing MULTILINESTRING with LINESTRING triggers it as well.

SELECT ST_3DIntersects(b1, b2)
    FROM ST_GeomFromText('LINESTRING Z (1 0 0, 0 0 0)')
    As b1,
    ST_GeomFromText('LINESTRING Z (1 0 0, 0 0 0)')
    As b2;
-- actual{f}; expected{t}

However, reordering the points does not.

SELECT ST_3DIntersects(b1, b2)
    FROM ST_GeomFromText('LINESTRING Z (0 0 0,1 0 0)')
    As b1,
    ST_GeomFromText('LINESTRING Z (1 0 0,0 0 0)')
    As b2;
-- result{t}

Meanwhile, adding a point avoids triggering it.

SELECT ST_3DIntersects(b1, b2)
    FROM ST_GeomFromText('MULTILINESTRING Z ((2 0 0,1 0 0,0 0 0))')
    As b1,
    ST_GeomFromText('LINESTRING Z (2 0 0,1 0 0,0 0 0)')
    As b2;
-- result{t}

comment:2 by robe, 4 months ago

@Wenjing try to upgrade to the latest for

POSTGIS="3.5.0dev 3.4.0rc1-1071-gff91a5acd" [EXTENSION] PGSQL="160" GEOS="3.13.0dev-CAPI-1.18.0" PROJ="9.3.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/share/proj/proj.db" GDAL="GDAL 3.8.1, released 2023/11/28" LIBXML="2.9.14" LIBJSON="0.17" LIBPROTOBUF="1.4.1" WAGYU="0.5.0 (Internal)" TOPOLOGY RASTER
SELECT ST_3DIntersects(b1, b2)
    FROM ST_GeomFromText('LINESTRING Z (1 0 0, 0 0 0)')
    As b1,
    ST_GeomFromText('LINESTRING Z (1 0 0, 0 0 0)')
    As b2;

st_3dintersects
-----------------
 t
(1 row)

Same for:

SELECT ST_3DIntersects(b2, b1)
    FROM ST_GeomFromText('LINESTRING Z (1 0 0, 0 0 0)')
    As b1,
    ST_GeomFromText('LINESTRING Z (1 0 0, 0 0 0)')
    As b2;

So I think this issue might already be fixed

Version 0, edited 4 months ago by robe (next)
Note: See TracTickets for help on using tickets.