예제 #1
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)
 {
     _phi1 = projInfo.GetPhi1();
     if (Math.Abs(_phi1) < EPS10)
     {
         throw new ProjectionException(-23);
     }
     if (Es > 0)
     {
         _en = Proj.Enfn(Es);
         double c;
         _m1 = Proj.Mlfn(_phi1, _am1 = Math.Sin(_phi1),
                         c = Math.Cos(_phi1), _en);
         _am1 = c / (Math.Sqrt(1 - Es * _am1 * _am1) * _am1);
     }
     else
     {
         if (Math.Abs(_phi1) + EPS10 >= HalfPi)
         {
             _cphi1 = 0;
         }
         else
         {
             _cphi1 = 1 / Math.Tan(_phi1);
         }
     }
 }
예제 #2
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 phits   = 0.0;
            bool   isPhits = false;

            if (projInfo.StandardParallel1 != null)
            {
                isPhits = true;
                phits   = projInfo.GetPhi1();
                if (phits >= HalfPi)
                {
                    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);
                }
            }
        }
예제 #3
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)
        {
            const double phi_0 = 0.0;

            _rok = A / K0;
            _rtk = A * K0;
            if (projInfo.Parameters.ContainsKey("alpha"))
            {
                double alpha = projInfo.ParamR("alpha");
                double lonz  = projInfo.ParamR("lonc");
                _singam = Math.Atan(-Math.Cos(alpha) / (-Math.Sin(phi_0) * Math.Sin(alpha))) + lonz;
                _sinphi = Math.Asin(Math.Cos(phi_0) * Math.Sin(alpha));
            }
            else
            {
                double phi_1 = projInfo.GetPhi1();
                double phi_2 = projInfo.GetPhi2();
                double lam_1 = projInfo.ParamR("lon_1");
                double lam_2 = projInfo.ParamR("lon_2");
                _singam = Math.Atan2(Math.Cos(phi_1) * Math.Sin(phi_2) * Math.Cos(lam_1) -
                                     Math.Sin(phi_1) * Math.Cos(phi_2) * Math.Cos(lam_2),
                                     Math.Sin(phi_1) * Math.Cos(phi_2) * Math.Sin(lam_2) -
                                     Math.Cos(phi_1) * Math.Sin(phi_2) * Math.Sin(lam_1));
                _sinphi = Math.Atan(-Math.Cos(_singam - lam_1) / Math.Tan(phi_1));
            }
            Lam0    = _singam + HalfPi;
            _cosphi = Math.Cos(_sinphi);
            _sinphi = Math.Sin(_sinphi);
            _singam = Math.Sin(_singam);
        }
예제 #4
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.StandardParallel1 != null)
     {
         _phi1    = projInfo.GetPhi1();
         _cosphi1 = Math.Cos(_phi1);
         if (_cosphi1 < EPS)
         {
             throw new ProjectionException(22);
         }
     }
     _tanphi1 = Math.Tan(FortPi + 0.5 * _phi1);
 }
예제 #5
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.StandardParallel1 != null)
     {
         _cosphi1 = Math.Cos(projInfo.GetPhi1());
         if (_cosphi1 == 0)
         {
             throw new ProjectionException(22);
         }
     }
     else
     {
         /* 50d28' or acos(2/pi) */
         _cosphi1 = 0.636619772367581343;
     }
 }
        /// <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.GetPhi1();
            double lam1 = projInfo.GetLam1();
            double phi2 = projInfo.GetPhi2();
            double lam2 = projInfo.GetLam2();

            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   = HalfPi - 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;
        }
예제 #7
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)
 {
     Phi1 = projInfo.GetPhi1();
     Phi2 = (Phi1 < 0) ? -HalfPi : HalfPi;
     Setup();
 }
예제 #8
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)
 {
     _cosphi1 = Math.Cos(projInfo.GetPhi1());
 }
예제 #9
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 con;
            double f;
            double d;
            double toRadians = projInfo.GeographicInfo.Unit.Radians;

            _rot = projInfo.ParamI("no_rot") == 0;
            bool azi = projInfo.ParamD("alpha") != 0.0;

            if (azi)
            {
                _lamc  = projInfo.ParamD("lonc") * toRadians;
                _alpha = projInfo.ParamD("alpha") * toRadians;
                if (Math.Abs(_alpha) < Tol ||
                    Math.Abs(Math.Abs(Phi0) - HalfPi) <= Tol ||
                    Math.Abs(Math.Abs(_alpha) - HalfPi) <= Tol)
                {
                    throw new ProjectionException(32);
                }
            }
            else
            {
                _lam1 = projInfo.GetLam1();
                _phi1 = projInfo.GetPhi1();
                _lam2 = projInfo.GetLam2();
                _phi2 = projInfo.GetPhi2();
                if (Math.Abs(_phi1 - _phi2) <= Tol ||
                    (con = Math.Abs(_phi1)) <= Tol ||
                    Math.Abs(con - HalfPi) <= Tol ||
                    Math.Abs(Math.Abs(Phi0) - HalfPi) <= Tol ||
                    Math.Abs(Math.Abs(_phi2) - HalfPi) <= Tol)
                {
                    throw new ProjectionException(33);
                }
            }
            _ellips = Es > 0;
            double com = _ellips ? Math.Sqrt(OneEs) : 1;

            if (Math.Abs(Phi0) > EPS10)
            {
                double sinph0 = Math.Sin(Phi0);
                double cosph0 = Math.Cos(Phi0);
                if (_ellips)
                {
                    con = 1 - Es * sinph0 * sinph0;
                    _bl = cosph0 * cosph0;
                    _bl = Math.Sqrt(1 + Es * _bl * _bl / OneEs);
                    _al = _bl * K0 * com / con;
                    d   = _bl * com / (cosph0 * Math.Sqrt(con));
                }
                else
                {
                    _bl = 1;
                    _al = K0;
                    d   = 1 / cosph0;
                }


                if ((f = d * d - 1) <= 0)
                {
                    f = 0;
                }
                else
                {
                    f = Math.Sqrt(f);
                    if (Phi0 < 0)
                    {
                        f = -f;
                    }
                }
                _el = f += d;
                if (_ellips)
                {
                    _el *= Math.Pow(Proj.Tsfn(Phi0, sinph0, E), _bl);
                }
                else
                {
                    _el *= TSFN0(Phi0);
                }
            }
            else
            {
                _bl = 1 / com;
                _al = K0;
                _el = d = f = 1;
            }
            if (azi)
            {
                _gamma = Math.Asin(Math.Sin(_alpha) / d);
                Lam0   = _lamc - Math.Asin((.5 * (f - 1 / f)) * Math.Tan(_gamma)) / _bl;
            }
            else
            {
                double h;
                double l;
                if (_ellips)
                {
                    h = Math.Pow(Proj.Tsfn(_phi1, Math.Sin(_phi1), E), _bl);
                    l = Math.Pow(Proj.Tsfn(_phi2, Math.Sin(_phi2), E), _bl);
                }
                else
                {
                    h = TSFN0(_phi1);
                    l = TSFN0(_phi2);
                }
                f = _el / h;
                double p = (l - h) / (l + h);
                double j = _el * _el;
                j = (j - l * h) / (j + l * h);
                if ((con = _lam1 - _lam2) < -Math.PI)
                {
                    _lam2 -= Math.PI * 2;
                }
                else if (con > Math.PI)
                {
                    _lam2 += Math.PI * 2;
                }
                Lam0   = Proj.Adjlon(.5 * (_lam1 + _lam2) - Math.Atan(j * Math.Tan(.5 * _bl * (_lam1 - _lam2)) / p) / _bl);
                _gamma = Math.Atan(2 * Math.Sin(_bl * Proj.Adjlon(_lam1 - Lam0)) / (f - 1 / f));
                _alpha = Math.Asin(d * Math.Sin(_gamma));
            }
            _singam = Math.Sin(_gamma);
            _cosgam = Math.Cos(_gamma);
            if (projInfo.ParamI("rot_conv") != 0)
            {
                f = _gamma;
            }
            else
            {
                f = _alpha;
            }
            _sinrot = Math.Sin(f);
            _cosrot = Math.Cos(f);
            if (projInfo.ParamI("no_uoff") != 0)
            {
                _u0 = 0;
            }
            else
            {
                _u0 = Math.Abs(_al * Math.Atan(Math.Sqrt(d * d - 1) / _cosrot) / _bl);
            }
            if (Phi0 < 0)
            {
                _u0 = -_u0;
            }
        }
예제 #10
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)
 {
     _phi1 = projInfo.GetPhi1();
     _phi2 = projInfo.GetPhi2();
     Setup();
 }
