예제 #1
0
        /// <summary>
        /// Returns the distance between two locations, ignoring altitude differences. (Haversine formula)
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public static Distance GetFlatDistance(Location from, Location to)
        {
            double dLat = to.Latitude.Radians - from.Latitude.Radians;
            double dLong = to.Longitude.Radians - from.Longitude.Radians;

            double a = Math.Pow(Math.Sin(dLat/2), 2) + (Math.Pow(Math.Sin(dLong/2), 2) * Math.Cos(from.Latitude.Radians) * Math.Cos(to.Latitude.Radians));
            double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));

            Distance RadiusOfEarth = new Distance(RadiusOfEarthKm, Units.Linear.Kilometers);

            return new Distance(c * RadiusOfEarth.Kilometers, Units.Linear.Kilometers);
        }
예제 #2
0
 /// <summary>
 /// Sets the location parameters.
 /// </summary>
 /// <param name="latitude">The angle of latitude.</param>
 /// <param name="longitude">The angle of longitude.</param>
 /// <param name="altitude">The distance of altitude.</param>
 public void setLocation(Angle latitude, Angle longitude, Distance altitude)
 {
     _latitude = latitude;
     _longitude = longitude;
     _altitude = altitude;
 }