geometry icon indicating copy to clipboard operation
geometry copied to clipboard

Error in validity (report) (was: multipolygon buffer result either invalid geometry or valid geometry but wrong)

Open gastald88 opened this issue 2 years ago • 6 comments

I want to buffer of a small amount the multipolygon in the following picture (I apologize if it is quite complicated, I tried to replicate the issue in a simpler shape but I could not make it):

image

When applying the buffer algorithm, I have encountered two problems:

  1. if the buffer amount is 0.05, we obtain an invalid geometry due to self-intersections in the external border;
  2. if the buffer amount is 0.050005, we obtain a valid geometry, but the result is wrong (see image below). image

Here below a godbolt link to replicate this problem: https://godbolt.org/z/vM9ex7MrW

gastald88 avatar Aug 28 '23 15:08 gastald88

Can you please use it without #define BOOST_GEOMETRY_ROBUSTNESS_ALTERNATIVE This is not supposed to be used by library users (maybe it was suggested here once, but that was erroneous). Can you remove the define?

barendgehrels avatar Aug 29 '23 17:08 barendgehrels

Just did it myself.

Program returned: 0
Using Boost 1.83.0
is poly valid? true

buffer amount: 0.05
is buffered poly valid? false
validity check message: Geometry has invalid self-intersections. A self-intersection point was found at (1292.86, 1471.84); method: i; operations: i/u; segment IDs {source, multi, ring, segment}: {0, 0, -1, 259}/{0, 0, -1, 262}

buffer amount: 0.050005
is buffered poly valid? true
validity check message: Geometry is valid

So the report looks still the same.

barendgehrels avatar Aug 29 '23 17:08 barendgehrels

Adding area, report is now:

buffer amount: 0.05000000000000000278
area 4015945.12599748093634843826
is buffered poly valid? false
validity check message: Geometry has invalid self-intersections. A self-intersection point was found at (1292.86, 1471.84); method: i; operations: i/u; segment IDs {source, multi, ring, segment}: {0, 0, -1, 259}/{0, 0, -1, 262}

buffer amount: 0.05000500000000000084
area 4015945.17474469868466258049
is buffered poly valid? true
validity check message: Geometry is valid

It seems like the buffer has the same shape for both distances (still reporting one as invalid)

Added: << std::fixed << std::setprecision(20) and, per buffer << "area " << boost::geometry::area(buffered_poly) << std::endl

barendgehrels avatar Aug 29 '23 17:08 barendgehrels

Can you please use it without #define BOOST_GEOMETRY_ROBUSTNESS_ALTERNATIVE This is not supposed to be used by library users (maybe it was suggested here once, but that was erroneous). Can you remove the define?

Thank you for the reply.

As you said, I defined that macro as suggested in another issue of mine (see issue #1138), since that actually solved the problem. Do you think I should anyway remove the definition of BOOST_GEOMETRY_ROBUSTNESS_ALTERNATIVE and wait for future fixes of #1138 not concerning such macro?

gastald88 avatar Sep 01 '23 10:09 gastald88

It is not yet fixed, unlike #1138 Yes, please remove the define BOOST_GEOMETRY_ROBUSTNESS_ALTERNATIVE, it is deprecated The validity check might be a false positive in this case. Therefore I'm not closing this issue. But the buffer itself looks reasonable.

barendgehrels avatar Sep 14 '23 09:09 barendgehrels

perfect, thank you very much for the update.

gastald88 avatar Sep 14 '23 09:09 gastald88