Opened 2 days ago

Last modified 10 hours ago

#5827 new defect

ST_3DDFullyWithin gives wrong result

Reported by: nbvfgh Owned by: pramsey
Priority: critical Milestone: PostGIS 3.6.0
Component: postgis Version: 3.5.x
Keywords: Cc:

Description

When translating the Point, Linestring, and Polygon by 1 unit on the x and y axes on the plane Z=1 and tested them separately with ST_DFullyWithin and ST_3DDFullyWithin, obtaining inconsistent results.

SELECT ST_DFullyWithin(a, a_translate, 2), ST_3DDFullyWithin(a, a_translate, 2) FROM 
(SELECT ST_POINTS(ST_GeomFromText('POINT Z(0 0 1)')) AS a,
  ST_POINTS(ST_GeomFromText('POINT Z(1 1 1)')) AS a_translate);

-- result:{t, t}

SELECT ST_DFullyWithin(a, a_translate, 2), ST_3DDFullyWithin(a, a_translate, 2) FROM 
(SELECT ST_POINTS(ST_GeomFromText('MULTIPOINT Z(0 0 1, 1 1 1)')) AS a,
  ST_POINTS(ST_GeomFromText('MULTIPOINT Z(1 1 1, 2 2 1)')) AS a_translate);

-- result:{t, f}

SELECT ST_DFullyWithin(a, a_translate, 2), ST_3DDFullyWithin(a, a_translate, 2) FROM 
(SELECT ST_GeomFromText('LINESTRING Z(0 0 1, 0 1 1, 1 1 1, 1 0 1, 0 0 1)') AS a,
  ST_GeomFromText('LINESTRING Z(1 1 1, 1 2 1, 2 2 1, 2 1 1, 1 1 1)') AS a_translate);

-- result:{t, f}

SELECT ST_DFullyWithin(a, a_translate, 2), ST_3DDFullyWithin(a, a_translate, 2) FROM 
(SELECT ST_GeomFromText('POLYGON Z((0 0 1, 0 1 1, 1 1 1, 1 0 1, 0 0 1))') AS a,
  ST_GeomFromText('POLYGON Z((1 1 1, 1 2 1, 2 2 1, 2 1 1, 1 1 1))') AS a_translate);

-- result:{t, f}

Each point in geometry a should be translated to its corresponding point in geometry a_translate, and the distance between each pair of points should be √(2). Therefore, to make DFullyWithin and 3DDFullyWithin true, setting the parameter distance to √(2) is completely sufficient.

SELECT ST_DFullyWithin(a, a_translate, sqrt(2)), ST_3DDFullyWithin(a, a_translate, sqrt(2)) FROM 
(SELECT ST_GeomFromText('POLYGON Z((0 0 1, 0 1 1, 1 1 1, 1 0 1, 0 0 1))') AS a,
  ST_GeomFromText('POLYGON Z((1 1 1, 1 2 1, 2 2 1, 2 1 1, 1 1 1))') AS a_translate);

-- result{t, f}

Version Info: POSTGIS="3.5.0 3.5.0" [EXTENSION] PGSQL="170" GEOS="3.13.0-CAPI-1.19.0" SFCGAL="SFCGAL 1.5.2, CGAL 5.6.1, BOOST 1.84.0"

Attachments (1)

bug13.png (47.6 KB ) - added by nbvfgh 2 days ago.

Download all attachments as: .zip

Change History (6)

by nbvfgh, 2 days ago

Attachment: bug13.png added

comment:1 by nbvfgh, 2 days ago

This issue also exists in the unreleased version 3.6.0. Version Info: POSTGIS="3.6.0dev 3.5.0-91-g593df9088" [EXTENSION] PGSQL="170" GEOS="3.13.0-CAPI-1.19.0"

comment:2 by nbvfgh, 2 days ago

Milestone: PostGIS 3.5.2PostGIS 3.6.0

comment:3 by robe, 18 hours ago

I know we changed the behavior in ST_DFullyWithin in 3.5.0 as noted in https://git.osgeo.org/gitea/postgis/postgis/src/branch/stable-3.5/NEWS#L90

#5659

I guess we didn't change the behavior of ST_3DDFullyWithin

comment:4 by nbvfgh, 14 hours ago

Yes, but there is currently no implementation of 3DContains or 3DWithin (at least I haven't seen it in the documentation).

Last edited 10 hours ago by nbvfgh (previous) (diff)

comment:5 by nbvfgh, 13 hours ago

Last edited 11 hours ago by nbvfgh (previous) (diff)
Note: See TracTickets for help on using tickets.