distanceTo method
- RaliPosition other
//////////// //////////// Calculate distance to another position in meters
Implementation
// II.D - Utility Methods
///////////////
/// Calculate distance to another position in meters
double distanceTo(RaliPosition other) {
const double earthRadius = 6371000; // meters
final dLat = _toRadians(other.lat - lat);
final dLon = _toRadians(other.lng - lng);
final a =
math.sin(dLat/2) * math.sin(dLat/2) +
math.cos(_toRadians(lat)) * math.cos(_toRadians(other.lat)) *
math.sin(dLon/2) * math.sin(dLon/2);
final c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a));
return earthRadius * c;
}