algorithm - Point in polygon on Earth globe -
i have list of coordinates (latitude, longitude) define polygon. edges created connecting 2 points arc shortest path between points.
my problem determine whether point (let's call u) lays in or out of polygon. i've been searching web hours looking algorithm complete , won't have flaws. here's want algorithm support , accept (in terms of possible weaknesses):
- the earth may treated perfect sphere (from i've read results in 0.3% precision loss i'm fine with).
- it must correctly handle polygons cross international date line.
- it must correctly handle polygons span on north pole , south pole.
i've decided implement following approach (as modification of ray casting algorithm works 2d scenario).
- i want pick point s (latitude, longitude) outside of polygon.
- for each pair of vertices define single edge, want calculate great circle (let's call g).
- i want calculate great circle pair of points s , u.
- for each great circle defined in point 2, want calculate whether great circle intersects g. if so, i'll check if intersection point lays on edge of polygon.
- i count how many intersections there are, , based on (even/odd) i'll decide if point u inside/outside of polygon.
i know how implement calculations points 2 5, don't have clue how pick starting point s. it's not obvious on 2d plane, since can't pick point left of leftmost point.
any ideas on how can pick point (s) , if approach makes sense , optimal?
thanks input!
Comments
Post a Comment