distanceCoordsEquirectangular function Null safety

double distanceCoordsEquirectangular(
  1. double latADeg,
  2. double longADeg,
  3. double latBDeg,
  4. double longBDeg
)

Calculates an approximation of the distance in meters between point A at spherical (latitude, longitude) coordinates (latADeg, longADeg) and B at (latBDeg, longBDeg) - all in degrees, using the equirectangular approximation.

The accuracy depends on the distance between the points and the latitude.

Implementation

double distanceCoordsEquirectangular(
    double latADeg, double longADeg, double latBDeg, double longBDeg) {
  final latARad = degToRad(latADeg);
  final latBRad = degToRad(latBDeg);
  final deltaLongRad = degToRad(deltaLongitudeAbs(longADeg, longBDeg));
  final x = deltaLongRad * cos((latARad + latBRad) / 2);
  final y =
      degToRad(deltaLatitudeAbs(latADeg, latBDeg)); // (latBRad - latARad);
  return sqrt(x * x + y * y) * EarthRadiusMeters.mean;
}