/[projects]/dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/GeoPoint.java
ViewVC logotype

Annotation of /dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/GeoPoint.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2222 - (hide annotations) (download)
Sat Sep 20 11:02:26 2014 UTC (9 years, 8 months ago) by torben
File size: 1191 byte(s)
Use a conversion helper instead of hardcoded latitude/longitude spans
1 torben 2211 package dk.daoas.fulddaekning;
2    
3     public class GeoPoint {
4    
5     public double latitude;
6     public double longitude;
7    
8     public GeoPoint() { //Default
9     }
10    
11     public GeoPoint(double lat, double lng) { //Default
12     latitude=lat;
13     longitude=lng;
14     }
15    
16     public static double beregnAfstand(GeoPoint point1, GeoPoint point2) {
17     //(62.8*sqrt(3.1*(Power(a.Latitude-x.Latitude,2)+Power(a.Longitude-x.Longitude,2)))) as Afstand,
18    
19    
20     double pwrLat = Math.pow(point1.latitude - point2.latitude, 2);
21     double pwrLng = Math.pow(point1.longitude - point2.longitude, 2);
22    
23     return 62.8 * Math.sqrt( 3.1 * (pwrLat + pwrLng) );
24     }
25 torben 2222
26    
27     //Latitude (horizonal), longitude(vertical) so
28     // 1 degree latitude is ~ 111320 meters, since the distance between the horizonal lines is always the same
29     // 1 degree longitude is ~111320 meters at equator but gets shorter as we get closer to the poles.
30     // so 1 degree longitude is 64.5 km at denmarks southern point (gedser=54.55,11.95)
31     // and is 59.4km at northern point (skagen = 57.75,10.65)
32    
33     public static double kmToLatitude(double km) {
34     return km / 111.320 ;
35     }
36    
37     public static double kmToLongitude( double km) {//denne er kun ca
38     return km / 62.0;
39     }
40 torben 2211 }

  ViewVC Help
Powered by ViewVC 1.1.20