- Timestamp:
- 08/22/12 19:14:33 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Utilities/Utils.cs
r8516 r8520 17 17 18 18 public static double LocationDistance(PointD p1, PointD p2) { 19 return LocationDistance(p1.X, p1.Y, p2.X, p2.Y); 20 } 21 22 // calculates the distance of the 2 given locations in kilometers 23 public static double LocationDistance(double startX, double startY, double endX, double endY) { 19 24 // The Haversine formula 20 25 /* dlon = lon2 - lon1 … … 25 30 */ 26 31 27 double lat1Rad = p1.Y * (Math.PI / 180.0);28 double long1Rad = p1.X * (Math.PI / 180.0);29 double lat2Rad = p2.Y * (Math.PI / 180.0);30 double long2Rad = p2.X * (Math.PI / 180.0);32 double lat1Rad = startY * (Math.PI / 180.0); 33 double long1Rad = startX * (Math.PI / 180.0); 34 double lat2Rad = endY * (Math.PI / 180.0); 35 double long2Rad = endX * (Math.PI / 180.0); 31 36 32 37 double longitude = long2Rad - long1Rad; … … 39 44 double c = 2.0 * Math.Asin(Math.Sqrt(a)); 40 45 41 const double earthRadiusKms = 63 76.5;46 const double earthRadiusKms = 6367.5; 42 47 double distance = earthRadiusKms * c; 43 48
Note: See TracChangeset
for help on using the changeset viewer.