Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: geometry::buffer returns an empty multi-polygon in a very specific case #1294

Closed
DJ-caddev opened this issue Jul 25, 2024 · 4 comments
Closed
Assignees
Labels

Comments

@DJ-caddev
Copy link

BOOST v1.84 / v1.85

Using the following code, lOuts is empty in the end:

boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>> lPolygon;
lPolygon.outer().push_back({730.35, 750.00});
lPolygon.outer().push_back({730.35, 740.00});
lPolygon.outer().push_back({726.02, 740.00});
lPolygon.outer().push_back({726.02, 735.00});
lPolygon.outer().push_back({730.35, 735.00});
lPolygon.outer().push_back({730.35, 0.00});
lPolygon.outer().push_back({0.00, 0.00});
lPolygon.outer().push_back({0.00, 750.00});
lPolygon.outer().push_back({730.35, 750.00});

static const boost::geometry::strategy::buffer::side_straight side_strategy;
const boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(5);
boost::geometry::model::multi_polygon<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>>> lOuts;

static const boost::geometry::strategy::buffer::join_miter join_strategy;
static const boost::geometry::strategy::buffer::end_flat end_strategy;
static const boost::geometry::strategy::buffer::point_circle point_strategy;
boost::geometry::buffer(lPolygon, lOuts, distance_strategy, side_strategy, join_strategy, end_strategy, point_strategy);

The shape looks like this:
image

If the small hole is moved a bit to the bottom, the boost function seems to work well.
This is a very specific case that crashes in our code.
Moreover, we need to keep "rectangular/cartesian" shapes (we cannot have arcs in the final shapes).

Do you guys have any clue of how to bypass this particular problem? Is this a wrong usage from on our side or something that Boost can fix directly?

If you need any detail, feel free to ask :)

@barendgehrels barendgehrels self-assigned this Jul 27, 2024
@barendgehrels
Copy link
Collaborator

Indeed, I can reproduce it. The code is right.

@barendgehrels
Copy link
Collaborator

barendgehrels commented Jul 27, 2024

Ugly workaround: add 1.0e-12 to the distance.

Smaller reproduction wkt: POLYGON((130.35 150,130.35 140,126.02 140,126.02 135,130.35 135,130.35 0,0 0,0 150,130.35 150))

It generates colocated turns. The green ones on the right side are all detected OK. But the top two are colocated (therefore you see only 2) and that causes the problem.
image

To be continued.

@barendgehrels
Copy link
Collaborator

I've a working fix and will make a PR on Wednesday

@barendgehrels
Copy link
Collaborator

This was fixed in July 30 (but the issue was not closed automatically, somehow - and not manually). PR #1300
Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants