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

bug :intersect returns null although two polygones crosses each other #1883

Closed
zx3236114 opened this issue Apr 10, 2020 · 6 comments
Closed
Labels

Comments

@zx3236114
Copy link

zx3236114 commented Apr 10, 2020

var points1 = [[[103.06965947998805, 25.166360955441036],
    [103.06936423825272, 25.16592004745796],
    [103.06997932523149, 25.165407879620716],
    [103.06965947998805, 25.166360955441036]]];
var points2 = [[[103.06882256663783, 25.166667027669433],
    [103.06866395130692, 25.165835431757955],
    [103.06968681685834, 25.165884659624638],
    [103.06972748746756, 25.165870594527007],
    [103.06882256663783, 25.166667027669433]]];
var polygon1 = turf.polygon(points1);
var polygon2 = turf.polygon(points2);

var intersection = turf.intersect(polygon1, polygon2);

turf.intersect returns null but two polygons crosses each other

@stebogit stebogit added the bug label Apr 13, 2020
@stebogit
Copy link
Collaborator

@zx3236114 it looks like the issue is due to coordinates precision. @turf/intersect uses martinez-polygon-clipping, which apparently does have issues with coordinates with a lot of decimals.

Just FYI the package still works, even though you lose some details on your geometries, if you don't exceed (at least in your case) 4 decimals:

Screen Shot 2020-04-13 at 8 44 17 AM

@PawelGIX
Copy link

There is a chance to get more precision? I use this on maps and need precision of 2-3 meters

@daazb001
Copy link

The version 6.2.0-alpha.2 seems to solve the problem. At least for me it works now.

@kbhalerao
Copy link

This is still an issue. One workaround is to do use turf.difference a couple times.
i.e. poly1 - (poly1 - poly2)
This seems to work satisfactorily in my case at the desired precision.

@ZuPerfect
Copy link

Has this bug been fixed? I still have problems with it,Is there a solution?thank you

@rowanwins
Copy link
Member

Resolved in v6.2.0
See https://runkit.com/rowanwins/600514e94c0167001b9de93f

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

No branches or pull requests

7 participants