package dk.daoas.fulddaekning; public class GeoPoint { public double latitude; public double longitude; public GeoPoint() { //Default } public GeoPoint(double lat, double lng) { //Default latitude=lat; longitude=lng; } public static double beregnAfstand(GeoPoint point1, GeoPoint point2) { //(62.8*sqrt(3.1*(Power(a.Latitude-x.Latitude,2)+Power(a.Longitude-x.Longitude,2)))) as Afstand, double pwrLat = Math.pow(point1.latitude - point2.latitude, 2); double pwrLng = Math.pow(point1.longitude - point2.longitude, 2); return 62.8 * Math.sqrt( 3.1 * (pwrLat + pwrLng) ); } //Latitude (horizonal), longitude(vertical) so // 1 degree latitude is ~ 111320 meters, since the distance between the horizonal lines is always the same // 1 degree longitude is ~111320 meters at equator but gets shorter as we get closer to the poles. // so 1 degree longitude is 64.5 km at denmarks southern point (gedser=54.55,11.95) // and is 59.4km at northern point (skagen = 57.75,10.65) public static double kmToLatitude(double km) { return km / 111.320 ; } public static double kmToLongitude( double km) {//denne er kun ca return km / 62.0; } }