wasSharp – Diff between revs 14 and 27

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 14 Rev 27
1 /////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // 2 // Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 //
3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // 3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, //
4 // rights of fair usage, the disclaimer and warranty conditions. // 4 // rights of fair usage, the disclaimer and warranty conditions. //
5 /////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////
6   6  
7 using System; 7 using System;
8   8  
9 namespace wasSharp.Geo 9 namespace wasSharp.Geo
10 { 10 {
11 public static class GeodesicExtensions 11 public static class GeodesicExtensions
12 { 12 {
13 public static Distance HaversineDistanceTo(this GeographicCoordinate sourceGeographicCoordinate, 13 public static Distance HaversineDistanceTo(this GeographicCoordinate sourceGeographicCoordinate,
14 GeographicCoordinate targetGeographicCoordinate) 14 GeographicCoordinate targetGeographicCoordinate)
15 { 15 {
16 return HaversineDistanceTo(sourceGeographicCoordinate, targetGeographicCoordinate, DistanceUnits.KILOMETERS); 16 return HaversineDistanceTo(sourceGeographicCoordinate, targetGeographicCoordinate, DistanceUnits.KILOMETERS);
17 } 17 }
18   18  
19 public static Distance HaversineDistanceTo(this GeographicCoordinate sourceGeographicCoordinate, 19 public static Distance HaversineDistanceTo(this GeographicCoordinate sourceGeographicCoordinate,
20 GeographicCoordinate targetGeographicCoordinate, 20 GeographicCoordinate targetGeographicCoordinate,
21 DistanceUnits distanceUnits) 21 DistanceUnits distanceUnits)
22 { 22 {
23 var sourcePhi = Math.PI*sourceGeographicCoordinate.Latitude/180; 23 var sourcePhi = Math.PI * sourceGeographicCoordinate.Latitude / 180;
24 var targetPhi = Math.PI*targetGeographicCoordinate.Latitude/180; 24 var targetPhi = Math.PI * targetGeographicCoordinate.Latitude / 180;
25 var deltaPhi = Math.PI*(targetPhi - sourcePhi)/180; 25 var deltaPhi = Math.PI * (targetPhi - sourcePhi) / 180;
26 var deltaLam = Math.PI*(targetGeographicCoordinate.Longitude - sourceGeographicCoordinate.Longitude)/180; 26 var deltaLam = Math.PI * (targetGeographicCoordinate.Longitude - sourceGeographicCoordinate.Longitude) / 180;
-   27  
-   28 var a = Math.Sin(deltaPhi / 2) * Math.Sin(deltaPhi / 2) +
-   29 Math.Cos(sourcePhi) * Math.Cos(targetPhi) *
27   30 Math.Sin(deltaLam / 2) * Math.Sin(deltaLam / 2);
28   -  
29 var a = Math.Sin(deltaPhi/2)*Math.Sin(deltaPhi/2) + -  
30 Math.Cos(sourcePhi)*Math.Cos(targetPhi)* -  
31 Math.Sin(deltaLam/2)*Math.Sin(deltaLam/2); -  
32   31  
33 var c = 2*Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); 32 var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
34   33  
35 return new Distance(Constants.EARTH_MEAN_RADIUS.Meters*c); -  
36 } 34 return new Distance(Constants.EARTH_MEAN_RADIUS.Meters * c);
-   35 }
37 } 36 }
38 } 37 }
39   38  
40
Generated by GNU Enscript 1.6.5.90.
-  
41   -  
42   -  
43   -