MathExtensionsDistance Method
Calculates the distance between two
GeoLocation objects using the Haversine formula in meters.
Namespace: MobileTrack.Common.ExtensionsAssembly: MobileTrack.Common (in MobileTrack.Common.dll) Version: 0.7+1dadc87dcf0a0f837e19a3ce2deb7c1cd85375d1
public static double Distance(
GeoLocation first,
GeoLocation second
)
- first GeoLocation
- First location
- second GeoLocation
- Second location
DoubleThe distance, in meters. Digits after the point are centimeters.
The output is in meters. If both locations contain an altitude, the altitude will be included.
If none of them or only one of the locations contains an altitude, the altitude will be ignored.
Note: it is recommended to only maximum 2 digits for centimeter precision, for sake
of readability and precision
Note: assuming both locations are accurate and without error, this formula still returns
with an error of up to 0.3%, given the Earth is an oblate spheroid, but we don't take that into account.
Meaning: a distance of 300 meters can have an error of up to 1 meter.