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

pointInPolygon does not work if polygon contains pole #28

Open
pwiecz opened this issue Dec 1, 2015 · 2 comments
Open

pointInPolygon does not work if polygon contains pole #28

pwiecz opened this issue Dec 1, 2015 · 2 comments

Comments

@pwiecz
Copy link

pwiecz commented Dec 1, 2015

I don't know if the project is developed any more, but anyway:
If polygon contains pole pointInPolygon does not work.

  1. founding bounding box does not work either
  2. even if we ignore bounding box check it still does not work (always returns false)

I think that polygons crossing 180th meridian may also not work.

@zeke
Copy link

zeke commented Dec 2, 2015

This is a great library, but @maxogden is a busy 🐈 so you might not see a fix here any time soon.

I would take a look at http://turfjs.org/static/docs/module-turf_inside.html -- turf is an awesome library, and is actively maintained my @mapbox folk. Here's a sample of turf.inside in use: https://github.com/zeke/hoods/blob/577719e273fef69685fdd8e056d80926aa50dc4e/index.js#L16-L18

@pwiecz
Copy link
Author

pwiecz commented Dec 2, 2015

Thanks, but unfortunately the turf.inside also does not seem to work for polygons crossing 180th meridian (and I'm pretty sure that it does not handle polygons containing pole as well).
E.g. in the sandbox you've entered you can try using polygon [[179, -1],[-179, -1],[-179, 1],[179, 1],[179, -1]], and for inclusion of points [179.5, 0.5], [-179.5, -0.5] I think they both should be considered to be inside the polygon.
Looking at pretty simple implementation (https://github.com/Turfjs/turf-inside/blob/master/index.js#L94 ) you can see that it only works if spherical polygons are very closely approximated by polygons in cartesian projection.
I'm not very eager to implement my own library for that, but probably I'll have to.
I'll submit an issue to turf-inside as well.

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

No branches or pull requests

2 participants