public double CalculationByDistance(Location Start, Location End)

{

double Radius = 6371;

double lat1 = Start.getLatitude();

double lat2 = End.getLatitude();

double lon1 = Start.getLongitude();

double lon2 = End.getLongitude();

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.atan2(Math.sqrt(a), Math.sqrt(1 - a));

double km = Radius * c;

return km * 1000;

}

{

double Radius = 6371;

double lat1 = Start.getLatitude();

double lat2 = End.getLatitude();

double lon1 = Start.getLongitude();

double lon2 = End.getLongitude();

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.atan2(Math.sqrt(a), Math.sqrt(1 - a));

double km = Radius * c;

return km * 1000;

}

## 2 comments:

distance between two cities of India? Take the help of the city distance search engine. The search engine helps in finding the distance between major cities.

Now you can calculate Distance Between Two Places with the help of distance calculator site are google map.

Post a Comment