4 ms·
I don't really see the point of this post. Any two points on the earth are connected by a great circle. The two points divide the great circle into two arcs. T
by lalaithion 6y ago
I don't really see the point of this post.
Any two points on the earth are connected by a great circle. The two points divide the great circle into two arcs. The length of the shorter arc is the distance between them. The midpoint of the two points is half the distance between them along the shorter arc starting from one point.
Are any of the values above particularly expensive to compute? I can't imagine why I'd want to compute the midpoint between two points by averaging their latitudes and longitudes. Not only does it break if it travels over the prime meridian, but it's also just wrong. The post even says that: "But is the midpoint in longitude, latitude correct? In many cases, it isn’t."
- Brian_K_White 6y agoIndeed the difficulty of representing circles and pieces of circles as lines and pieces of lines sounds like a case of "Doctor it hurts when I hit my thumb with this hammer!" However much more complicated the math and logic might be dealing in the actual geometry of circles and patches of spheres, instead of lines and triangles within an arbitrarily bordered x,y grid, It's got to be simply the only way to go? It sounds like "grappling with the difficulty of using 3.0 in place of pi for decades". Of course I do realize that other smart people must have had this same thought, and that there must be some real reason this is actually a problem. But I do not get any sense of what that real problem might be from this article. Everything described here sounds totally avoidable.
- apendleton 6y agoExplaining it in terms of points and distances is an effort at making the content accessible, but the issues arise when you're dealing with complex shapes, which might not be able to be unambiguously represented: given a sequence of points representing a polygon, it will not always the case that the shorter line connecting two points is the intended one, for example. And it's possible to contrive examples where you have two such shapes, where if you assume that each consecutive pair of points signifies an edge that's the shortest possible line between those two points, and then you naively calculate the intersection of those two polygons, you can end up with a situation where your new, intersected polygon (under the same set of assumptions) has lines that suddenly go the other way around the world. It can get really gnarly really fast. As the article suggests, most people just give up and split the polygons into pieces.
- zokier 6y ago> given a sequence of points representing a polygon, it will not always the case that the shorter line connecting two points is the intended one, for example > intersected polygon (under the same set of assumptions) has lines that suddenly go the other way around the world would be really cool to actually see these examples I do not doubt that naive great circle shortest path might fall apart in pathological cases, but I have difficulty understanding why that would be the case. And the article does nothing to explain why this seemingly obvious solution wouldn't work, your comment already was more enlightening.
- NovemberWhiskey 6y agoYour simplest Euclidean polygon is the triangle. Imagine the triangle is defined by the cities of London, Tokyo and New York. Assuming the world is a sphere (which we know it isn't, but it's not disastrously wrong for these purposes), that gives you something that looks like this: http://gc.kls2.com/cgi-bin/gc?PATH=NYC-TYO-LON-NYC http://gc.kls2.com/cgi-bin/gc?PATH=NYC-TYO-LON-NYC The slightly-curved lines represent the shortest distance between those points; the great circle routes. Now take your typical world map (probably a Mercator projection) and draw the same triangle on it using straight lines along the shortest distances on the map. Notice that the triangle on the world map includes within its area a significant chunk of Central Asia and absolutely none of Greenland. Imagine how unsuccessful you would be trying to intersect the world-map triangle with another polygon; it would be completely meaningless.
- zokier 6y agoobviously straight lines on (some) projections are very wonky on a sphere (or geoid), as would be shapes built on those lines. That was not really the question though, the question was that if you have shapes defined by points connected with shortest great circle paths then when (and how) would that fail? Sibling comment already raised the good point that great circles do not work that well on spheroids and other more complex models of Earth, but I got the impression that it was not what apendleton was referring to
- 6y ago
- nwallin 6y agoIf 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
- cozzyd 6y agoIndeed, computing the geodesic is not that simple... the geodesics are not even closed in general on Earth. I always just use GeographicLib (https://geographiclib.sourceforge.io/ https://geographiclib.sourceforge.io/) for this. https://arxiv.org/abs/1102.1215 https://arxiv.org/abs/1102.1215 is a paper by the author on geodesics.