Created
February 28, 2015 06:57
-
-
Save aaryadev/ca8da82c925539fae9df to your computer and use it in GitHub Desktop.
distance between 2 gps location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static double EARTH_RADIUS = 6378100;// radius of earth in meters | |
public static double gpsdistance (double lat1, double long1, double lat2, double long2) | |
{ | |
//in meters :D | |
double degToRad= Math.PI / 180.0; | |
double phi1 = lat1 * degToRad; | |
double phi2 = lat2 * degToRad; | |
double lam1 = long1 * degToRad; | |
double lam2 = long2 * degToRad; | |
return EARTH_RADIUS * Math.acos( Math.sin(phi1) * Math.sin(phi2) + Math.cos(phi1) * Math.cos(phi2) * Math.cos(lam2 - lam1) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment