H { public static double calculationByDistance(LatLng StartP, LatLng EndP) { double lat1 = StartP.latitude; double lat2 = EndP.latitude; double lon1 = StartP.longitude; double lon2 = EndP.longitude; if (lat1 == lat2 && lon1 == lon2) { return .0; } double dLat = Math.toRadians(lat2 - lat1); double dLon = Math.toRadians(lon2 - lon1); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2); double c = 2 * Math.asin(Math.sqrt(a)); return RADIUS * c; }  static String intToHex(int i); static int toInt(byte b); static int toInt(byte[] bytes); static long toLong(byte[] bytes); static String bytesToHex(byte[] bytes); static byte[] reverse4bytes(byte[] b); static byte[] reverse8bytes(byte[] b); static byte[] toReversedBytes(short s); static byte[] toBytes(int i); static byte[] toReversedBytes(int i); static byte[] toBytes(long i); static String getDateFromMs(String ms); static String getDateFromSeconds(String seconds); static byte[] hexStringToByteArray(String s); static int crc8(byte[] b, int start, int len); static float round(float d, int decimalPlace); static double calculationByDistance(LatLng StartP, LatLng EndP); static byte[] concatArray(byte[] a, byte[] b); static String k(String s); static byte[] floatToByteArrayRev(float value); static byte[] floatToByteArray(float value); static float stringToFloat(String s); static String getLogFilename(); static String trunc(@NonNull final String s, final int l); static int dpToPx(int dp, @NonNull Context c); static Bitmap drawableToBitmap(int imgRes, int dpwidth, int dpheight, @NonNull Context c); static Bitmap drawableToBitmap(Drawable d, int dpwidth, int dpheight, @NonNull Context c); final static String NS; final static String RS; final static String S; }
@Test public void calculationByDistance_EltenToKleve_ReturnsDistance() { final double RESULT = 8.250642402104924; final LatLng ELTEN = new LatLng(51.863454, 6.171409); final LatLng KLEVE = new LatLng(51.795390, 6.123602); assertThat(H.calculationByDistance(ELTEN, KLEVE), is(RESULT)); }