[PostGIS] #5827: ST_3DDFullyWithin gives wrong result

PostGIS trac at osgeo.org
Sat Jan 4 00:17:13 PST 2025


#5827: ST_3DDFullyWithin gives wrong result
----------------------+---------------------------
 Reporter:  nbvfgh    |      Owner:  pramsey
     Type:  defect    |     Status:  new
 Priority:  critical  |  Milestone:  PostGIS 3.5.2
Component:  postgis   |    Version:  3.5.x
 Keywords:            |
----------------------+---------------------------
 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"}}}
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5827>
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