Пример #1
0
        //public static double GetRadius(double latitude, double radius = GeoGlobal.Earths.RadiusEquatorial)
        //{
        //    latitude = latitude.ToRadians();
        //    var a = GeoGlobal.Earths.RadiusEquatorial;
        //    var b = GeoGlobal.Earths.RadiusPolar;
        //    var e = Math.Pow(b*b/a*a, 1/2);
        //    return a * (1.0 - e * e) / (1.0 - e * 2 * Math.Sin ^ 2(latitude)) ^ (3 / 2);
        //}
        #endregion
        #region Geographic Path

        /// <summary>
        /// Calculates geographic path between two geographic locations on the Great Circle
        /// <para>Using the Spherical law of cosines </para>
        /// </summary>
        /// <param name="origin">origin location in geographic degrees</param>
        /// <param name="destination">destination location in geographic degrees</param>
        /// <param name="interval">interval between consecutive points of the geographic path, in kilometers</param>
        /// <param name="radius">radius of a geographic sphere, in kilometers</param>
        public static GeoPointList GetPathPoints(IGeoLocatable origin, IGeoLocatable destination, double interval = GeoGlobal.Earths.CircumferenceOneDegree, double radius = GeoGlobal.Earths.Radius)
        {
            var path     = new GeoPointList();
            var distance = GeoCalculator.GetDistance(origin, destination);

            if (double.IsNaN(distance.Kilometers))
            {
                return(path);
            }

            if (distance.Kilometers <= interval)
            {
                path.Add(origin.ToGeoPoint());
                path.Add(destination.ToGeoPoint());
            }
            else
            {
                var currentPoint = origin.ToGeoPoint();
                for (double dist = interval; dist <= distance.Kilometers; dist += interval)
                {
                    path.Add(currentPoint);
                    var bearing = GeoCalculator.GetBearing(currentPoint, destination);
                    currentPoint = GeoCalculator.GetDestination(currentPoint, bearing, interval);
                }
                path.Add(destination.ToGeoPoint());
            }
            return(path);
        }
Пример #2
0
        public GeoPath(IGeoLocatable origin, IGeoLocatable destination, double resolution = 2.0)
        {
            Resolution   = resolution;
            _origin      = origin.ToGeoPoint();
            _destination = destination.ToGeoPoint();

            this.ComputePath();
        }
Пример #3
0
        public static GeoPoint GetPathDestination(IGeoLocatable origin, double bearing, double distance, double interval = GeoGlobal.Earths.CircumferenceOneDegree, double radius = GeoGlobal.Earths.Radius)
        {
            var currentPoint = origin.ToGeoPoint();

            //var previousPoint = origin.ToGeoPoint();
            for (double dist = 0; dist <= distance; dist += interval)
            {
                var previousPoint = currentPoint;
                currentPoint = GeoCalculator.GetDestination(currentPoint, bearing, interval);
                bearing      = GeoCalculator.GetBearingFinal(previousPoint, currentPoint);
            }
            return(currentPoint);
        }