-
Notifications
You must be signed in to change notification settings - Fork 161
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
geoContains function doesn't seem to handle MultiPolygons #277
Comments
It should work. Please make sure the polygon has the expected winding order. https://observablehq.com/@fil/rewind |
Thanks for the quick response @Fil, I have tested to make sure the polygon is in the expected winding order by using this GeoJSON linter at https://geojsonlint.com/. It will notify you if you need to rewind the data and also the polygon is displaying correctly on my map and I am not seeing this behavior you described:
Here is an example of one of the GeoJSON files that does not seem to be working correctly for me: https://gist.github.com/secondl1ght/a902b36dac2379fead3452af49a77973 The same code I wrote is working for other polygons so your theory does make sense that it would be certain GeoJSONs that I am using causing issues. I thought I had it narrowed down to a multipoly issue because those seemed to be the problem ones from when I looked. Maybe you can see if something is wrong with this Dublin file I shared? Thanks for the help! |
If you rewind it it works |
Wow ok thanks! I guess I should have tested that the polygon drew correctly using D3. I am trying to find your package to use but I don't see it on NPM when I search for |
For now it's just a function in a notebook. https://observablehq.com/@fil/rewind More discussion at #138 |
Thanks, I had a look and it's not super clear to me which part of the code I need to copy over into my app. There is a lot of code there, do I need all of it to complete the rewind that I require? |
Consider fixing the geojson outside your application. If that's not possible, then you should copy 3 cells: geoRewindFeature and its dependencies geoRewindStream and geoProjectSimple. Also make sure you agree with the license (which I had not set yet, now ISC). |
Thanks, is there also a way to check which polygons need to be rewound? I don't want to rewind ones that are already following the required spec. |
I tried fixing the geojsons outside the application using https://geojsonlint.com/ to check for the 'right-hand rule'. But for some reason the problem GeoJSONs are not being picked up with errors on the lint website but they are still not working with D3. |
I am using the
geoContains
function to determine if a point is inside a polygon. It works fine for simple polygons, but it does not seem to work for multi polys. Is this expected behavior? ThanksThe text was updated successfully, but these errors were encountered: