Geo { public static double distance(double lat1, double lon1, double lat2, double lon2) { final double lat1r = Math.toRadians(lat1); final double lat2r = Math.toRadians(lat2); final double delta_lat = lat2r - lat1r; final double delta_lon = Math.toRadians(lon2 - lon1); final double sin_lat = Math.sin(delta_lat / 2); final double sin_lon = Math.sin(delta_lon / 2); final double a = sin_lat * sin_lat + Math.cos(lat1r) * Math.cos(lat2r) * sin_lon * sin_lon; final double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return R * c; }  static double distance(double lat1, double lon1, double lat2, double lon2); static double fastDistance(double lat1, double lon1, double lat2, double lon2); static double bearing(double lat1, double lon1, double lat2, double lon2); @NonNull static LatLng moveDirection(double latitude, double longitude, double bearing, double distance);  }
@Test public void distance() { assertEquals(distance, Geo.distance(seattle.latitude, seattle.longitude, la.latitude, la.longitude), 0.01); }