-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Fix rounding errors in center calculation for small layers #8784
Merged
Falke-Design
merged 5 commits into
Leaflet:v1
from
Falke-Design:fix/polygon-center-small
Feb 28, 2023
Merged
Fix rounding errors in center calculation for small layers #8784
Falke-Design
merged 5 commits into
Leaflet:v1
from
Falke-Design:fix/polygon-center-small
Feb 28, 2023
Conversation
This file contains 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
4 tasks
4 tasks
We should release this fix. @mourner @jonkoops @IvanSanchez can you please review. |
jonkoops
requested changes
Feb 11, 2023
Falke-Design
commented
Feb 12, 2023
jonkoops
approved these changes
Feb 13, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
IvanSanchez
previously requested changes
Feb 13, 2023
Quote Ivan "I'm OK with that [...]"
Falke-Design
added a commit
that referenced
this pull request
Feb 28, 2023
4 tasks
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.
For small areas, the center was to far away of the layer. It looks like the reason are rounding errors (Thx to turf.js for the idea: https://github.com/Turfjs/turf/blob/master/packages/turf-center-of-mass/index.ts#L39). But this solution doesn't work good for normal / larger areas, so I added a check if the area of the bounds are small then
1700
it using the rounding preventing solution.To solve this I needed to add the new function
PolyUtil.centroid
.This needs merged in the
main
banche too.error:
![grafik](https://user-images.githubusercontent.com/19800037/211090134-ce69fd79-5b93-4dbf-9d68-620f04174d68.png)
fixed:
![grafik](https://user-images.githubusercontent.com/19800037/211090702-518f3eb8-29cc-4659-af95-96a1a4b9ece4.png)
Fixes #8783
PS: I also cleaned up some unnecessary tests.