Пример #1
0
        /// <summary>
        /// Gets the elevation from this location to another location (positive = up).
        /// </summary>
        /// <param name="from">This starting point location.</param>
        /// <param name="to">The destination location.</param>
        /// <returns>The distance vector between the two locations.</returns>
        public static double ElevationTo(this ILocation from, ILocation to)
        {
            if (from == null)
            {
                throw new ArgumentNullException(nameof(from), "The from location is null");
            }

            if (to == null)
            {
                throw new ArgumentNullException(nameof(to), "The to location is null");
            }

            return(from.ElevationTo(to, from.HaversineDistanceTo(to)));
        }
Пример #2
0
        /// <summary>
        /// Gets the direction from this location to another location.
        /// </summary>
        /// <param name="from">This starting point location.</param>
        /// <param name="to">The destination location.</param>
        /// <returns>The distance vector between the two locations.</returns>
        public static IDirectionVector DirectionTo(this ILocation from, ILocation to)
        {
            if (from == null)
            {
                throw new ArgumentNullException(nameof(from), "The from location is null");
            }

            if (to == null)
            {
                throw new ArgumentNullException(nameof(to), "The to location is null");
            }

            // computing distance only once and passing it to elevation to optimize performance
            var distance = from.HaversineDistanceTo(to);

            return(new DirectionVector(
                       from,
                       to,
                       distance,
                       from.GreatCircleBearingTo(to),
                       from.ElevationTo(to, distance)));
        }