[PostGIS] #5817: CG_3DIntersection gives wrong result with LINESTRING and Solid
PostGIS
trac at osgeo.org
Thu Dec 5 18:36:51 PST 2024
#5817: CG_3DIntersection gives wrong result with LINESTRING and Solid
----------------------+---------------------------
Reporter: nbvfgh | Owner: lbartoletti
Type: defect | Status: new
Priority: critical | Milestone: PostGIS 3.5.1
Component: sfcgal | Version: 3.5.x
Keywords: |
----------------------+---------------------------
{{{
SELECT ST_IsClosed('POLYHEDRALSURFACE Z (
((-1 1 -1,1 1 -1,1 -1 -1,-1 -1 -1,-1 1 -1)),
((-1 1 1,-1 -1 1,1 -1 1,1 1 1,-1 1 1)),
((-1 1 -1,-1 1 1,1 1 1,1 1 -1,-1 1 -1)),
((1 1 -1,1 1 1,1 -1 1,1 -1 -1,1 1 -1)),
((1 -1 -1,1 -1 1,-1 -1 1,-1 -1 -1,1 -1 -1)),
((-1 -1 -1,-1 -1 1,-1 1 1,-1 1 -1,-1 -1 -1)))');
-- result:{true}
}}}
Then we make the closed POLYHEDRALSURFACE a Solid, and use
CG_3DIntersection to get the Interaction with the Solid and Linestring,
which we get the unexpected result.
{{{
WITH solid AS (
SELECT
CG_MakeSolid('POLYHEDRALSURFACE Z (
((-1 1 -1,1 1 -1,1 -1 -1,-1 -1 -1,-1 1 -1)),
((-1 1 1,-1 -1 1,1 -1 1,1 1 1,-1 1 1)),
((-1 1 -1,-1 1 1,1 1 1,1 1 -1,-1 1 -1)),
((1 1 -1,1 1 1,1 -1 1,1 -1 -1,1 1 -1)),
((1 -1 -1,1 -1 1,-1 -1 1,-1 -1 -1,1 -1 -1)),
((-1 -1 -1,-1 -1 1,-1 1 1,-1 1 -1,-1 -1 -1)))')
geom
)
SELECT
ST_AsText(CG_3DIntersection(
'LINESTRING (-2 0 0, 2 0 2)'::geometry,
solid.geom
)),
ST_AsText(CG_3DIntersection(
'LINESTRING (-2 0 0,0 0 1,2 0 2)'::geometry,
solid.geom
))
FROM solid;
-- expected: {{LINESTRING Z (-1 0 0.5,0 0 1)},{LINESTRING Z (-1 0 0.5,0 0
1)}}
-- actual : {{POINT Z (-1 0 0.5)},{LINESTRING Z (-1 0 0.5,0 0 1)}}
}}}
To verify that the issue is not caused by differences in the two
Linestrings, we ran the following query:
{{{
SELECT
ST_AsText(CG_3DIntersection(
'LINESTRING (-2 0 0,2 0 2)'::geometry,
'POLYHEDRALSURFACE Z (((-1 1 -1,1 1 -1,1 -1 -1,-1 -1 -1,-1 1
-1)),((-1 1 1,-1 -1 1,1 -1 1,1 1 1,-1 1 1)),((-1 1 -1,-1 1 1,1 1 1,1 1
-1,-1 1 -1)),((1 1 -1,1 1 1,1 -1 1,1 -1 -1,1 1 -1)),((1 -1 -1,1 -1 1,-1 -1
1,-1 -1 -1,1 -1 -1)),((-1 -1 -1,-1 -1 1,-1 1 1,-1 1 -1,-1 -1 -1)))'
)),
ST_AsText(CG_3DIntersection(
'LINESTRING (-2 0 0,0 0 1,2 0 2)'::geometry,
'POLYHEDRALSURFACE Z (((-1 1 -1,1 1 -1,1 -1 -1,-1 -1 -1,-1 1
-1)),((-1 1 1,-1 -1 1,1 -1 1,1 1 1,-1 1 1)),((-1 1 -1,-1 1 1,1 1 1,1 1
-1,-1 1 -1)),((1 1 -1,1 1 1,1 -1 1,1 -1 -1,1 1 -1)),((1 -1 -1,1 -1 1,-1 -1
1,-1 -1 -1,1 -1 -1)),((-1 -1 -1,-1 -1 1,-1 1 1,-1 1 -1,-1 -1 -1)))'
));
-- expected: {{MULTIPOINT Z ((-1 0 0.5),(0 0 1))},{MULTIPOINT Z ((-1 0
0.5),(0 0 1))}
-- actual : {{MULTIPOINT Z ((-1 0 0.5),(0 0 1))},{MULTIPOINT Z ((-1 0
0.5),(0 0 1))}
}}}
The intersection between the original POLYHEDRALSURFACE and these two
linestrings yielded the same result, so there should be some bugs in the
operation of the intersection between Solid and Linestring.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5817>
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