Ejemplo n.º 1
0
 /// <inheritdoc />
 protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int phi = i * 2 + PHI;
         int lam = i * 2 + LAMBDA;
         int x   = i * 2 + X;
         int y   = i * 2 + Y;
         lp[phi]  = Proj.Aasin(xy[y] / _cY);
         lp[lam]  = xy[x] / (_cX * Math.Cos(lp[phi]));
         lp[phi] += lp[phi];
         lp[phi]  = Proj.Aasin((lp[phi] + Math.Sin(lp[phi])) / _cP);
     }
 }
Ejemplo n.º 2
0
 /// <inheritdoc />
 protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int    phi = i * 2 + PHI;
         int    lam = i * 2 + LAMBDA;
         int    x = i * 2 + X;
         int    y = i * 2 + Y;
         double us, vs;
         if (!_rot)
         {
             us = xy[x];
             vs = xy[y];
         }
         else
         {
             vs = xy[x] * _cosrot - xy[y] * _sinrot;
             us = xy[y] * _cosrot + xy[x] * _sinrot;
         }
         us += _u0;
         double q  = Math.Exp(-_bl * vs / _al);
         double s  = .5 * (q - 1 / q);
         double vl = Math.Sin(_bl * us / _al);
         double ul = 2 * (vl * _cosgam + s * _singam) / (q + 1 / q);
         if (Math.Abs(Math.Abs(ul) - 1) < EPS10)
         {
             lp[lam] = 0;
             lp[phi] = ul < 0 ? -HALF_PI : HALF_PI;
         }
         else
         {
             lp[phi] = _el / Math.Sqrt((1 + ul) / (1 - ul));
             if (_ellips)
             {
                 if ((lp[phi] = Proj.Phi2(Math.Pow(lp[phi], 1 / _bl), E)) == double.MaxValue)
                 {
                     lp[lam] = double.NaN;
                     lp[phi] = double.NaN;
                     continue;
                     //ProjectionException(20);
                 }
             }
             else
             {
                 lp[phi] = HALF_PI - 2 * Math.Atan(lp[phi]);
             }
             lp[lam] = -Math.Atan2((s * _cosgam - vl * _singam), Math.Cos(_bl * us / _al)) / _bl;
         }
     }
 }
Ejemplo n.º 3
0
 /// <inheritdoc />
 protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int    phi = i * 2 + PHI;
         int    lam = i * 2 + LAMBDA;
         int    x   = i * 2 + X;
         int    y   = i * 2 + Y;
         double c;
         lp[phi] = Proj.Aasin(xy[y] / CY);
         lp[lam] = xy[x] / (CX * (1 + (c = Math.Cos(lp[phi]))));
         lp[phi] = Proj.Aasin((lp[phi] + Math.Sin(lp[phi]) * (c + 2)) / CP);
     }
 }
Ejemplo n.º 4
0
        /// <inheritdoc />
        protected override void EllipticalForward(double[] lp, double[] xy, int startIndex, int numPoints)
        {
            for (int i = startIndex; i < startIndex + numPoints; i++)
            {
                int    phi = i * 2 + PHI;
                int    lam = i * 2 + LAMBDA;
                int    x = i * 2 + X;
                int    y = i * 2 + Y;
                double sinX = 0.0, cosX = 0.0;

                double coslam = Math.Cos(lp[lam]);
                double sinlam = Math.Sin(lp[lam]);
                double sinphi = Math.Sin(lp[phi]);
                if (_mode == Modes.Oblique || _mode == Modes.Equitorial)
                {
                    double cx;
                    sinX = Math.Sin(cx = 2 * Math.Atan(Ssfn(lp[phi], sinphi, E)) - HALF_PI);
                    cosX = Math.Cos(cx);
                }
                if (_mode == Modes.Oblique || _mode == Modes.Equitorial)
                {
                    double a;
                    if (_mode == Modes.Oblique)
                    {
                        a = _akm1 / (_cosX1 * (1 + _sinX1 * sinX +
                                               _cosX1 * cosX * coslam));
                        xy[y] = a * (_cosX1 * sinX - _sinX1 * cosX * coslam);
                    }
                    else
                    {
                        a     = 2 * _akm1 / (1 + cosX * coslam);
                        xy[y] = a * sinX;
                    }
                    xy[x] = a * cosX;
                }
                else
                {
                    if (_mode == Modes.SouthPole)
                    {
                        lp[phi] = -lp[phi];
                        coslam  = -coslam;
                        sinphi  = -sinphi;
                    }
                    xy[x] = _akm1 * Proj.Tsfn(lp[phi], sinphi, E);
                    xy[y] = -xy[x] * coslam;
                }
                xy[x] = xy[x] * sinlam;
            }
        }
Ejemplo n.º 5
0
 /// <inheritdoc />
 protected override void EllipticalForward(double[] lp, double[] xy, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int    phi = i * 2 + PHI;
         int    lam = i * 2 + LAMBDA;
         int    x = i * 2 + X;
         int    y = i * 2 + Y;
         double e, c;
         double rh = _am1 + _m1 - Proj.Mlfn(lp[phi], e = Math.Sin(lp[phi]), c = Math.Cos(lp[phi]), _en);
         e     = c * lp[lam] / (rh * Math.Sqrt(1 - Es * e * e));
         xy[x] = rh * Math.Sin(e);
         xy[y] = _am1 - rh * Math.Cos(e);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes the transform using the parameters from the specified coordinate system information
        /// </summary>
        /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param>
        protected override void OnInit(ProjectionInfo projInfo)
        {
            double sinphi;

            if (projInfo.StandardParallel1 != null)
            {
                _phi1 = projInfo.StandardParallel1.Value * Math.PI / 180;
            }
            if (projInfo.StandardParallel2 != null)
            {
                _phi2 = projInfo.StandardParallel2.Value * Math.PI / 180;
            }

            if (Math.Abs(_phi1 + _phi2) < EPS10)
            {
                throw new ProjectionException(-21);
            }
            _en = Proj.Enfn(Es);
            _n  = sinphi = Math.Sin(_phi1);
            double cosphi = Math.Cos(_phi1);
            bool   secant = Math.Abs(_phi1 - _phi2) >= EPS10;

            if (IsElliptical)
            {
                double m1  = Proj.Msfn(sinphi, cosphi, Es);
                double ml1 = Proj.Mlfn(_phi1, sinphi, cosphi, _en);
                if (secant)
                {
                    /* secant cone */
                    sinphi = Math.Sin(_phi2);
                    cosphi = Math.Cos(_phi2);
                    _n     = (m1 - Proj.Msfn(sinphi, cosphi, Es)) /
                             (Proj.Mlfn(_phi2, sinphi, cosphi, _en) - ml1);
                }
                _c    = ml1 + m1 / _n;
                _rho0 = _c - Proj.Mlfn(Phi0, Math.Sin(Phi0),
                                       Math.Cos(Phi0), _en);
            }
            else
            {
                if (secant)
                {
                    _n = (cosphi - Math.Cos(_phi2)) / (_phi2 - _phi1);
                }
                _c    = _phi1 + Math.Cos(_phi1) / _n;
                _rho0 = _c - Phi0;
            }
        }
Ejemplo n.º 7
0
 /// <inheritdoc />
 protected override void OnForward(double[] lp, double[] xy, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int phi = i * 2 + PHI;
         int lam = i * 2 + LAMBDA;
         int x   = i * 2 + X;
         int y   = i * 2 + Y;
         _rho = _c - (IsElliptical
                          ? Proj.Mlfn(lp[phi], Math.Sin(lp[phi]),
                                      Math.Cos(lp[phi]), _en)
                          : lp[phi]);
         xy[x] = _rho * Math.Sin(lp[lam] *= _n);
         xy[y] = _rho0 - _rho * Math.Cos(lp[lam]);
     }
 }
Ejemplo n.º 8
0
 /// <inheritdoc />
 protected override void SphericalInverse(double[] xy, double[] lp, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int phi = i * 2 + PHI;
         int lam = i * 2 + LAMBDA;
         int x   = i * 2 + X;
         int y   = i * 2 + Y;
         xy[y]  /= _cY;
         lp[phi] = _m > 0
                       ? Proj.Aasin((_m * xy[y] + Math.Sin(xy[y])) / _n)
                       :
                   (_n != 1 ? Proj.Aasin(Math.Sin(xy[y]) / _n) : xy[y]);
         lp[lam] = xy[x] / (_cX * (_m + Math.Cos(xy[y])));
     }
 }
