SphericalDistance implements DistanceMeasure { @Override public double distance(double lon, double lat) { final double phi = Math.toRadians(lat); return Math.acos(si * Math.sin(phi) + co * Math.cos(phi) * Math.cos(Math.toRadians(lon - this.lon))); } SphericalDistance(double lon, double lat); @Override double distance(double lon, double lat);  }
@Test public void testDistance() { final DistanceMeasure distanceMeasure = new SphericalDistance(0.0, 0.0); assertEquals(0.0, distanceMeasure.distance(0.0, 0.0), 0.0); assertEquals(1.0, Math.toDegrees(distanceMeasure.distance(1.0, 0.0)), 1.0e-10); assertEquals(1.0, Math.toDegrees(distanceMeasure.distance(0.0, 1.0)), 1.0e-10); }