top | item 23402020

The 180th Meridian (2016)

25 points| Tomte | 5 years ago |macwright.org | reply

24 comments

order
[+] ThisIsTheWay|5 years ago|reply
It's wild to see something so obscure - yet so relevant to my work - on the front page of HN. The antimeridian problem has plagued the GIS and satellite imaging communities for years, and as the article illustrates, there is no simple solution.
[+] lalaithion|5 years ago|reply
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."

[+] nwallin|5 years ago|reply
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

[+] apendleton|5 years ago|reply
Explaining 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.
[+] Brian_K_White|5 years ago|reply
Indeed 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.

[+] mdswanson|5 years ago|reply
I experienced a little shell shock reading this post. I ran into all of these problems (and more) while building an interactive editor in VR. Selecting things across the "180th meridian", grouping them, aligning them, distributing them, etc.
[+] uj8efdkjfdshf|5 years ago|reply
Why not just internally represent longitude as being between 0 to 360 (mod 360)? This way you won't have a discontinuity in direction when going from one longitude to another.
[+] apendleton|5 years ago|reply
You still have a discontinuity, you've just moved it from the antemeridian (+/-180 degrees) to the prime meridian (0 degrees). The issue isn't the sign, it's the wrapping.

In a lot of ways, this is actually worse. Lots of software can ignore problems posed by antemeridian-crossing geometries because in practice, not that many people encounter them (not many people live there). This would move any problems to the middle of the UK, plus a good chunk of west Africa.

[+] ChuckMcM|5 years ago|reply
I was wondering the same, lat/long pairs are unique so you could map them to a homogenous sphere and then all of the algebra works as expected.
[+] NovemberWhiskey|5 years ago|reply
Honestly I'm with a few of the other posters here: I don't get it.

You obviously can't just project two lat/lon pairs into the plane and then expect to be able to draw a straight line between in the projection coordinate system (x/y) and have the result mean anything, unless those points are extremely close together.

On a Mercator projection that will happen to be a rhumb line, but that's a specific property of that projection.

If you want to know the point halfway along the shortest distance between two lat/lons (and you're prepared to accept the better-but-not-accurate spherical earth model), you can use spherical geometry to determine the mid waypoint along the great circle route.

The futility of thinking otherwise is expressed by the fact that the projection that does map straight lines in the projection to great circles on the globe - i.e. the gnomonic projection - can only show half the world on a map of finite size.

[+] projektfu|5 years ago|reply
Would mapping to a different coordinate system help? Representing the values as sine of spherical coordinates, for example, then converting back for presentation?
[+] cozzyd|5 years ago|reply
asin(x) is multi-valued over the domain of longitude
[+] cbdumas|5 years ago|reply
I may be missing something here but the example given of finding the midpoint between to points across the antimeridian seems at best misleading. The formula given, averaging each coordinate, does not work for spherical coordinates as this post demonstrates. And the correct formula for doing so is never given.
[+] madcaptenor|5 years ago|reply
It works approximately over small distances, though (such as the New Zealand example). Going down the spherical coordinates rabbit hole, so that for example you could find the midpoint on a flight from Los Angeles to Tokyo, would detract from the point of the post.
[+] randyrand|5 years ago|reply
You could also just always specify the left-most point first.

If it should cross the meridian it would be easy to detect.