[postgis-tickets] [PostGIS] #3930: Precision error in lwgeom_calculate_mbc / point_inside_circle

PostGIS trac at osgeo.org
Sat Nov 18 09:54:55 PST 2017


#3930: Precision error in lwgeom_calculate_mbc / point_inside_circle
-----------------------+---------------------------
 Reporter:  rundel     |      Owner:  strk
     Type:  defect     |     Status:  new
 Priority:  medium     |  Milestone:  PostGIS 2.4.2
Component:  liblwgeom  |    Version:  2.4.x
 Keywords:             |
-----------------------+---------------------------
 Working on an R wrapper for lwgeom we recent came across a bug with
 lwgeom_calculate_mbc where certain geometries on 32 bit systems returned
 nan values for center and radius of the mbc. After some debugging the
 issue is caused by bad floating point comparison in the
 point_inside_circle function. Specifically, distance2d_pt_pt(p, c->center)
 > c->radius will erroneously return true when the point p is identical to
 one of the support points on 32 bit but not 64 bit systems.

 Replacing this test with distance2d_pt_pt(p, c->center) - c->radius >
 DBL_EPSILON along with including float.h was able to resolve this issue
 for our test case.

 Our discussion about the bug and the related pull request for the R
 package can be found here: https://github.com/r-spatial/lwgeom/issues/7.
 An example of the specific geometry that was producing the error is
 attached as WKT.

 I am happy to provide a pull request to the github repo if that would be
 helpful.

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