Geolocation distance calculation
To achieve collaboration and interaction between agents in the system, we need to be estimating distances in the environment between agents, but also with points of interest. Using GNSS positions (latitude and longitude), we show how to estimate distances. The library we’re using, GeographicLib, is detailed in the second part.
Calculations with formulas, or online
Using various formulas
Simple formulas can be used to calculate distances between two geographical points known by their latitudes and longitudes, such as: Pythagoras, the law of sines, haversine. Examples are given here.
Here’s another method and detailed calculations from IGN, to obtain the distance between two known points in longitude and latitude on a sphere, available here.
On a website
Here’s a site to calculate the distance between two geographic coordinates using the Vincenty formula, here.
GeographicLib library (recommended)
Available in C++, Python and other languages, the GeographicLib library solves two well-known geodesic problems. The Python library is downloadable in Python, and a documentation is also available, containing some examples.
Here are the two functions for solving the two main problems:
The
inversefunction, to calculate the distance between 2 points.The
directfunction, to find a point B from a point A, a direction and an angle.
For your information, this package has been taken over by a well-known Python library, GeoPy.