Does anyone have a general algorithm for determining the orientation (CW/CCW) of a spherical polygon? Polygon orientation is an easy problem in cartesian space, but much tricker on the sphere. I'm looking for an algorithm that handles ALL cases, including the polygon enclosing a pole, and also straddling the antimeridian.
For example, here's a simple small square polygon that crosses the antimeridian, which will produce the wrong answer if you run it through the cartesian algorithm (coordinates are latitude, longitude):
10, 171 11, -169 -8, -169 -9, 168
The antimeridian discontinuity is a never-ending bugbear.
BTW, no, you can't just naively add 360 to all negative longitudes. That works in this case, but fails for an equivalent polygon straddling the meridian, such as:
12, 11 -9, 11 -8, -12 13, -11