-
Notifications
You must be signed in to change notification settings - Fork 953
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
booleanPointOnLine fails for aligned points #2826
Comments
I kept on digging and I used a function allowing me to reproduce my need and it works correctly. I don't know if there's a difference with the function you're using. isPointOnLine: function (point, lineStart, lineEnd, tolerance = 0.00001) {
const [x, y] = point
const [x1, y1] = lineStart
const [x2, y2] = lineEnd
// Calculer l'équation de la ligne (distance point -> ligne)
const distance
= Math.abs((y2 - y1) * x - (x2 - x1) * y + x2 * y1 - y2 * x1)
/ Math.sqrt((y2 - y1) ** 2 + (x2 - x1) ** 2)
// Vérifier si la distance est inférieure ou égale à la tolérance
return distance <= tolerance
} |
In this case, with the data you provided:
Perhaps the question is, should |
Sensible suggestion. Couple of thoughts:
So default tolerance becomes whatever amounts to 0.000001 degrees / 10cm? |
That suggestion makes sense to me. The current behaviour, expecting floating point calculations to somehow yield exact equality does not. (Shame the spec doesn't quite come out as far as recommending 6 DPs. It sort of tiptoes all around it, but doesn't quite say it.) |
Maybe 10 years ago the "cost" of those extra bytes felt like a more firm handed warning 🤷 |
📝 Description
The function
turf.booleanPointOnLine
incorrectly returnsfalse
when checking if a point lies on a line, even when the point is perfectly aligned with the line segment. This behavior occurs under the following conditions:📍 Coordinates
[1.1491048489081164, 47.97013091862306]
[1.1497411448453079, 47.97009507298361]
[1.1489123422593934, 47.970141763457235]
🔍 Steps to Reproduce
The text was updated successfully, but these errors were encountered: