Skip to content
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

Add optional parameter to disable truncating coordinates to @turf/intersect #1118

Closed
JD-Coder opened this issue Nov 24, 2017 · 6 comments
Closed

Comments

@JD-Coder
Copy link

JD-Coder commented Nov 24, 2017

I've noticed that most turf.js transform functions return highly precise geometries, but I'm having trouble with the intersect function only returning six decimal points of precision. Consider these polygons:

var poly1 = turf.polygon([[
[0.555555555555555, 0.555555555555555],
[2.555555555555555, 0.555555555555555],
[2.555555555555555, 1.555555555555555],
[0.555555555555555, 1.555555555555555],
[0.555555555555555, 0.555555555555555]
]]);
var poly1 = turf.polygon([[
[1.555555555555555, 0.555555555555555],
[3.555555555555555, 0.555555555555555],
[3.555555555555555, 1.555555555555555],
[1.555555555555555, 1.555555555555555],
[1.555555555555555, 0.555555555555555]
]]);

turf.difference(poly1, poly2) will result in this:

[[
[1.555555555555555, 0.555555555555555],
[0.555555555555555, 0.555555555555555],
[0.555555555555555, 1.555555555555555],
[1.555555555555555, 1.555555555555555],
[1.555555555555555, 0.555555555555555]
]]

while turf.intersect(poly1, poly2) will result in this:

[[
[2.555556, 0.555556],
[1.555556, 0.555556],
[1.555556, 1.555556],
[2.555556, 1.555556],
[2.555556, 0.555556]
]]

Is there a way to get higher precision from this function?

@DenisCarriere
Copy link
Member

@turf/intersect is currently using JSTS in the background and there was a few issues with precision errors that made certain results crash, there's definitely a way we can add an optional parameter to disable the truncating/cleaning coordinates operations.

Related Issue #463 & PR #1004

@DenisCarriere DenisCarriere changed the title Intersect Precision Add optional parameter to disable truncating coordinates to @turf/intersect Nov 24, 2017
@JD-Coder
Copy link
Author

That would be very helpful! Please let me know if you have a chance to add that parameter.

@DenisCarriere
Copy link
Member

That would be very helpful!

👍 Indeed

Please let me know if you have a chance to add that parameter.

Unfortunately I won't have time to implement this, however feel free to push a PR with the proposed feature.

@JD-Coder
Copy link
Author

Thanks for letting me know. I'm working on using JSTS for those transforms and it's looking promising. I appreciate for your help!

@rdfong
Copy link

rdfong commented Nov 13, 2018

Hello, has there been any progress on this? Thanks!

@rowanwins
Copy link
Member

This now no longer happens in v6 onwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants