lib/vector: improve numerical stability for point-in-polygon calculations#7333
Open
metzm wants to merge 2 commits intoOSGeo:mainfrom
Open
lib/vector: improve numerical stability for point-in-polygon calculations#7333metzm wants to merge 2 commits intoOSGeo:mainfrom
metzm wants to merge 2 commits intoOSGeo:mainfrom
Conversation
ee3e17e to
ca061ca
Compare
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.
What this PR does:
dig_x_intersect(),Vect__intersect_x_line_with_poly()andVect__intersect_y_line_with_poly()Vect_point_in_poly()whenever possible for consistency and to reduce code maintenance burdenThe motivation for this PR arises from two issues:
Vect_get_point_in_poly_isl()fails for very small or very thin areas. This PR improves this fn by successfully calculating centroid's coordinates for more very small or very thin areas. However, because of fp precision limits, it is technically not possible to calculate centroid's coordinates for too small or too thin areas. In these cases it can not be guaranteed that the centroid is really inside the area.Vect_get_point_in_poly_isl()confirm that the calculated centroid's coordinates are indeed inside the given area,Vect_find_area()might in extreme cases later on assign this centroid to a different area, causing problems with both duplicate centroids and missing centroids.I am not sure if this PR should be regarded as a bug fix or as an enhancement. Suggestions welcome!
Please excuse the many changes in this single PR, but they really belong together.