geometry icon indicating copy to clipboard operation
geometry copied to clipboard

`boost::geometry::buffer()` of linestring returns inner polygon

Open Raclamusi opened this issue 1 year ago • 2 comments

I tried to compute the buffer of LINESTRING(3 2, 2 2, 2 4, 4 4, 4 2, 3 1) with a distance of 0.5, but did not get the expected result and instead got the inner polygon. This problem does not occur with the reverse order linestring, LINESTRING(3 1, 4 2, 4 4, 2 4, 2 2, 3 2).

https://godbolt.org/z/Gfd85v5bG

Expected Result: MULTIPOLYGON(((2.79289 1.5,2 1.5,1.5 1.5,1.5 2,1.5 4,1.5 4.5,2 4.5,4 4.5,4.5 4.5,4.5 4,4.5 2,4.5 1.79289,4.35355 1.64645,3.35355 0.646447,2.64645 1.35355,2.79289 1.5),(3 1.70711,3.5 2.20711,3.5 3.5,2.5 3.5,2.5 2.5,3 2.5,3 1.70711))) Result with boost-1.84.0: MULTIPOLYGON(((3 1.70711,3 2.5,2.5 2.5,2.5 3.5,3.5 3.5,3.5 2.20711,3 1.70711)))

Screenshot

Raclamusi avatar Feb 27 '24 17:02 Raclamusi

Thanks for the report, I can reproduce it. Not yet fixed by my last changes.

barendgehrels avatar Feb 28 '24 08:02 barendgehrels

It is fixed now. I jumped on it because the case is, geometrically, so simple, it should really not fail. But apparently it was still a rare case, needing a condition which should always have been there. Great you found it and reported it.

barendgehrels avatar Feb 28 '24 21:02 barendgehrels

The fix is merged, closing.

barendgehrels avatar Mar 23 '24 10:03 barendgehrels