Пример #1
0
        public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate coord)
        {
            if (_spherical)
            {
                coord.Y = Math.Asin(Math.Asin(_dd = xyy + ProjectionLatitude) * Math.Cos(xyx));
                coord.X = Math.Atan2(Math.Tan(xyx), Math.Cos(_dd));
            }
            else
            {
                double ph1;

                ph1     = ProjectionMath.inv_mlfn(_m0 + xyy, _es, _en);
                _tn     = Math.Tan(ph1); _t = _tn * _tn;
                _n      = Math.Sin(ph1);
                _r      = 1.0 / (1.0 - _es * _n * _n);
                _n      = Math.Sqrt(_r);
                _r     *= (1.0 - _es) * _n;
                _dd     = xyx / _n;
                _d2     = _dd * _dd;
                coord.Y = ph1 - (_n * _tn / _r) * _d2 *
                          (.5 - (1.0 + 3.0 * _t) * _d2 * C3);
                coord.X = _dd * (1.0 + _t * _d2 *
                                 (-C4 + (1.0 + 3.0 * _t) * _d2 * C5)) / Math.Cos(ph1);
            }
            return(coord);
        }
Пример #2
0
        public override Coordinate ProjectInverse(double x, double y, Coordinate coord)
        {
            if (_spherical)
            {
                double h = Math.Exp(x / _scaleFactor);
                double g = 0.5 * (h - 1.0 / h);
                h       = Math.Cos(_projectionLatitude + y / _scaleFactor);
                coord.Y = ProjectionMath.Asin(Math.Sqrt((1.0 - h * h) / (1.0 + g * g)));
                if (y < 0)
                {
                    coord.Y = -coord.Y;
                }
                coord.X = Math.Atan2(g, h);
            }
            else
            {
                double n, con, cosphi, d, ds, sinphi, t;

                coord.Y = ProjectionMath.inv_mlfn(_ml0 + y / _scaleFactor, _es, _en);
                if (Math.Abs(y) >= ProjectionMath.PiHalf)
                {
                    coord.Y = y < 0.0 ? -ProjectionMath.PiHalf : ProjectionMath.PiHalf;
                    coord.X = 0.0;
                }
                else
                {
                    sinphi   = Math.Sin(coord.Y);
                    cosphi   = Math.Cos(coord.Y);
                    t        = Math.Abs(cosphi) > 1e-10 ? sinphi / cosphi : 0.0;
                    n        = _esp * cosphi * cosphi;
                    d        = x * Math.Sqrt(con = 1.0 - _es * sinphi * sinphi) / _scaleFactor;
                    con     *= t;
                    t       *= t;
                    ds       = d * d;
                    coord.Y -= (con * ds / (1.0 - _es)) * FC2 * (1.0 -
                                                                 ds * FC4 * (5.0 + t * (3.0 - 9.0 * n) + n * (1.0 - 4 * n) -
                                                                             ds * FC6 * (61.0 + t * (90.0 - 252.0 * n +
                                                                                                     45.0 * t) + 46.0 * n
                                                                                         - ds * FC8 * (1385.0 + t * (3633.0 + t * (4095.0 + 1574.0 * t)))
                                                                                         )));
                    coord.X = d * (FC1 -
                                   ds * FC3 * (1.0 + 2.0 * t + n -
                                               ds * FC5 * (5.0 + t * (28.0 + 24.0 * t + 8.0 * n) + 6.0 * n
                                                           - ds * FC7 * (61.0 + t * (662.0 + t * (1320.0 + 720.0 * t)))
                                                           ))) / cosphi;
                }
            }
            return(coord);
        }
