@Test public void testGetDistance() { Assert.assertEquals( 69.382, _distanceCalculator.getDistance( _LATITUDE, _LONGITUDE, 34.045886, -118.564861), _DELTA); Assert.assertEquals( 9070.629, _distanceCalculator.getDistance( _LATITUDE, _LONGITUDE, 48.856614, 2.352222), _DELTA); }
public double getDistance( double latitude1, double longitude1, double latitude2, double longitude2) { double latitudeDifference = Math.toRadians(latitude2 - latitude1); double longitudeDifference = Math.toRadians(longitude2 - longitude1); latitude1 = Math.toRadians(latitude1); latitude2 = Math.toRadians(latitude2); double a = Math.pow(Math.sin(latitudeDifference / 2), 2) + Math.pow(Math.sin(longitudeDifference / 2), 2) * Math.cos(latitude1) * Math.cos(latitude2); double c = 2 * Math.asin(Math.sqrt(a)); return _EARTH_RADIUS * c; }
DistanceCalculator { public double getDistance( double latitude1, double longitude1, double latitude2, double longitude2) { double latitudeDifference = Math.toRadians(latitude2 - latitude1); double longitudeDifference = Math.toRadians(longitude2 - longitude1); latitude1 = Math.toRadians(latitude1); latitude2 = Math.toRadians(latitude2); double a = Math.pow(Math.sin(latitudeDifference / 2), 2) + Math.pow(Math.sin(longitudeDifference / 2), 2) * Math.cos(latitude1) * Math.cos(latitude2); double c = 2 * Math.asin(Math.sqrt(a)); return _EARTH_RADIUS * c; } }
DistanceCalculator { public double getDistance( double latitude1, double longitude1, double latitude2, double longitude2) { double latitudeDifference = Math.toRadians(latitude2 - latitude1); double longitudeDifference = Math.toRadians(longitude2 - longitude1); latitude1 = Math.toRadians(latitude1); latitude2 = Math.toRadians(latitude2); double a = Math.pow(Math.sin(latitudeDifference / 2), 2) + Math.pow(Math.sin(longitudeDifference / 2), 2) * Math.cos(latitude1) * Math.cos(latitude2); double c = 2 * Math.asin(Math.sqrt(a)); return _EARTH_RADIUS * c; }  }
DistanceCalculator { public double getDistance( double latitude1, double longitude1, double latitude2, double longitude2) { double latitudeDifference = Math.toRadians(latitude2 - latitude1); double longitudeDifference = Math.toRadians(longitude2 - longitude1); latitude1 = Math.toRadians(latitude1); latitude2 = Math.toRadians(latitude2); double a = Math.pow(Math.sin(latitudeDifference / 2), 2) + Math.pow(Math.sin(longitudeDifference / 2), 2) * Math.cos(latitude1) * Math.cos(latitude2); double c = 2 * Math.asin(Math.sqrt(a)); return _EARTH_RADIUS * c; }  double getDistance(
		double latitude1, double longitude1, double latitude2,
		double longitude2); }
DistanceCalculator { public double getDistance( double latitude1, double longitude1, double latitude2, double longitude2) { double latitudeDifference = Math.toRadians(latitude2 - latitude1); double longitudeDifference = Math.toRadians(longitude2 - longitude1); latitude1 = Math.toRadians(latitude1); latitude2 = Math.toRadians(latitude2); double a = Math.pow(Math.sin(latitudeDifference / 2), 2) + Math.pow(Math.sin(longitudeDifference / 2), 2) * Math.cos(latitude1) * Math.cos(latitude2); double c = 2 * Math.asin(Math.sqrt(a)); return _EARTH_RADIUS * c; }  double getDistance(
		double latitude1, double longitude1, double latitude2,
		double longitude2);  }