calculateDistanceBetweenTwoLtnLng static method

double calculateDistanceBetweenTwoLtnLng(
  1. FTxLatLng origin,
  2. FTxLatLng destination
)

Implementation

static double calculateDistanceBetweenTwoLtnLng(
    FTxLatLng origin, FTxLatLng destination) {
  double lat1 = origin.latitude;
  double lon1 = origin.longitude;
  double lat2 = destination.latitude;
  double lon2 = destination.longitude;
  var p = 0.017453292519943295;
  var c = cos;
  var a = 0.5 -
      c((lat2 - lat1) * p) / 2 +
      c(lat1 * p) * c(lat2 * p) * (1 - c((lon2 - lon1) * p)) / 2;
  return 12742 * asin(sqrt(a));
}