distanceTo method
Calculates distance in meters to another location using Haversine formula.
Returns the great-circle distance between this location and other.
Implementation
double distanceTo(LocationUpdate other) {
const earthRadiusMeters = 6371000.0;
final dLat = _toRadians(other.latitude - latitude);
final dLon = _toRadians(other.longitude - longitude);
final a =
(math.sin(dLat / 2) * math.sin(dLat / 2)) +
(math.cos(_toRadians(latitude)) *
math.cos(_toRadians(other.latitude)) *
math.sin(dLon / 2) *
math.sin(dLon / 2));
final c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a));
return earthRadiusMeters * c;
}