-
Notifications
You must be signed in to change notification settings - Fork 343
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
Buffer operation: use fallback to lower precision when result geometry is invalid #561
Conversation
JTS recently had the buffer quadSegs behaviour improved/clarified: JTS-778. So the first thing to do is to port that fix, and see if that solves this problem. If not can then investigate further. |
It turns out the fix from JTS-778 doesn't have any effect on this issue. (It's still worthwhile though, so I'll be making a PR for it). At the moment this looks like some kind of robustness issue in GEOS which isn't in JTS. Perhaps due to a noding failure which for some reason isn't being detected. This will require more investigation. I'm really reluctant to accept the fix in this PR, though, because running validation is costly and it penalizes every call to buffer. |
Yes, this is a robustness issue. geos/src/operation/buffer/BufferBuilder.cpp Line 429 in 4526237
Labels are edge index / point index in edge, image is not to scale, close points are really close (see second image). I think the exact cause here is point Here are coordinates of the 4-point group in the middle, where multiple buffer lines intersect: JTS documetation states that I may be missing something but I don't see a good way to handle this situation using C API, since there's no precision parameter for buffer operation. |
Further investigation reveals the following:
Not sure that trying to fix the GEOS topology building will be very easy. So the easy thing to do is to in fact check whether buffer is valid, as this PR suggests. In fact, buffer output tends to be simpler than the input, so this may not be a huge performance hit. (It will certainly be faster than checking the noding arrangement, since that can be very large). |
So... do we actually want a post-buffer validity check? |
I think the answer is that we do not want a post-buffer validity check, people can do that themselves if it's something they care about. |
Fix for "GEOSBufferWithStyle produce invalid geometry when quadsegs = 0" https://trac.osgeo.org/geos/ticket/1131
The issue can be solved by falling back on lower precision in
BufferOp::computeGeometry()
, but currently the result ofBufferBuilder::buffer()
is assumed to always be valid. I suggest adding validity check toBufferBuilder::buffer()
and throwing when it fails, so the caller can retry with lower precision.