I have a set of polygons of which I want to find the union. In order to allow for some floating point inaccuracies for polygons that touch each other, I am using boost::geometry::buffer
with a inflation strategy via boost::geometry::strategy::buffer::distance_symmetric<double>
. For certain inputs, the buffer operation produces results that I do not understand:
There are 7 polygons to be joined. The union (via boost::geometry::union_
) behaves as expected, but in the buffered join, the last two polygons appear to be missing.
Interestingly, the buffer behaves as expected if I slightly perturbate Polygon 4 (shifted by 0.01 in x).
or remove it from the set altogether:
Code snippet of polygon set of buffer operation:
using Point = boost::geometry::model::d2::point_xy<double>;
using Polygon = boost::geometry::model::polygon<Point>;
double epsilon = 0.3;
boost::geometry::strategy::buffer::join_miter join_strategy;
boost::geometry::strategy::buffer::distance_symmetric<double>
inflate_strategy(epsilon);
boost::geometry::strategy::buffer::end_flat end_strategy;
boost::geometry::strategy::buffer::side_straight side_strategy;
boost::geometry::strategy::buffer::point_circle point_strategy;
boost::geometry::model::multi_polygon<Polygon> source_set, joined_inflated;
source_set.push_back(
Polygon{{Point(12.50, 36.50), Point(12.50, 30.50), Point(6.50, 30.50),
Point(6.50, 36.50), Point(12.50, 36.50)}});
source_set.push_back(
Polygon{{Point(6.50, 27.00), Point(6.50, 33.50), Point(12.50, 33.50),
Point(12.50, 27.00), Point(6.50, 27.00)}});
source_set.push_back(
Polygon{{Point(12.50, 30.00), Point(12.50, 24.00), Point(6.50, 24.00),
Point(6.50, 30.00), Point(12.50, 30.00)}});
source_set.push_back(
Polygon{{Point(24.00, 24.00), Point(9.50, 24.00), Point(9.50, 30.00),
Point(24.00, 30.00), Point(24.00, 24.00)}});
source_set.push_back(
Polygon{{Point(27.0, 30.0), Point(27.0, 24.0), Point(21.0, 24.0),
Point(21.0, 30.0), Point(27.0, 30.0)}});
source_set.push_back(
Polygon{{Point(28.10, 30.73), Point(26.90, 26.23), Point(21.10, 27.77),
Point(22.30, 32.27), Point(28.10, 30.73)}});
source_set.push_back(
Polygon{{Point(28.20, 34.50), Point(28.20, 28.50), Point(22.20, 28.50),
Point(22.20, 34.50), Point(28.20, 34.50)}});
boost::geometry::buffer(source_set, joined_inflated, inflate_strategy,
side_strategy, join_strategy, end_strategy,
point_strategy);
Why does the buffered join behave this way?