// ==================================================
 // Internal
 private void Init(double lat, double lon, double?elevation, DateTime?timestamp, GeoDirection direction)
 {
     Latitude  = lat;
     Longitude = lon;
     Elevation = elevation;
     Timestamp = timestamp;
     Direction = direction;
 }
예제 #2
0
        public static double DistanceMeters(IGeoLatLon a, IGeoLatLon b)
        {
            var r1   = GeoDirection.DegreesInRadians(a.Latitude);
            var r2   = GeoDirection.DegreesInRadians(b.Latitude);
            var rLat = GeoDirection.DegreesInRadians(b.Latitude - a.Latitude);
            var rLon = GeoDirection.DegreesInRadians(b.Longitude - a.Longitude);

            var c1 = Math.Sin(rLat / 2) * Math.Sin(rLat / 2) + Math.Cos(r1) * Math.Cos(r2) * Math.Sin(rLon / 2) * Math.Sin(rLon / 2);

            return(Math.Atan2(Math.Sqrt(c1), Math.Sqrt(1 - c1)) * 2.0 * _earthRadiusMeter);
        }
 public GeoPosition(decimal lat, decimal lon, decimal?elevation = null, DateTime?timestamp = null, GeoDirection direction = null)
 {
     Init(Convert.ToDouble(lat), Convert.ToDouble(lon), Convert.ToDouble(elevation), timestamp, direction);
 }
 // ==================================================
 // Constructors
 public GeoPosition(double lat, double lon, double?elevation = null, DateTime?timestamp = null, GeoDirection direction = null)
 {
     Init(lat, lon, elevation, timestamp, direction);
 }