distance method

double distance(
  1. YimLocationData other
)

Implementation

double distance(YimLocationData other) {
  double radLat1 = _rad(latitude);
  double radLat2 = _rad(other.latitude);
  double a = radLat1 - radLat2;
  double b = _rad(longitude) - _rad(other.longitude);
  double s = 2 * asin(sqrt(pow(sin(a / 2), 2) + cos(radLat1) * cos(radLat2) * pow(sin(b / 2), 2)));
  s = s * _earthRadius;
  s = (s * 10000).round() / 10000;
  return s;
}