-
Notifications
You must be signed in to change notification settings - Fork 952
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
booleanEqual check does not properly handle precision #2530
Comments
Thanks for raising @solarissmoke. Given geojson-equality hasn't seen any activity for several years, it might be best to re-implement it afresh. Would you mind sharing a few thoughts about what the PR might look like? Would it be a new module, or do you think it would fit into an existing module? Would it be end user facing, or only for internal use? Thanks! |
@smallsaucepan my suggestion would be that we implement this inside the I have re-implemented the logic inside |
Only thing to consider is geojson-equality is also a dependency of turf-boolean-overlap. So we'd need to put the implementation somewhere we can reuse it internally. Might it fit into turf-helpers or turf-meta? |
Putting it in |
Turf version: 6.5.0/7.0.0a
The way
booleanEqual
check handles precision is incorrect. The following example illustrates the problem:This is incorrect. If two points are equal to a precision of 7, then by definition they must be equal to a precision of 6 as well. The problem here arises from the underlying implementation of
GeojsonEquality
, which uses toFixed to round the coordinates. The problem is that this introduces rounding errors that then cause the equality check to fail:I think the correct behaviour here is not to use
toFixed()
but to check that both values fall within the acceptable precision, e.g., like this:Which likely needs to be fixed upstream in GeojsonEquality (I've filed a bug there too), or that logic replaced entirely in turf.
My suggestion is to drop the dependency on
geojson-equality
and implement it afresh here, which will allow updating the implementation to use typescript - more than happy to make a PR if the maintainers here agree.The text was updated successfully, but these errors were encountered: