Port of Kyle Wilcox's Python implementation of the Vincenty formulation for calculating distances on a spherical earth