### Question:
GeoUtils { public static double approximateDistance(double lat1, double lng1, double lat2, double lng2) { double rlat1 = toRadians(lat1); double rlat2 = toRadians(lat2); double rlng1 = toRadians(lng1); double rlng2 = toRadians(lng2); double x = (rlng2 - rlng1) * Math.cos((rlat1 + rlat2) / 2); double y = (rlat2 - rlat1); return Math.sqrt(x * x + y * y) * EARTH_RADIUS_KM; } private  GeoUtils(); static GeoCoordinate getMidpoint(Collection<? extends GeoCoordinate> coordinates); static GeoCoordinate getCenterOfMinimumDistance(Collection<? extends GeoCoordinate> coordinates); static double parseDms(String dmsString); static double approximateDistance(double lat1, double lng1, double lat2, double lng2); static double approximateDistance(GeoCoordinate c1, GeoCoordinate c2); static double computeDistance(double lat1, double lng1, double lat2, double lng2); static boolean isValidCoordinateRange(double lat, double lng); static void validateCoordinateRange(double lat, double lng); static double normalizeLatitude(double lat); static double normalizeLongitude(double lng); static double getLargestDistance(Collection<? extends GeoCoordinate> coordinates); static final String DMS; static final double EARTH_RADIUS_KM; static final double EARTH_CIRCUMFERENCE_KM; static final double EARTH_MAX_DISTANCE_KM; static final Distance<GeoCoordinate> DISTANCE; }### Answer:
@Test public void testApproximateDistance() { GeoCoordinate c1 = new ImmutableGeoCoordinate(33.662508, -95.547692); GeoCoordinate c2 = new ImmutableGeoCoordinate(48.85341, 2.3488); GeoCoordinate c3 = new ImmutableGeoCoordinate(49.265278, 4.028611); GeoCoordinate c4 = new ImmutableGeoCoordinate(48.858222, 2.2945); double exact = c1.distance(c2); double approximate = GeoUtils.approximateDistance(c1, c2); assertTrue(exact < approximate); assertTrue(approximate < exact * 1.1); exact = c2.distance(c3); approximate = GeoUtils.approximateDistance(c2, c3); assertTrue(exact < approximate); assertTrue(approximate < exact * 1.1); exact = c2.distance(c4); approximate = GeoUtils.approximateDistance(c2, c4); assertTrue(exact < approximate); assertTrue(approximate < exact * 1.1); collector.checkThat(GeoUtils.approximateDistance(c1, c2), Matchers.is(GeoUtils.approximateDistance(c1.getLatitude(), c1.getLongitude(), c2.getLatitude(), c2.getLongitude()))); }
@Test @Ignore public void performanceTest() { GeoCoordinate c1 = new ImmutableGeoCoordinate(33.662508, -95.547692); GeoCoordinate c2 = new ImmutableGeoCoordinate(48.85341, 2.3488); StopWatch stopExact = new StopWatch(); for (int i = 0; i < 10000000; i++) { c1.distance(c2); } System.out.println("Time with exact distance: " + stopExact); StopWatch stopApproximate = new StopWatch(); for (int i = 0; i < 10000000; i++) { GeoUtils.approximateDistance(c1, c2); } System.out.println("Time with approximate distance: " + stopApproximate); System.out.println("Speedup: " + (double)stopExact.getElapsedTime() / stopApproximate.getElapsedTime()); }