5

What formula is used by Google Maps for calculating the shortest distance between 2 points (having their Lat, Lng coordinates)? Is it purely based on Haversine? Or is it something different? Is there a mathematical or code implemenatation reference available somewhere?

1

According to http://www.daftlogic.com/projects-google-maps-distance-calculator.htm

You can use the Google Maps Distance Calculator to find out the distance between two or more points anywhere on the earth. In other words, the distance between A and B. Click once on the map to place the first marker and then click again to position the second marker. The mileage between the points will then be displayed. You can also build up a series of locations to find a total distance. An important feature of this distance calculator tool is that is "as the crow flies"...

Calculating the "As the Crow Flies" distance is a matter of using Great Circle formula.

and the Great Circle formula reference is to http://en.wikipedia.org/wiki/Great-circle_distance which does provide various computational formulas.

1

If Google Maps is using the great circle distance then the results are within less than 1% of the geodesic distance for the ellipsoid. If you want to see the true ellipsoidal geodesic path in Google Maps, then visit

http://geographiclib.sourceforge.net/scripts/geod-google.html

This uses Javascript to solve the geodesic problems for an ellipsoid. Wikipedia has a lot of information on ellipsoidal geodesics; see

https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid

0

A straight line distance is the hypotenuse of a triangle. This is good for distances up to 600nm. Great Circle should be used for greater distances.

Latitude coordinates change into miles easily as one minute of latitude = 1 mile.

Longitude is a bit more difficult as the meridians of longitude converge when approaching the poles.

The formula for calculating longitude distance is: "Dep = d.long * Cos Mid.Lat" Dep is the same thing as miles. d.Long is the difference in longitude and expressed in minutes. Mid.Lat the average latitude and expressed in minutes. Then use Pythagoras to work out the hypotenuse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.