Ejemplo n.º 9
0
 private void GuamForward(double[] lp, double[] xy, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int    phi    = i * 2 + PHI;
         int    lam    = i * 2 + LAMBDA;
         int    x      = i * 2 + X;
         int    y      = i * 2 + Y;
         double cosphi = Math.Cos(lp[phi]);
         double sinphi = Math.Sin(lp[phi]);
         double t      = 1 / Math.Sqrt(1 - Es * sinphi * sinphi);
         xy[x] = lp[lam] * cosphi * t;
         xy[y] = Proj.Mlfn(lp[phi], sinphi, cosphi, _en) - _m1 +
                 .5 * lp[lam] * lp[lam] * cosphi * sinphi * t;
     }
 }
Ejemplo n.º 10
0
        /// <inheritdoc />
        protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints)
        {
            for (int i = startIndex; i < startIndex + numPoints; i++)
            {
                int    phi = i * 2 + PHI;
                int    lam = i * 2 + LAMBDA;
                int    x   = i * 2 + X;
                int    y   = i * 2 + Y;
                double cx  = xy[x] / K0;
                double cy  = _rho0 - xy[y] / K0;

                _rho = Math.Sqrt(cx * cx + cy * cy);

                if (_rho != 0.0)
                {
                    if (_n < 0)
                    {
                        _rho = -_rho;
                        cx   = -cx;
                        cy   = -cy;
                    }
                    if (_ellipse)
                    {
                        double temp = Math.Pow(_rho / _c, 1 / _n);
                        lp[phi] = Proj.Phi2(temp, E);
                        if (lp[phi] == double.MaxValue)
                        {
                            lp[lam] = double.NaN;
                            lp[phi] = double.NaN;
                            continue;
                            //throw new ProjectionException(20);
                        }
                    }
                    else
                    {
                        lp[phi] = 2 * Math.Atan(Math.Pow(_c / _rho, 1 / _n)) - HALF_PI;
                    }
                    lp[lam] = Math.Atan2(cx, cy) / _n;
                }
                else
                {
                    lp[lam] = 0;
                    lp[phi] = _n > 0 ? HALF_PI : -HALF_PI;
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes the transform using the parameters from the specified coordinate system information
        /// </summary>
        /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param>
        protected override void OnInit(ProjectionInfo projInfo)
        {
            double phip0;

            _hlfE = 0.5 * E;
            double cp = Math.Cos(Phi0);

            cp *= cp;
            _c  = Math.Sqrt(1 + Es * cp * cp * ROneEs);
            double sp = Math.Sin(Phi0);

            _cosp0 = Math.Cos(phip0 = Proj.Aasin(_sinp0 = sp / _c));
            sp    *= E;
            _k     = Math.Log(Math.Tan(FORT_PI + 0.5 * phip0)) - _c * (
                Math.Log(Math.Tan(FORT_PI + 0.5 * Phi0)) - _hlfE *
                Math.Log((1 + sp) / (1 - sp)));
            _kR = K0 * Math.Sqrt(OneEs) / (1 - sp * sp);
        }
Ejemplo n.º 12
0
 /// <inheritdoc />
 protected override void EllipticalInverse(double[] xy, double[] lp, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int phi = i * 2 + PHI;
         int lam = i * 2 + LAMBDA;
         int x   = i * 2 + X;
         int y   = i * 2 + Y;
         if ((lp[phi] = Proj.Phi2(Math.Exp(-xy[y] / K0), E)) == double.MaxValue)
         {
             lp[lam] = double.NaN;
             lp[phi] = double.NaN;
             continue;
             //throw new ProjectionException(20);
         }
         lp[lam] = xy[x] / K0;
     }
 }
Ejemplo n.º 13
0
 /// <inheritdoc />
 protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int      phi = i * 2 + PHI;
         int      lam = i * 2 + LAMBDA;
         int      x   = i * 2 + X;
         int      y   = i * 2 + Y;
         int      nn;
         double[] p  = new double[2];
         double[] dp = new double[2];
         p[R] = xy[y];
         p[I] = xy[x];
         for (nn = 20; nn > 0; --nn)
         {
             double[] fp;
             double[] f = Proj.Zpolyd1(p, _bf, NBF, out fp);
             f[R] -= xy[y];
             f[I] -= xy[x];
             double den = fp[R] * fp[R] + fp[I] * fp[I];
             p[R] += dp[R] = -(f[R] * fp[R] + f[I] * fp[I]) / den;
             p[I] += dp[I] = -(f[I] * fp[R] - f[R] * fp[I]) / den;
             if ((Math.Abs(dp[R]) + Math.Abs(dp[I])) <= EPS10)
             {
                 break;
             }
         }
         if (nn > 0)
         {
             lp[lam] = p[I];
             lp[phi] = _tphi[NTPHI];
             for (int j = NTPHI - 1; j >= 0; j--)
             {
                 lp[phi] = _tphi[j] + p[R] * lp[phi];
             }
             lp[phi] = Phi0 + p[R] * lp[phi] * SEC5_TO_RAD;
         }
         else
         {
             lp[lam] = lp[phi] = double.MaxValue;
         }
     }
 }
Ejemplo n.º 14
0
 /// <inheritdoc />
 protected override void EllipticalForward(double[] lp, double[] xy, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int phi = i * 2 + PHI;
         int lam = i * 2 + LAMBDA;
         int x   = i * 2 + X;
         int y   = i * 2 + Y;
         if (Math.Abs(Math.Abs(lp[phi]) - HALF_PI) <= EPS10)
         {
             xy[x] = double.NaN;
             xy[y] = double.NaN;
             continue;
             //throw new ProjectionException(20);
         }
         xy[x] = K0 * lp[lam];
         xy[y] = -K0 *Math.Log(Proj.Tsfn(lp[phi], Math.Sin(lp[phi]), E));
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Special factor calculations for a factors calculation
 /// </summary>
 /// <param name="lp">lambda-phi</param>
 /// <param name="p">The projection</param>
 /// <param name="fac">The Factors</param>
 protected override void OnSpecial(double[] lp, ProjectionInfo p, Factors fac)
 {
     if (Math.Abs(Math.Abs(lp[PHI]) - HALF_PI) < EPS10)
     {
         if ((lp[PHI] * _n) <= 0)
         {
             return;
         }
         _rho = 0;
     }
     else
     {
         _rho = _c * (_ellipse ? Math.Pow(Proj.Tsfn(lp[PHI], Math.Sin(lp[PHI]),
                                                    p.GeographicInfo.Datum.Spheroid.Eccentricity()), _n)
                          : Math.Pow(Math.Tan(Math.PI / 4 + .5 * lp[PHI]), -_n));
     }
     fac.Code = AnalyticModes.IsAnalHk | AnalyticModes.IsAnalConv;
     fac.K    = fac.H = p.ScaleFactor * _n * _rho / Proj.Msfn(Math.Sin(lp[PHI]), Math.Cos(lp[PHI]), p.GeographicInfo.Datum.Spheroid.EccentricitySquared());
     fac.Conv = -_n * lp[LAMBDA];
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Internal code handling the setup operations for the transform
        /// </summary>
        protected void Setup()
        {
            double sinphi;

            if (Math.Abs(_phi1 + _phi2) < EPS10)
            {
                throw new ProjectionException(-21);
            }
            _n = sinphi = Math.Sin(_phi1);
            double cosphi = Math.Cos(_phi1);
            bool   secant = Math.Abs(_phi1 - _phi2) >= EPS10;

            if (IsElliptical)
            {
                double m1  = Proj.Msfn(sinphi, cosphi, Es);
                double ml1 = Proj.Qsfn(sinphi, E, OneEs);
                if (secant)
                { /* secant cone */
                    sinphi = Math.Sin(_phi2);
                    cosphi = Math.Cos(_phi2);
                    double m2  = Proj.Msfn(sinphi, cosphi, Es);
                    double ml2 = Proj.Qsfn(sinphi, E, OneEs);
                    _n = (m1 * m1 - m2 * m2) / (ml2 - ml1);
                }
                _ec   = 1 - .5 * OneEs * Math.Log((1 - E) / (1 + E)) / E;
                _c    = m1 * m1 + _n * ml1;
                _dd   = 1 / _n;
                _rho0 = _dd * Math.Sqrt(_c - _n * Proj.Qsfn(Math.Sin(Phi0), E, OneEs));
            }
            else
            {
                if (secant)
                {
                    _n = .5 * (_n + Math.Sin(_phi2));
                }
                _n2   = _n + _n;
                _c    = cosphi * cosphi + _n2 * sinphi;
                _dd   = 1 / _n;
                _rho0 = _dd * Math.Sqrt(_c - _n2 * Math.Sin(Phi0));
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Initializes the transform using the parameters from the specified coordinate system information
        /// </summary>
        /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param>
        protected override void OnInit(ProjectionInfo projInfo)
        {
            if (projInfo.AuxiliarySphereType == AuxiliarySphereType.AuthalicWithConvertedLatitudes)
            {
                throw new NotSupportedException("The conversion which requries latitude conversion to authalic latitudes is not yet supported");
            }
            double phits   = 0.0;
            bool   isPhits = false;

            if (projInfo.StandardParallel1 != null)
            {
                isPhits = true;
                phits   = projInfo.Phi1;
                if (phits >= HALF_PI)
                {
                    throw new ProjectionException(-24);
                }
            }

            if (IsElliptical)
            { /* ellipsoid */
                if (isPhits)
                {
                    K0 = Proj.Msfn(Math.Sin(phits), Math.Cos(phits), Es);
                }
            }
            else
            { /* sphere */
                if (isPhits)
                {
                    K0 = Math.Cos(phits);
                }
            }

            if (projInfo.AuxiliarySphereType == AuxiliarySphereType.AuthalicWithConvertedLatitudes)
            {
                Spheroid sph = new Spheroid(Proj4Ellipsoid.WGS_1984);
                _ae = Math.Acos(sph.PolarRadius / sph.EquatorialRadius);
                _geodeticToAuthalic = true;
            }
        }
Ejemplo n.º 18
0
 /// <inheritdoc />
 protected override void OnForward(double[] lp, double[] xy, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int    phi  = i * 2 + PHI;
         int    lam  = i * 2 + LAMBDA;
         int    x    = i * 2 + X;
         int    y    = i * 2 + Y;
         double sp   = E * Math.Sin(lp[phi]);
         double phip = 2 * Math.Atan(Math.Exp(_c * (
                                                  Math.Log(Math.Tan(FORT_PI + 0.5 * lp[phi])) -
                                                  _hlfE * Math.Log((1 + sp) / (1 - sp)))
                                              + _k)) - HALF_PI;
         double lamp  = _c * lp[lam];
         double cp    = Math.Cos(phip);
         double phipp = Proj.Aasin(_cosp0 * Math.Sin(phip) - _sinp0 * cp * Math.Cos(lamp));
         double lampp = Proj.Aasin(cp * Math.Sin(lamp) / Math.Cos(phipp));
         xy[x] = _kR * lampp;
         xy[y] = _kR * Math.Log(Math.Tan(FORT_PI + 0.5 * phipp));
     }
 }
Ejemplo n.º 19
0
 /// <inheritdoc />
 protected override void EllipticalForward(double[] lp, double[] xy, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int phi = i * 2 + PHI;
         int lam = i * 2 + LAMBDA;
         int x   = i * 2 + X;
         int y   = i * 2 + Y;
         xy[y] = Proj.Mlfn(lp[phi], _n = Math.Sin(lp[phi]), _c = Math.Cos(lp[phi]), _en);
         _n    = 1 / Math.Sqrt(1 - Es * _n * _n);
         _tn   = Math.Tan(lp[phi]);
         _t    = _tn * _tn;
         _a1   = lp[lam] * _c;
         _c   *= Es * _c / (1 - Es);
         _a2   = _a1 * _a1;
         xy[x] = _n * _a1 * (1 - _a2 * _t *
                             (C1 - (8 - _t + 8 * _c) * _a2 * C2));
         xy[y] -= _m0 - _n * _tn * _a2 *
                  (.5 + (5 - _t + 6 * _c) * _a2 * C3);
     }
 }
Ejemplo n.º 20
0
        /// <inheritdoc />
        protected override void EllipticalInverse(double[] xy, double[] lp, int startIndex, int numPoints)
        {
            for (int i = startIndex; i < startIndex + numPoints; i++)
            {
                int    phi = i * 2 + PHI;
                int    lam = i * 2 + LAMBDA;
                int    x   = i * 2 + X;
                int    y   = i * 2 + Y;
                double det;

                /* Setting three components of vector from satellite to position.*/
                double vx = -1.0;
                double vy = Math.Tan(xy[x] / _radiusG1);
                double vz = Math.Tan(xy[y] / _radiusG1) * Proj.Hypot(1.0, vy);

                /* Calculation of terms in cubic equation and determinant.*/
                double a = vz / _radiusP;
                a = vy * vy + a * a + vx * vx;
                double b = 2 * _radiusG * vx;
                if ((det = (b * b) - 4 * a * _c) < 0)
                {
                    lp[lam] = double.NaN;
                    lp[phi] = double.NaN;
                    continue;
                    //throw new ProjectionException(20);
                }

                /* Calculation of three components of vector from satellite to position.*/
                double k = (-b - Math.Sqrt(det)) / (2 * a);
                vx  = _radiusG + k * vx;
                vy *= k;
                vz *= k;

                /* Calculation of longitude and latitude.*/
                lp[lam] = Math.Atan2(vy, vx);
                lp[phi] = Math.Atan(vz * Math.Cos(lp[lam]) / vx);
                lp[phi] = Math.Atan(_radiusPInv2 * Math.Tan(lp[phi]));
            }
        }
Ejemplo n.º 21
0
        private void GuamInverse(double[] xy, double[] lp, int startIndex, int numPoints)
        {
            for (int i = startIndex; i < startIndex + numPoints; i++)
            {
                int    phi = i * 2 + PHI;
                int    lam = i * 2 + LAMBDA;
                int    x   = i * 2 + X;
                int    y   = i * 2 + Y;
                double t   = 0;
                int    j;

                double x2 = 0.5 * xy[x] * xy[x];
                lp[phi] = Phi0;
                for (j = 0; j < 3; ++j)
                {
                    t       = E * Math.Sin(lp[phi]);
                    lp[phi] = Proj.InvMlfn(_m1 + xy[y] -
                                           x2 * Math.Tan(lp[phi]) * (t = Math.Sqrt(1 - t * t)), Es, _en);
                }
                lp[lam] = xy[x] * t / Math.Cos(lp[phi]);
            }
        }
Ejemplo n.º 22
0
 /// <inheritdoc />
 protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int phi = i * 2 + PHI;
         int lam = i * 2 + LAMBDA;
         int x   = i * 2 + X;
         int y   = i * 2 + Y;
         xy[y] /= _cY;
         double c = Math.Cos(lp[phi] = _tanMode ? Math.Atan(xy[y]) : Proj.Aasin(xy[y]));
         lp[phi] /= _cP;
         lp[lam]  = xy[x] / (_cX * Math.Cos(lp[phi] /= _cP));
         if (_tanMode)
         {
             lp[lam] /= c * c;
         }
         else
         {
             lp[lam] *= c;
         }
     }
 }
Ejemplo n.º 23
0
        /// <inheritdoc />
        protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints)
        {
            for (int i = startIndex; i < startIndex + numPoints; i++)
            {
                int phi = i * 2 + PHI;
                int lam = i * 2 + LAMBDA;
                int x   = i * 2 + X;
                int y   = i * 2 + Y;
                int j;

                double phipp = 2 * (Math.Atan(Math.Exp(xy[y] / _kR)) - FORT_PI);
                double lampp = xy[x] / _kR;
                double cp    = Math.Cos(phipp);
                double phip  = Proj.Aasin(_cosp0 * Math.Sin(phipp) + _sinp0 * cp * Math.Cos(lampp));
                double lamp  = Proj.Aasin(cp * Math.Sin(lampp) / Math.Cos(phip));
                double con   = (_k - Math.Log(Math.Tan(FORT_PI + 0.5 * phip))) / _c;
                for (j = NITER; j > 0; --j)
                {
                    double esp  = E * Math.Sin(phip);
                    double delp = (con + Math.Log(Math.Tan(FORT_PI + 0.5 * phip)) - _hlfE *
                                   Math.Log((1 + esp) / (1 - esp))) *
                                  (1 - esp * esp) * Math.Cos(phip) * ROneEs;
                    phip -= delp;
                    if (Math.Abs(delp) < EPS)
                    {
                        break;
                    }
                }
                if (j <= 0)
                {
                    lp[lam] = double.NaN;
                    lp[phi] = double.NaN;
                    continue;
                    //ProjectionException(20);
                }
                lp[phi] = phip;
                lp[lam] = lamp / _c;
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Initializes the transform using the parameters from the specified coordinate system information
        /// </summary>
        /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param>
        protected override void OnInit(ProjectionInfo projInfo)
        {
            double pp;

            /* get control point locations */
            double phi1 = projInfo.Phi1;
            double lam1 = projInfo.Lam1;
            double phi2 = projInfo.Phi2;
            double lam2 = projInfo.Lam2;

            if (phi1 == phi2 && lam1 == lam2)
            {
                throw new ProjectionException(-25);
            }
            Lam0   = Proj.Adjlon(0.5 * (lam1 + lam2));
            _dlam2 = Proj.Adjlon(lam2 - lam1);
            _cp1   = Math.Cos(phi1);
            _cp2   = Math.Cos(phi2);
            _sp1   = Math.Sin(phi1);
            _sp2   = Math.Sin(phi2);
            _cs    = _cp1 * _sp2;
            _sc    = _sp1 * _cp2;
            _ccs   = _cp1 * _cp2 * Math.Sin(_dlam2);
            _z02   = Proj.Aacos(_sp1 * _sp2 + _cp1 * _cp2 * Math.Cos(_dlam2));
            _hz0   = .5 * _z02;
            double a12 = Math.Atan2(_cp2 * Math.Sin(_dlam2),
                                    _cp1 * _sp2 - _sp1 * _cp2 * Math.Cos(_dlam2));

            _ca     = Math.Cos(pp = Proj.Aasin(_cp1 * Math.Sin(a12)));
            _sa     = Math.Sin(pp);
            _lp     = Proj.Adjlon(Math.Atan2(_cp1 * Math.Cos(a12), _sp1) - _hz0);
            _dlam2 *= .5;
            _lamc   = HALF_PI - Math.Atan2(Math.Sin(a12) * _sp1, Math.Cos(a12)) - _dlam2;
            _thz0   = Math.Tan(_hz0);
            _rhshz0 = .5 / Math.Sin(_hz0);
            _r2Z0   = 0.5 / _z02;
            _z02   *= _z02;
        }
Ejemplo n.º 25
0
 /// <inheritdoc />
 protected override void EllipticalInverse(double[] xy, double[] lp, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int    phi = i * 2 + PHI;
         int    lam = i * 2 + LAMBDA;
         int    x   = i * 2 + X;
         int    y   = i * 2 + Y;
         double ph1 = Proj.InvMlfn(_m0 + xy[y], Es, _en);
         _tn     = Math.Tan(ph1);
         _t      = _tn * _tn;
         _n      = Math.Sin(ph1);
         _r      = 1 / (1 - Es * _n * _n);
         _n      = Math.Sqrt(_r);
         _r     *= (1 - Es) * _n;
         _dd     = xy[x] / _n;
         _d2     = _dd * _dd;
         lp[phi] = ph1 - (_n * _tn / _r) * _d2 *
                   (.5 - (1 + 3 * _t) * _d2 * C3);
         lp[lam] = _dd * (1 + _t * _d2 *
                          (-C4 + (1 + 3 * _t) * _d2 * C5)) / Math.Cos(ph1);
     }
 }
Ejemplo n.º 26
0
 /// <inheritdoc />
 protected override void OnForward(double[] lp, double[] xy, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int phi = i * 2 + PHI;
         int lam = i * 2 + LAMBDA;
         int x   = i * 2 + X;
         int y   = i * 2 + Y;
         if (Math.Abs(Math.Abs(lp[phi]) - HALF_PI) < EPS10)
         {
             if (lp[phi] * _n <= 0)
             {
                 xy[x] = double.NaN;
                 xy[y] = double.NaN;
                 continue;
                 //throw new ProjectionException(20);
             }
             _rho = 0;
         }
         else
         {
             double cx;
             if (_ellipse)
             {
                 cx = Math.Pow(Proj.Tsfn(lp[phi], Math.Sin(lp[phi]), E), _n);
             }
             else
             {
                 cx = Math.Pow(Math.Tan(Math.PI / 4 + .5 * lp[phi]), -_n);
             }
             _rho = _c * cx;
         }
         double nLam = lp[lam] * _n;
         xy[x] = K0 * (_rho * Math.Sin(nLam));
         xy[y] = K0 * (_rho0 - _rho * Math.Cos(nLam));
     }
 }
Ejemplo n.º 27
0
        /// <inheritdoc />
        protected override void EllipticalForward(double[] lp, double[] xy, int startIndex, int numPoints)
        {
            for (int i = startIndex; i < startIndex + numPoints; i++)
            {
                int phi = i * 2 + PHI;
                int lam = i * 2 + LAMBDA;
                int x   = i * 2 + X;
                int y   = i * 2 + Y;
                if (Math.Abs(lp[phi]) <= TOL)
                {
                    xy[x] = lp[lam];
                    xy[y] = -_ml0;
                }
                else
                {
                    double sp = Math.Sin(lp[phi]);
                    double cp;
                    double ms = Math.Abs(cp = Math.Cos(lp[phi])) > TOL?Proj.Msfn(sp, cp, Es) / sp : 0;

                    xy[x] = ms * Math.Sin(lp[lam] *= sp);
                    xy[y] = (Proj.Mlfn(lp[phi], sp, cp, _en) - _ml0) + ms * (1 - Math.Cos(lp[lam]));
                }
            }
        }
Ejemplo n.º 28
0
        /// <inheritdoc />
        protected override void OnForward(double[] lp, double[] xy, int startIndex, int numPoints)
        {
            for (int i = startIndex; i < startIndex + numPoints; i++)
            {
                int phi = i * 2 + PHI;
                int lam = i * 2 + LAMBDA;
                int x   = i * 2 + X;
                int y   = i * 2 + Y;

                double[] p = new double[2];

                lp[phi] = (lp[phi] - Phi0) * RAD_TO_SEC5;
                p[R]    = _tpsi[NTPSI];
                for (int j = NTPSI - 1; j >= 0; j--)
                {
                    p[R] = _tpsi[j] + lp[phi] * p[R];
                }
                p[R] *= lp[phi];
                p[I]  = lp[lam];
                p     = Proj.Zpoly1(p, _bf, NBF);
                xy[x] = p[I];
                xy[y] = p[R];
            }
        }
