/// <summary> /// Calculates the distance between two geo-points in kilometers using the Haversine algorithm. /// </summary> /// <param name="point1">The first point.</param> /// <param name="point2">The second point.</param> /// <returns>A double indicating the distance between the points in KM.</returns> public static double GetDistanceKM(LatLon point1, LatLon point2) { double dLat = ToRad(point2.Latitude - point1.Latitude); double dLon = ToRad(point2.Longtitude - point1.Longtitude); double a = Math.Pow(Math.Sin(dLat / 2), 2) + Math.Cos(ToRad(point1.Latitude)) * Math.Cos(ToRad(point2.Latitude)) * Math.Pow(Math.Sin(dLon / 2), 2); double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); double distance = EARTH_RADIUS_KM * c; return distance; }