Repository navigation
Add lower bound to the OverlayNG area check for symDifference - #1241
Open
adityaanikam wants to merge 1 commit into
Open
adityaanikam wants to merge 1 commit into
adityaanikam wants to merge 1 commit into
Conversation
OverlayUtil.isResultAreaConsistent only checked an upper bound for SYMDIFFERENCE, so a result with negative area was accepted. For the input in locationtech#1239 this stopped OverlayNGRobust from retrying with a larger snap tolerance, and an inverted polygon was returned. A symmetric difference cannot be smaller than the difference of the input areas. Check that, relaxed by the area tolerance as it is for DIFFERENCE, so that nearly identical inputs still give an empty result. Fixes locationtech#1239 Signed-off-by: adityaanikam <adityanikam9502@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1239
OverlayUtil.isResultAreaConsistentchecked only an upper bound forSYMDIFFERENCE, so a result with negative area was accepted. For the input in #1239, the first snapping attempt ofOverlayNGRobustbuilds an inverted polygon, the check accepts it, and the retry with a larger snap tolerance never happens.A symmetric difference cannot be smaller than the difference of the input areas, so this adds that lower bound. It is relaxed by the same area tolerance that the other operations use (a fraction of the larger input area). Without the relaxation, nearly identical inputs would be rejected: their areas differ only by rounding and the correct result is empty (the case from #951 and #1005). The lower bound is the one proposed in the issue.
This only fixes the safety net. The first snapping attempt still builds an inverted polygon, which is not changed here.
Testing
OverlayNGRobustTest.testSymDifferencePolygonLineInvertedResultuses the input from the issue and checks that the result is valid and has the area of the polygon.mvn test -pl modules/coreruns 2308 tests with no failures (Windows, JDK 17, Maven 3.9.16, with the project's checkstyle).OverlayUtil.javareverted and the new test kept, the new test fails onresult is valid. The other 7 tests inOverlayNGRobustTestpass.