[postgis-tickets] [PostGIS] #4151: ST_3DDwithin Errors on memcmp with pt_in_ring_3d

PostGIS trac at osgeo.org
Thu Aug 16 05:24:11 PDT 2018


#4151: ST_3DDwithin Errors on memcmp with pt_in_ring_3d
---------------------+---------------------------
 Reporter:  tilt     |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:  PostGIS 2.5.0
Component:  postgis  |    Version:  trunk
 Keywords:           |
---------------------+---------------------------
 The following query:

 {{{
 SELECT
 ST_3DDwithin(ST_GeometryFromText('POLYGON Z ((
 238122.872000001 576633.508999999 5.98677038142003,
 238122.872 576633.509 5.98677038052055,
 238121.623809392 576634.389879555 4.95792405791038,
 238120.252000002 576635.357999998 3.82718245716979,
 238120.252 576635.358 3.82718245541562,
 238121.873 576637.738 3.8333125996467,
 238121.873000001 576637.737999999 3.83331260027449,
 238124.460390651 576635.62447975 6.0745417745131,
 238122.991788134 576633.427399075 6.08439985368325,
 238122.872000001 576633.508999999 5.98677038142796))
 ')
 ST_GeometryFromText('POINT Z (238123 576634 0)')
 ,0.1)
 }}}

 results in:

 {{{
 ERROR:  pt_in_ring_3d: V[n] != V[0] (238123 576634 5.98677!= 238123 576634
 5.98677)
 }}}

 Likely this is due to a rounding error and happening in:

 {{{
 https://github.com/postgis/postgis/blob/svn-
 trunk/liblwgeom/measures3d.c#L1249
 }}}

 The polygon obviously is not a very nice one (with vertices almost on top
 of each other) but it is valid. I tried the folowing workarounds: \\
  ST_RemoveRepeatedPoints 0.1\\
  ST_SnapToGrid 0.1\\
  manually cleaning the polygon\\

 Only the last option worked so I suspect the problem is in the precision
 of the Z-value, since the other two only deal with 2D coordinates.

 Running on:

 {{{
 POSTGIS="2.5.0rc1dev r16693" [EXTENSION] PGSQL="100"
 GEOS="3.7.0beta2-CAPI-1.11.0 e7d54545" SFCGAL="1.3.5" PROJ="Rel. 5.1.0,
 June 1st, 2018" GDAL="GDAL 2.4.0dev-3ea4d4ed14-dirty, released 2018/07/09"
 LIBXML="2.9.4" LIBJSON="0.12.1" LIBPROTOBUF="1.2.1" (core procs from
 "2.5.0beta2dev r16638" need upgrade) RASTER (raster procs from
 "2.5.0beta2dev r16638" need upgrade) (sfcgal procs from "2.5.0beta1dev
 r16609" need upgrade)
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4151>
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