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):

  1. the earth may treated perfect sphere (from i've read results in 0.3% precision loss i'm fine with).
  2. it must correctly handle polygons cross international date line.
  3. 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).

  1. i want pick point s (latitude, longitude) outside of polygon.
  2. for each pair of vertices define single edge, want calculate great circle (let's call g).
  3. i want calculate great circle pair of points s , u.
  4. 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.
  5. 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

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -