private double GetLongitudeEllipsoid(double latitude, Point coord1, Point coord2)
        {
            var   inverce = new InverseProblemService(_ellipsoid);
            var   direct  = new DirectProblemService(_ellipsoid);
            Point coordM;
            Point first = coord1, second = coord2;

            do
            {
                var dist = inverce.OrthodromicDistance(first, second);
                coordM = direct.DirectProblem(first, dist.ForwardAzimuth, dist.Distance / 2).Сoordinate;

                if (Math.Abs(latitude - first.LatR) < TOLERANCE)
                {
                    return(first.Longitude);
                }
                if (Math.Abs(latitude - second.LatR) < TOLERANCE)
                {
                    return(second.Longitude);
                }

                if (IsBetween(first.LatR, coordM.LatR, latitude))
                {
                    second = coordM;
                }
                else if (IsBetween(second.LatR, coordM.LatR, latitude))
                {
                    first = coordM;
                }
            } while (Math.Abs(coordM.LatR - latitude) > TOLERANCE);
            return(coordM.Longitude);
        }
示例#2
0
        /// <summary>
        /// А нет ли пересечения полюса?
        /// </summary>
        private bool IsPolisIntersect(Point coord, double aDegree, double s)
        {
            if (!(Math.Abs(aDegree - 360) < TOLERANCE) && !(Math.Abs(aDegree - 180) < TOLERANCE))
            {
                return(false);
            }

            // Расстояние до полюса
            var dist =
                new InverseProblemService(_ellipsoid).OrthodromicDistance(coord,
                                                                          new Point(coord.Longitude, Math.Abs(aDegree - 360) < TOLERANCE ? 90 : -90))
                .Distance;

            return(Math.Abs(dist) < s);
        }