### Question:
GeoUtils { public static GeoCoordinate getMidpoint(Collection<? extends GeoCoordinate> coordinates) { Validate.notEmpty(coordinates, "locations must not be empty"); int count = coordinates.size(); if (count == 1) { return CollectionHelper.getFirst(coordinates); } double x = 0; double y = 0; double z = 0; for (GeoCoordinate location : coordinates) { double latRad = Math.toRadians(location.getLatitude()); double lngRad = Math.toRadians(location.getLongitude()); x += Math.cos(latRad) * Math.cos(lngRad); y += Math.cos(latRad) * Math.sin(lngRad); z += Math.sin(latRad); } x /= count; y /= count; z /= count; if (Math.abs(x) < 1e-9 || Math.abs(y) < 1e-9 || Math.abs(z) < 1e-9) { return new ImmutableGeoCoordinate(0., 0.); } double lngRad = Math.atan2(y, x); double hypRad = Math.sqrt(x * x + y * y); double latRad = Math.atan2(z, hypRad); double lng = Math.toDegrees(lngRad); double lat = Math.toDegrees(latRad); return new ImmutableGeoCoordinate(lat, lng); } 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 testMidpoint() { GeoCoordinate midpoint = GeoUtils.getMidpoint(coordinates1); assertEquals(49.464867, midpoint.getLatitude(), 0.01); assertEquals(6.7807, midpoint.getLongitude(), 0.01); midpoint = GeoUtils.getMidpoint(coordinates2); assertEquals(69.660652, midpoint.getLatitude(), 0.01); assertEquals(-153.661864, midpoint.getLongitude(), 0.01); midpoint = GeoUtils.getMidpoint(coordinates3); assertEquals(new ImmutableGeoCoordinate(52.52437, 13.41053), midpoint); midpoint = GeoUtils.getMidpoint(coordinates4); assertEquals(47.703117, midpoint.getLatitude(), 0.01); assertEquals(-41.737184, midpoint.getLongitude(), 0.01); }