0

I have a problem with boost::geometry::covered_by method to determine if point is inside polygon or not. In the example below I have point that is exactly out of polygon. Point is far away from polygon by x coordinate (0.1377). The 3rd point of polygon has y-coordinate (4.9999999999999982). And this leads to problem I think. When I change 4.9999999999999982 to 5.00 all is OK. What to do?

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>


int main()
{
typedef boost::geometry::model::d2::point_xy<double> bg_point;
typedef boost::geometry::model::polygon< bg_point, false, true > bg_polygon;

// point is tested (out of polygon)
bg_point    p(0.1377, 5.00);

// polygon
bg_polygon  poly;
boost::geometry::read_wkt("POLYGON((0.1277 4.97,  0.1277 5.00, 0.1278 4.9999999999999982, 0.1278 4.97, 0.1277 4.97))", poly);

bool inside;

// inside = true here (ERROR!)
inside = boost::geometry::covered_by(p, poly);

// change 4.9999999999999982 to 5.00
boost::geometry::read_wkt("POLYGON((0.1277 4.97,  0.1277 5.00, 0.1278 5.00, 0.1278 4.97, 0.1277 4.97))", poly);

// inside = false here (OK)
inside = boost::geometry::covered_by(p, poly);

return 0;
}
tobias_k
  • 81,265
  • 12
  • 120
  • 179

1 Answers1

1

This sounds like a bug. You should post it to the boost trac:

https://svn.boost.org/trac/boost/

Brandon Kohn
  • 1,612
  • 8
  • 18