[Boost-bugs] [Boost C++ Libraries] #10234: boost::geometry::covered_by wrong results

Subject: [Boost-bugs] [Boost C++ Libraries] #10234: boost::geometry::covered_by wrong results
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-07-23 15:44:39


#10234: boost::geometry::covered_by wrong results
-------------------------------------------+---------------------------
 Reporter: Alexander Sarychev <alex-x@…> | Owner: barendgehrels
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: geometry covered_by |
-------------------------------------------+---------------------------
 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;
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10234>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC