2 ms·
If you never have to interop with anything ever, then sure. Just do everything correctly. But if you have to pass data around to other services, you have to ass
by nwallin 6y ago
If you never have to interop with anything ever, then sure. Just do everything correctly. But if you have to pass data around to other services, you have to assume that most of them are broken and do things the wrong way. Because most services are broken and do things the wrong way. Not many: most.
Note that "just use great circle arcs" isn't trivial. acos is poorly conditioned when the input is close to 1 or -1, ie, if the two points are close to each other, or on nearly antipodal. So you have to be careful of rounding errors.
"Great circles" assumes a spherical Earth, which it isn't. Consider the shortest arc from (0,0) to (179.9,0). The shortest arc on a sphere will follow the equator, and the solution is unique. The shortest arc on an oblate spheroid will go north or south, and there are two unique solutions.
The math for "geodesic on an ellipsoid" is fairly hairy, and there isn't a closed form solution, just an iterative approximation. [0] And it converges fairly slowly for points that are nearly antipodal. Wikipedia says it takes 130 iterations to converge to a good result for the great circle from (0,0) to (179.5,.5). And keep in mind that's a second order approximation designed for ease of computation on a '70s desk calculator.
Also, even though great circle arcs are wrong on an oblate spheroid Earth, sometimes the arc you want is a great circle arc anyway. Plenty of regulations predate the means to efficiently calculate ellipsoidal geodesics, so use great circle arcs.
"Just use great circle arcs" is a lot like "just store UTC and timezone". I should write up a "falsehoods programmers believe about GIS" but I don't have that kind of time.
[0] https://en.wikipedia.org/wiki/Vincenty%27s_formulae https://en.wikipedia.org/wiki/Vincenty%27s_formulae