Helper extends ErrorAware { public static double distanceInMetersBetween(double longitude1, double latitude1, double longitude2, double latitude2) { double phi1 = deg2rad(latitude1); double phi2 = deg2rad(latitude2); double lambda1 = deg2rad(longitude1); double lambda2 = deg2rad(longitude2); double dPhi = phi1 - phi2; double dLambda = lambda1 - lambda2; double dRoh = 2 * Math.asin(Math.sqrt( Math.pow(Math.sin(dPhi / 2), 2) + Math.cos(phi1) * Math.cos(phi2) * Math.pow(Math.sin(dLambda / 2), 2) )); double distance = EARTH_RADIUS_METERS * dRoh; return distance; }  static void deleteDir(File file); static long folderSize(File directory); static String getResultString(HttpURLConnection http); static boolean saveUrlToFile(String url, File file); static String doubleTo15DigitString(double d); static AlertDialog.Builder getAlertBuilder(Context context); static boolean setBitmapFromFileOrNull(File file, ImageView imageView); static double metersToDegrees(double distanceInMeters); static int directionFromPositionToPositionAsResourceId(IPosition me, IPosition other); static int directionFromPositionToPositionAsResourceId(
            double fromLongitude, double fromLatitude, double toLongitude, double toLatitude); static double distanceInMetersBetween(double longitude1, double latitude1, double longitude2, double latitude2); static void trustAllConnections(); static int compare(long a , long b); static Map<String, List<String>> splitQuery(String query);  }
@Test public void distanceInMetersBetween() { double delta = 1e-6; double longitude1 = 10.01; double latitude1 = 11.02; double longitude2 = 12.03; double latitude2 = 13.04; double distanceInMetersBetween = Helper.distanceInMetersBetween(longitude1, latitude1, longitude2, latitude2); double expected = 315583.811651; assertEquals(expected, distanceInMetersBetween, delta); }
@Test public void testDistanceInMeters(){ assertEquals(Helper.distanceInMetersBetween(0.0,0.0,1.0,1.0), 157955.13999241014, 0); assertEquals(Helper.distanceInMetersBetween(45.58885,12.34521,12.47785,1.12345), 3874247.1015959415, 0); }