I have code which works in India well. This code calculate the approximate distance between two locations. I used the code mentioned below. But If i run this same code in USA. Then for every location updates calculates the different distance. I passed the source and destination latitude and longitude to this function.The app works well in India. But not works in USA. At same place it shows different calculations. Thanks in advance.Any help will be appreciate.
public static double distanceKm(double lat1, double lon1, double lat2, double lon2) {
double lat1Rad = Math.toRadians(lat1);
double lat2Rad = Math.toRadians(lat2);
double deltaLonRad = Math.toRadians(lon2 - lon1);
return Math.acos(Math.sin(lat1Rad) * Math.sin(lat2Rad) + Math.cos(lat1Rad) * Math.cos(lat2Rad)
* Math.cos(deltaLonRad))
* 6371;
}