Here is a tutorial that calculates Great Circle Distances on Earth via the entry of Latitude and Longitude. The calculations are not true geodesic calculations and so, we will show the result to the nearest metre. We assume the radius of the Earth is 6371000 metres, but Land Surveyors will tell you this is a pretty simplistic assumption, for the reason that 6371000m could be improved upon, and because the Earth is not a true sphere, and, as is a real issue in the tutorial’s example, no account is taken of the Z co-ordinate, and methinks a walk down from the top of Mt Everest is worth a few metres, and a few beers, maybe?! Of course, if you get into all this, it is a very interesting area, and here is a link to a Wikipedia page that may lead you to further research, if you want more detail.
The Javascript embellishments in this tutorial mainly revolve around:
The use of window.open can sometimes be blocked by web browsers depending on their settings and you can read a bit more about such issues here.
Useful tutorials that helped, and we give thanks to, were:
- Great Circle Distance formulae
- Javascript rounding
- Javascript commas for thousands
- Katmandu positioning via a Google search
Here is a link to a live run. (The way it changed on 1/12/2013 to have a dropdown of placenames as extra functionality will be explained in a tutorial called PHP/Javascript/HTML Geographical Placename Integration Tutorial on 3/12/2013.)
Here is a link to some downloadable PHP programming source code which you may want to rename to distance.php
If this was interesting you may be interested in this too.
17 Responses to PHP/Javascript/HTML Great Circle Distance Tutorial