1private double distance(double lat1, double lon1, double lat2, double lon2) {
2 double theta = lon1 - lon2;
3 double dist = Math.sin(deg2rad(lat1))
4 * Math.sin(deg2rad(lat2))
5 + Math.cos(deg2rad(lat1))
6 * Math.cos(deg2rad(lat2))
7 * Math.cos(deg2rad(theta));
8 dist = Math.acos(dist);
9 dist = rad2deg(dist);
10 dist = dist * 60 * 1.1515;
11 return (dist);
12}
13
14private double deg2rad(double deg) {
15 return (deg * Math.PI / 180.0);
16}
17
18private double rad2deg(double rad) {
19 return (rad * 180.0 / Math.PI);
20}
21