Is there an easy way to check if a cell is inside a LatLngPoly? #927
-
I'm trying to match a list of cells to their corresponding polygon. My current approach: I converted the geojson to multilatlngpoly.
I was wondering if there's a better approach than what I'm doing. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you want to check containment of an individual cell within a polygon, just using If you want full containment or any overlapping containment (with the assumption that the polygon feature details are not smaller than an individual cell), you can use If the set of polygons is relatively static and smaller in number than the set of cells you're testing, then converting the polygons into a list of cells, and converting that into a |
Beta Was this translation helpful? Give feedback.
If you want to check containment of an individual cell within a polygon, just using
cellToLatLng
and then using a normal point-in-polygon call with that point would be equivalent based on howpolygonToCells
generates the set of cells returned.If you want full containment or any overlapping containment (with the assumption that the polygon feature details are not smaller than an individual cell), you can use
cellToBoundary
to get the borders of the cell in question, and then test all of those points with the point-in-polygon algorithm, where full containment requires all points to be in, and any overlap requires at least one.If the set of polygons is relatively static and smaller in numb…