Algorithm generates wrong results due to limits on double type
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript
- Domain
- computer-graphics
Research direction
Start by locating the polylabel implementation and its bounding-box calculation, then reproduce the issue with the four-point polygon in the report. Verify the coordinate normalization avoids loss of precision and that bounding boxes account for all rings, while preserving the expected returned point.
Written by the indexing model from the issue text.
Description
If you try to find the polylabel for the following polygon, it fails to find a good point.
-111.1815838, 45.7768091
-111.1816944, 45.7766950
-111.1812484, 45.7764847
-111.1811378, 45.7765988
It does not matter what precision you use. It does drill down to a point, but it is not right.
This is due to limitations in the double type.
The solution is to subtract the min of the bounding box before doing the remaining calculations, and then add it back at the end. This does seem to fix the problem in my tests, and shouldn't add much in execution time.
Also, it would also be best to calculate the bounding box for all rings to better avoid this problem.
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 163
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/polylabel
-
question
Difficulty 3/5 1-2 days Newbie friendliness 20/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
question
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
-
enhancement question
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
MultiPolygon Openquestion
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in mapbox/polylabel
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·