Ejemplo n.º 29
0
 /// <inheritdoc />
 protected override void OnForward(double[] lp, double[] xy, int startIndex, int numPoints)
 {
     for (int i = startIndex; i < startIndex + numPoints; i++)
     {
         int    phi = i * 2 + PHI;
         int    lam = i * 2 + LAMBDA;
         int    x = i * 2 + X;
         int    y = i * 2 + Y;
         double t, dl1, dl2;
         double sp = Math.Sin(lp[phi]);
         double cp = Math.Cos(lp[phi]);
         double z1 = Proj.Aacos(_sp1 * sp + _cp1 * cp * Math.Cos(dl1 = lp[lam] + _dlam2));
         double z2 = Proj.Aacos(_sp2 * sp + _cp2 * cp * Math.Cos(dl2 = lp[lam] - _dlam2));
         z1   *= z1;
         z2   *= z2;
         xy[x] = _r2Z0 * (t = z1 - z2);
         t     = _z02 - t;
         xy[y] = _r2Z0 * Proj.Asqrt(4 * _z02 * z2 - t * t);
         if ((_ccs * sp - cp * (_cs * Math.Sin(dl1) - _sc * Math.Sin(dl2))) < 0)
         {
             xy[y] = -xy[y];
         }
     }
 }
Ejemplo n.º 30
0
        /// <inheritdoc />
        protected override void OnForward(double[] lp, double[] xy, int startIndex, int numPoints)
        {
            for (int i = startIndex; i < startIndex + numPoints; i++)
            {
                int phi = i * 2 + PHI;
                int lam = i * 2 + LAMBDA;
                int x   = i * 2 + X;
                int y   = i * 2 + Y;

                if ((_rho = _c - (IsElliptical
                                      ? _n * Proj.Qsfn(Math.Sin(lp[phi]),
                                                       E, OneEs)
                                      : _n2 *Math.Sin(lp[phi]))) < 0)
                {
                    xy[x] = double.NaN;
                    xy[y] = double.NaN;
                    continue;
                    //throw new ProjectionException(20);
                }
                _rho  = _dd * Math.Sqrt(_rho);
                xy[x] = _rho * Math.Sin(lp[lam] *= _n);
                xy[y] = _rho0 - _rho * Math.Cos(lp[lam]);
            }
        }