[Boost-bugs] [Boost C++ Libraries] #13078: boost::geometry::intersection between a polygon and a box produces incorrect results

Subject: [Boost-bugs] [Boost C++ Libraries] #13078: boost::geometry::intersection between a polygon and a box produces incorrect results
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-06-16 18:24:56


#13078: boost::geometry::intersection between a polygon and a box produces
incorrect results
----------------------------------+---------------------
 Reporter: David R <ratchkov@…> | Owner:
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
  Version: Boost 1.59.0 | Severity: Problem
 Keywords: |
----------------------------------+---------------------
 I am intersecting a polygon with a box and with a polygon of the same
 points as the box. The result from box intersection is incorrect - it is a
 large as the original polygon.

 Here is the code:

 {{{
 #include <iostream>`

 #include <boost/geometry.hpp>
 #include <boost/geometry/geometries/point_xy.hpp>

 namespace bg = boost::geometry;
 namespace bgm = bg::model;

 typedef double base_type;
 typedef bgm::d2::point_xy<base_type> point_type;
 typedef bgm::polygon<point_type> polygon_type;
 typedef bgm::multi_polygon<polygon_type> multipolygon_type;

 int main() {
 std::vector<point_type> points {
     {7.99922500000000127329e+02, 1.04990090625000011642e+04},
     {7.99922500000000013642e+02, 9.99905624999999963620e+03},
     {3.99961250000000006821e+02, 9.99905624999999963620e+03},
     {3.99961250000000006821e+02, 1.04990090625000011642e+04},
     {7.99922500000000127329e+02, 1.04990090625000011642e+04},
 };
 polygon_type poly;
 bg::assign_points(poly, points);
 bgm::box<point_type> box(
     {5.99941874999999981810e+02, 1.02490326562500013097e+04},
     {7.99922500000000013642e+02, 1.04990090625000011642e+04}
 );

 std::vector<point_type> box_points {
     {5.99941874999999981810e+02, 1.02490326562500013097e+04},
     {5.99941874999999981810e+02, 1.04990090625000011642e+04},
     {7.99922500000000013642e+02, 1.04990090625000011642e+04},
     {7.99922500000000013642e+02, 1.02490326562500013097e+04},
     {5.99941874999999981810e+02, 1.02490326562500013097e+04},
 };
 polygon_type box2;
 bg::assign_points(box2, box_points);

 multipolygon_type out;
 bg::intersection(poly, box, out);
 std::cout << bg::area(out) << " " << bg::wkt(out) << std::endl;

 multipolygon_type out2;
 bg::intersection(poly, box2, out2);
 std::cout << bg::area(out2) << " " << bg::wkt(out2) << std::endl;
 return 0;
 }
 }}}

 And this is the output:
 {{{
 199962 MULTIPOLYGON(((599.942 10499,799.923 10499,799.923 9999.06,399.961
 9999.06,399.961 10499,599.942 10499)))
 49990.4 MULTIPOLYGON(((799.923 10249,599.942 10249,599.942 10499,799.923
 10499,799.923 10249)))
 }}}

 Is this expected?

--
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13078>
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-06-16 18:31:14 UTC