distanceCoords function Null safety

double distanceCoords(
  1. double latADeg,
  2. double longADeg,
  3. double latBDeg,
  4. double longBDeg,
  5. DistanceCalcMode mode
)

Implementation

double distanceCoords(double latADeg, double longADeg, double latBDeg,
    double longBDeg, DistanceCalcMode mode) {
  switch (mode) {
    case DistanceCalcMode.superFast:
      return distanceCoordsSuperFast(latADeg, longADeg, latBDeg, longBDeg);
    case DistanceCalcMode.equirectangular:
      return distanceCoordsEquirectangular(
          latADeg, longADeg, latBDeg, longBDeg);
    case DistanceCalcMode.haversine:
      return distanceCoordsHaversine(latADeg, longADeg, latBDeg, longBDeg);
    case DistanceCalcMode.lambert:
      return distanceCoordsLambert(latADeg, longADeg, latBDeg, longBDeg);
    case DistanceCalcMode.auto:
      {
        // For points that are relatively close together, choose super fast as
        // it's sufficiently accurate (< 0.5%).
        if (deltaLatitudeAbs(latADeg, latBDeg) <= maxAngleForSuperFastDeg &&
            deltaLongitudeAbs(longADeg, longBDeg) <= maxAngleForSuperFastDeg) {
          return distanceCoords(
              latADeg, longADeg, latBDeg, longBDeg, DistanceCalcMode.superFast);
        } else {
          // For points that are less close together, the chances increase that
          // the much slower haversine does give better accuracy.
          return distanceCoords(
              latADeg, longADeg, latBDeg, longBDeg, DistanceCalcMode.haversine);
        }
      }
  }
}