This file contains hidden or 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; |
This file contains hidden or 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
| public static double gpsbearing(double lat1, double long1, double lat2, double long2){ | |
| double dLon= Math.toRadians(long2-long1); | |
| double latA=Math.toRadians(lat1); | |
| double latB=Math.toRadians(lat2); | |
| double y = Math.sin(dLon) * Math.cos(latB); | |
| double x = Math.cos(latA) * Math.sin(latB) - Math.sin(latA) * Math.cos(latB) * Math.cos(dLon); | |
| double bearing = Math.toDegrees(Math.atan2(y, x)); | |
| return bearing; | |
| } |
NewerOlder