Opened 5 years ago
#13510 new Bugs
Boost::intersection giving wrong results when intersection is calculated between 2 polygons in Boost-1.61, where as Boost-1.55 is giving correct results.
Reported by: | Owned by: | Barend Gehrels | |
---|---|---|---|
Milestone: | Boost 1.61.0 | Component: | geometry |
Version: | Boost 1.61.0 | Severity: | Regression |
Keywords: | Cc: |
Description
Hi,
When calculating intersections between 2 polygons, the boost::geometry::intersection is giving wrong results in Boost-1.61 version, where as it is giving correct results in Boost-1.55 version. Here i am attaching the code snippet
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry.hpp> typedef boost::geometry::model::d2::point_xy<double> point; typedef boost::geometry::model::ring<point> ring; typedef boost::geometry::model::polygon<point> Polygon; int main() { Polygon p1; Polygon p2; ring r1; ring r2; r1.push_back(point(0.112, -105.2361)); r1.push_back(point(-0.6946, -53.2131)); r1.push_back(point(-0.2526, 0.9022)); r1.push_back(point(86.4137, 0.8264)); r1.push_back(point(179.5712, 0.0198)); r1.push_back(point(180.78110000, -51.1967)); r1.push_back(point(182.3942, -104.4295)); r1.push_back(point(90.0432, -104.8328)); r1.push_back(point(0.112, -105.2361)); p1.outer() = r1; boost::geometry::correct(p1); r1.clear(); r1.push_back(point(-10.7918213256483, 54.2140961455332)); r1.push_back(point(113.309785590778, -17.5321453530258)); r1.push_back(point(17.8097208933718, -86.8545273414985)); r1.push_back(point(-72.8426247838616, -20.4407767651296)); r1.push_back(point(-10.7918213256483, 54.2140961455332)); r2.push_back(point(33.8071936599424, 20.2800630043229)); r2.push_back(point(-28.7283817002881, -38.3773371397694)); r2.push_back(point(12.4772299711817, -63.1007041426512)); r2.push_back(point(64.8325953890491, 4.28259023775226)); r2.push_back(point(33.8071936599424, 20.2800630043229)); p2.inners().push_back(r2); p2.outer() = r1; boost::geometry::correct(p2); std::vector<Polygon> intersections; boost::geometry::intersection(p1, p2, intersections); return 0; }
The 2nd point in the intersection result i.e 1st index in "interesections" is wrong.
there is a difference of (0.00002) which will reduce the accuracy in computations.
Boost-1.55 version: intersections[1] = (-0.66354193, -55.21624099)
Boost-1.61 version: intersections[1] = (-0.66356150523, -55.216229256)
Note:
See TracTickets
for help on using tickets.