Opened 20 months ago

Last modified 19 months ago

#12663 new Support Requests

geometry::equals fails when points differ by small value

Reported by: anonymous Owned by: Barend Gehrels
Milestone: To Be Determined Component: geometry
Version: Boost 1.61.0 Severity: Problem
Keywords: equals Cc:


It seems the geometry::equals function is very strict when dealing w/ floating point precision. I have 2 polygons that are the same except for one point (15.0, 10.0) vs (14.9999999999, 10.0), but geometry::equals returns false. I don't know if this is a bug or the expected behavior. What is the tolerance and is there a way to specify it?

bg_polygon polygon1; boost::geometry::read_wkt("POLYGON((10.0 10.0, 10.0 20.0, 15.0 20.0, 14.9999999999 10.0, 10.0 10.0))", polygon1);

bg_polygon polygon2; boost::geometry::read_wkt("POLYGON((10.0 10.0, 10.0 20.0, 15.0 20.0, 15.0 10.0, 10.0 10.0))", polygon2);

boost::geometry::equals(polygon1, polygon2); --> returns false

Attachments (0)

Change History (1)

comment:1 Changed 19 months ago by awulkiew

Type: BugsSupport Requests

Yes, this is expected. Points are compared WRT machine epsilon scaled by the greater coordinate absolute value. Currently it's not possible to pass user-defined epsilon value into algorithms which could be used in Point comparisons. It'd be possible to implement custom coordinate type with comparison operator using greater epsilon but this way this comparison method would be used in every case, not only when Points were compared.

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain Barend Gehrels.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.