id summary reporter owner description type status priority milestone component version resolution keywords cc 3930 Precision error in lwgeom_calculate_mbc / point_inside_circle rundel strk "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. " defect closed medium PostGIS 2.4.3 liblwgeom 2.4.x fixed