
Fast geodesic measurements in Go - mapsnapps
https://github.com/JamesMilnerUK/cheap-ruler-go
======
Animats
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...](https://www.mathworks.com/matlabcentral/fileexchange/7942-covert-
lat--lon--alt-to-ecef-
cartesian?focused=5062966&tab=function&requestedDomain=www.mathworks.com)

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

------
gravypod
Why is the distance function not implemented with Haversine's methods?

[https://github.com/JamesMilnerUK/cheap-ruler-
go/blob/master/...](https://github.com/JamesMilnerUK/cheap-ruler-
go/blob/master/cheapruler.go#L74)

Is there a reason to do this with looping?

~~~
danpat
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](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](http://www.icsm.gov.au/mapping/datums1.html)

------
jhoechtl
Implementation of Helmert transformation in Go
[https://github.com/the42/cartconvert/blob/master/cartconvert...](https://github.com/the42/cartconvert/blob/master/cartconvert/cartconvert.go#L1009)

------
afpx
Transverse Mercator with an accuracy of a few nanometers

[https://link.springer.com/article/10.1007%2Fs00190-011-0445-...](https://link.springer.com/article/10.1007%2Fs00190-011-0445-3)

------
hamandcheese
It would be great if there were some usage examples in the readme or the
godocs.

~~~
mapsnapps
I'm looking into doing this at the moment. Also would like to add some
benchmarks. I've added an example for distance measurement in the godocs and
in the README.

