distanceTo method
Calculates the Great-Circle distance in meters to other using the Haversine formula.
Implementation
double distanceTo(GeoCoordinates other) {
const double earthRadiusMeters = 6371000.0;
final double lat1Rad = _toRadians(latitude);
final double lat2Rad = _toRadians(other.latitude);
final double deltaLat = _toRadians(other.latitude - latitude);
final double deltaLon = _toRadians(other.longitude - longitude);
final double a =
math.sin(deltaLat / 2) * math.sin(deltaLat / 2) +
math.cos(lat1Rad) *
math.cos(lat2Rad) *
math.sin(deltaLon / 2) *
math.sin(deltaLon / 2);
final double c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a));
return earthRadiusMeters * c;
}