-
Notifications
You must be signed in to change notification settings - Fork 943
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
Added special handling to booleanPointOnLine for zero length lines #2751
base: master
Are you sure you want to change the base?
Added special handling to booleanPointOnLine for zero length lines #2751
Conversation
…urning false positives for points on the same longitude as zero length lines.
Merging this will clear the way to getting a couple of cleanCoords bugs fixed as well. |
@JamesLMilner or @mfedderly could I please request someone cast an eye over this? There are a couple of other issues - cleanCoords and simplify - that can proceed once this is merged. |
|
||
// Special cases for zero length lines | ||
// https://github.com/Turfjs/turf/issues/2750 | ||
if (Math.abs(dxl) === Math.abs(dyl) && Math.abs(dxl) === 0) { |
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.
Does this math need to be done with some small epsilon for the float comparison instead of ===
?
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.
It should be ok without. The new section is guarding against the old (lower) code getting too many 0
s for dxl, etc. They don't seem to behave if they do.
If they get any value above zero, no matter how small, they cope. For example, did some experiments changing the test line string to:
lineString([
[1, 1],
[1 + Number.EPSILON, 1],
])
and all is well.
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.
I could try incorporating additional checks into the existing return dxl > 0 ? x1 <= x && x <= x2 : x2 <= x && x <= x1;
type code but keeping them separate seemed neater.
In cases where the point was on the same longitude as a zero length line, even if the point was far away, booleanPointOnLine would return true.
Resolves #2750