Live data from Hacker News

Fast geodesic measurements in Go

github.com

1–10 of 12 posts

Re: Fast geodesic measurements in Go

#2
The usual way to do this is to convert latitude and longitude to ECEF (Earth centered, Earth fixed) coordinates.[1] This includes the corrections for the Earth being slightly pear-shaped. Then, given 3-element vectors for each point, compute the great circle distance between those points based on simple spherical geometry. This works everywhere, including at the poles.

The FCC formula is based on the old V and H coordinate system that the Bell System used for long distance in the electromechanical era. That was for North America.

There's tons of code out there for this, because every GPS device with a map has to do these calculations.

[1] https://www.mathworks.com/matlabcentral/fileexchange/7942-co...

Re: Fast geodesic measurements in Go

#3
post #2

The usual way to do this is to convert latitude and longitude to ECEF (Earth centered, Earth fixed) coordinates.[1] This includes the corrections for the Earth being slightly pear-shaped. Then, given 3-element vectors for each point, compute the great circle distance between those points based on simple spherical geometry. This works everywhere, including at the poles. The FCC formula is based on the old V and H coor…

It seems like that won't get the "fast": that code does 4 trigonometric functions and a sqrt while the OPs approximation seems to do one cached trig call and then one sqrt for each point.

Re: Fast geodesic measurements in Go

#4
post #2

The usual way to do this is to convert latitude and longitude to ECEF (Earth centered, Earth fixed) coordinates.[1] This includes the corrections for the Earth being slightly pear-shaped. Then, given 3-element vectors for each point, compute the great circle distance between those points based on simple spherical geometry. This works everywhere, including at the poles. The FCC formula is based on the old V and H coor…

The standard LLA to ECEF function uses the WGS84 reference ellipsioid, not pear shaped

Re: Fast geodesic measurements in Go

#6
post #5

Why is the distance function not implemented with Haversine's methods? https://github.com/JamesMilnerUK/cheap-ruler-go/blob/master/... Is there a reason to do this with looping?

The basic answer is speed and accuracy. The approximations implemented here are within 0.1% of the Vincenty method for distances under 500km, which is useful in all kinds of situations. The Haversine formula works for spheres, so it's not as accurate as the Vincenty method for the Earth (a flattened sphere), and it uses more trig functions than this approximation, so it's slower and less accurate for lon/lat distance calculations.

I work with Vlad (the author of the original Javascript https://github.com/mapbox/cheap-ruler). At the time it was created, we were basically just looking for the fastest method to get accurate distance calculations on lon/lat values within "short distances". Vlad found that this approximation fitted our needs well (i.e. the types of distances we typically needed to calculate distances for), and performed the best.

For really accurate measurements, you typically need to use a projection system that's targeted at the area you're measuring in. The earth isn't even a perfect flattened sphere, it's covered in lumps and bumps, so if you need really accurate measurements, you need to use one designed for the bump you're measuring on. Some great illustrations here: http://www.icsm.gov.au/mapping/datums1.html

Re: Fast geodesic measurements in Go

#7
post #2

The usual way to do this is to convert latitude and longitude to ECEF (Earth centered, Earth fixed) coordinates.[1] This includes the corrections for the Earth being slightly pear-shaped. Then, given 3-element vectors for each point, compute the great circle distance between those points based on simple spherical geometry. This works everywhere, including at the poles. The FCC formula is based on the old V and H coor…

Huh, why would that work?
Post reply on HN