I have a little test application to intersect a few rectangles with boost::geometry.
typedef boost::geometry::model::point
<
double, 2, boost::geometry::cs::cartesian
> point;
typedef boost::geometry::model::polygon<point > polygon;
polygon Intersect(polygon p1, polygon p2) {
std::vector < polygon > result;
boost::geometry::intersection(p1, p2, result);
return result.front();
}
polygon IntersectionTest() {
polygon one, two, three, four;
boost::geometry::read_wkt("POLYGON((35 25, 35 35, 15 35, 15 25, 35 25))", one);
boost::geometry::read_wkt("POLYGON((45 30, 45 50, 25 50, 25 30, 45 30))", two);
boost::geometry::read_wkt("POLYGON((50 0, 50 40, 10 40, 10 0, 50 0))", three);
boost::geometry::read_wkt("POLYGON((40 20, 40 60, 0 60, 0 20, 40 20))", four);
return Intersect(Intersect(Intersect(one, two), three), four);
}
I must do something wrong, because I expect the result to be something like (35 30, 35 40, 25 40, 25 30, 35 30)
yet I get 10 points long polygons containing points like 50 0
while intersections of parallel rectangles should always be rectangles with 4+1 points and 50 0
is at the edge so it shouldn't be in the intersection at all. If I put it into an SVG, the rectangles seems to be as I expect them.
What can be wrong? If it is a bug in boost::geometry
how can I make sure it is? (I'm currently using 1.48.) If it is a bug is there a way to circumvent the problem?