예제 #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)
        {
            if (projInfo.StandardParallel1 != null)
            {
                _phits = projInfo.GetPhi1();
            }
            else
            {
                _phits = HalfPi;
            }
            double t;

            if (Math.Abs((t = Math.Abs(Phi0)) - HalfPi) < EPS10)
            {
                _mode = Phi0 < 0 ? Modes.SouthPole : Modes.NorthPole;
            }
            else
            {
                _mode = t > EPS10 ? Modes.Oblique : Modes.Equitorial;
            }
            _phits = Math.Abs(_phits);
            if (Es != 0)
            {
                switch (_mode)
                {
                case Modes.NorthPole:
                case Modes.SouthPole:
                    if (Math.Abs(_phits - HalfPi) < EPS10)
                    {
                        _akm1 = 2 * K0 / Math.Sqrt(Math.Pow(1 + E, 1 + E) * Math.Pow(1 - E, 1 - E));
                    }
                    else
                    {
                        _akm1  = Math.Cos(_phits) / Proj.Tsfn(_phits, t = Math.Sin(_phits), E);
                        t     *= E;
                        _akm1 /= Math.Sqrt(1 - t * t);
                    }
                    break;

                case Modes.Equitorial:
                    _akm1 = 2 * K0;
                    break;

                case Modes.Oblique:
                    t = Math.Sin(Phi0);
                    double x = 2 * Math.Atan(Ssfn(Phi0, t, E)) - HalfPi;
                    t     *= E;
                    _akm1  = 2 * K0 * Math.Cos(Phi0) / Math.Sqrt(1 - t * t);
                    _sinX1 = Math.Sin(x);
                    _cosX1 = Math.Cos(x);
                    break;
                }
            }
            else
            {
                if (_mode == Modes.Oblique || _mode == Modes.Equitorial)
                {
                    if (_mode == Modes.Oblique)
                    {
                        _sinX1 = Math.Sin(Phi0);
                        _cosX1 = Math.Cos(Phi0);
                    }
                    _akm1 = 2 * K0;
                }
                else
                {
                    _akm1 = Math.Abs(_phits - HalfPi) >= EPS10?
                            Math.Cos(_phits) / Math.Tan(FortPi - .5 * _phits) :
                                2 * K0;
                }
            }

            //Judge if north polar or south polar
            if (projInfo.LatitudeOfOrigin == 90)
            {
                ProjectionName = ProjectionNames.North_Polar_Stereographic;
            }
            else if (projInfo.LatitudeOfOrigin == -90)
            {
                ProjectionName = ProjectionNames.South_Polar_Stereographic;
            }
        }
        /// <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;
            double degreesToRadians = projInfo.GeographicInfo.Unit.Radians;

            _phi1 = projInfo.GetPhi1();
            if (projInfo.StandardParallel2 != null)
            {
                _phi2 = projInfo.GetPhi2();
            }
            else
            {
                _phi2 = _phi1;
                _phi1 = projInfo.GetPhi0();
            }
            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;

            _ellipse = projInfo.GeographicInfo.Datum.Spheroid.IsOblate();
            if (_ellipse)
            {
                double m1  = Proj.Msfn(sinphi, cosphi, Es);
                double ml1 = Proj.Tsfn(_phi1, sinphi, E);
                if (secant)
                {
                    sinphi = Math.Sin(_phi2);
                    _n     = Math.Log(m1 / Proj.Msfn(sinphi, Math.Cos(_phi2), Es));
                    _n     = _n / Math.Log(ml1 / Proj.Tsfn(_phi2, sinphi, E));
                }
                _rho0 = m1 * Math.Pow(ml1, -_n) / _n;
                _c    = _rho0;
                if (Math.Abs(Math.Abs(Phi0) - HalfPi) < EPS10)
                {
                    _rho0 = 0;
                }
                else
                {
                    _rho0 *= Math.Pow(Proj.Tsfn(Phi0, Math.Sin(Phi0), E), _n);
                }
            }
            else
            {
                if (secant)
                {
                    _n = Math.Log(cosphi / Math.Cos(_phi2)) /
                         Math.Log(Math.Tan(Math.PI / 4 + .5 * _phi2) /
                                  Math.Tan(Math.PI / 4 + .5 * _phi1));
                    _c = cosphi * Math.Pow(Math.Tan(Math.PI / 4 + .5 * _phi1), _n) / _n;
                }
                if (Math.Abs(Math.Abs(Phi0) - HalfPi) < EPS10)
                {
                    _rho0 = 0;
                }
                else
                {
                    _rho0 = _c * Math.Pow(Math.Tan(Math.PI / 4 + .5 * Phi0), -_n);
                }
            }
        }