leaflet-pip | point in polygon intersections for leaflet | Dataset library
kandi X-RAY | leaflet-pip Summary
kandi X-RAY | leaflet-pip Summary
point in polygon intersections for leaflet
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of leaflet-pip
leaflet-pip Key Features
leaflet-pip Examples and Code Snippets
Community Discussions
Trending Discussions on leaflet-pip
QUESTION
I am perplexed as to what I am doing wrong here. I have a geoJson object and I am trying to find which feature contains a given point.
When I am using d3.geoContains
I got back the false results, ie those polygons that do not contain the point.
What I do for now is to use point in polygon
from https://mapbox.github.io/leaflet-pip/ which seems to work fine, however I dont know what I am missing with d3.geoContains
. According to the docs it should return true if the object contains the point.
Attached is a simple case where I have 4 squares, two at the bottom row, one next to the other, and the other two at the top row. I am testing to find the polygon containing point [0.7, 0.7] and pip
returns the correct answer, top-right, but d3.geoContains
returns the other three squares.
ANSWER
Answered 2020-Jan-22 at 18:48D3, including d3.geoContains, uses spherical geometry. This is in contrast to almost every other web mapping tool which treat latitude longitude points as Cartesian.
This means every connection between two points in a geographical feature follows great circle distance (which is why it is harder to draw bounding boxes, see here, while other libraries may make it harder to draw great circle arcs, see here).
By using spherical geometry, the antimeridian doesn't cause as many problems, but conversely, winding order matters: are you drawing everywhere except an area of interest or the area of interest itself.
This applies to d3.geoContains: Your polygons are wound in the opposite order as they are supposed to be. Instead of bounding a small box, they bound the rest of the world - which is why you get the opposite outcome as expected.
You have two options: rewind the polygons , for example with turf.js:
QUESTION
I use Mapbox. I have a draggable marker also map is clickable, by click the marker will mover there but I want to alert when marker dragging out of the polygon. and show the message in the form tag.
...ANSWER
Answered 2018-Nov-17 at 12:48Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install leaflet-pip
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page