Пример #3
0
        public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate coord)
        {
            if (_spherical)
            {
                double rh = ProjectionMath.Distance(xyx, coord.Y = _cphi1 - xyy);
                coord.Y = _cphi1 + _phi1 - rh;
                if (Math.Abs(coord.Y) > ProjectionMath.PiHalf)
                {
                    throw new ProjectionException("I");
                }
                if (Math.Abs(Math.Abs(coord.Y) - ProjectionMath.PiHalf) <= EPS10)
                {
                    coord.X = 0.0;
                }
                else
                {
                    coord.X = rh * Math.Atan2(xyx, xyy) / Math.Cos(coord.Y);
                }
            }
            else
            {
                double s;

                double rh = ProjectionMath.Distance(xyx, coord.Y = _am1 - xyy);
                coord.Y = ProjectionMath.inv_mlfn(_am1 + _m1 - rh, _es, _en);
                if ((s = Math.Abs(coord.Y)) < ProjectionMath.PiHalf)
                {
                    s       = Math.Sin(coord.Y);
                    coord.X = rh * Math.Atan2(xyx, xyy) *
                              Math.Sqrt(1.0 - _es * s * s) / Math.Cos(coord.Y);
                }
                else if (Math.Abs(s - ProjectionMath.PiHalf) <= EPS10)
                {
                    coord.X = 0.0;
                }
                else
                {
                    throw new ProjectionException("I");
                }
            }
            return(coord);
        }
        public override Coordinate ProjectInverse(double x, double y, Coordinate lp)
        {
            if (Spherical)
            {
                double cosc, c_rh, sinc;

                if ((c_rh = ProjectionMath.Distance(x, y)) > Math.PI)
                {
                    if (c_rh - EPS10 > Math.PI)
                    {
                        throw new ProjectionException();
                    }
                    c_rh = Math.PI;
                }
                else if (c_rh < EPS10)
                {
                    lp.Y = ProjectionLatitude;
                    lp.X = 0.0;
                    return(lp);
                }
                if (Mode == AzimuthalMode.Oblique || Mode == AzimuthalMode.Equator)
                {
                    sinc = Math.Sin(c_rh);
                    cosc = Math.Cos(c_rh);
                    if (Mode == AzimuthalMode.Equator)
                    {
                        lp.Y = ProjectionMath.Asin(y * sinc / c_rh);
                        x   *= sinc;
                        y    = cosc * c_rh;
                    }
                    else
                    {
                        lp.Y = ProjectionMath.Asin(cosc * _sinphi0 + y * sinc * _cosphi0 /
                                                   c_rh);
                        y  = (cosc - _sinphi0 * Math.Sin(lp.Y)) * c_rh;
                        x *= sinc * _cosphi0;
                    }
                    lp.X = y == 0.0 ? 0.0 : Math.Atan2(x, y);
                }
                else if (Mode == AzimuthalMode.NorthPole)
                {
                    lp.Y = ProjectionMath.PiHalf - c_rh;
                    lp.X = Math.Atan2(x, -y);
                }
                else
                {
                    lp.Y = c_rh - ProjectionMath.PiHalf;
                    lp.X = Math.Atan2(x, y);
                }
            }
            else
            {
                double c, Az, cosAz, A, B, D, E, F, psi, t;
                int    i;

                if ((c = ProjectionMath.Distance(x, y)) < EPS10)
                {
                    lp.Y = ProjectionLatitude;
                    lp.X = 0.0;
                    return(lp);
                }
                if (Mode == AzimuthalMode.Oblique || Mode == AzimuthalMode.Equator)
                {
                    cosAz = Math.Cos(Az = Math.Atan2(x, y));
                    t     = _cosphi0 * cosAz;
                    B     = EccentricitySquared * t / _oneEs;
                    A     = -B * t;
                    B    *= 3.0 * (1.0 - A) * _sinphi0;
                    D     = c / _n1;
                    E     = D * (1.0 - D * D * (A * (1.0 + A) / 6.0 + B * (1.0 + 3.0 * A) * D / 24.0));
                    F     = 1.0 - E * E * (A / 2.0 + B * E / 6.0);
                    psi   = ProjectionMath.Asin(_sinphi0 * Math.Cos(E) + t * Math.Sin(E));
                    lp.X  = ProjectionMath.Asin(Math.Sin(Az) * Math.Sin(E) / Math.Cos(psi));
                    if ((t = Math.Abs(psi)) < EPS10)
                    {
                        lp.Y = 00.0;
                    }
                    else if (Math.Abs(t - ProjectionMath.PiHalf) < 0.0)
                    {
                        lp.Y = ProjectionMath.PiHalf;
                    }
                    else
                    {
                        lp.Y = Math.Atan((1.0 - EccentricitySquared * F * _sinphi0 / Math.Sin(psi)) * Math.Tan(psi) / _oneEs);
                    }
                }
                else
                {
                    lp.Y = ProjectionMath.inv_mlfn(Mode == AzimuthalMode.NorthPole ? _mp - c : _mp + c, EccentricitySquared, _en);
                    lp.X = Math.Atan2(x, Mode == AzimuthalMode.NorthPole ? -y : y);
                }
            }
            return(lp);
        }