/// <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.Parameters.ContainsKey("bns"))
     {
         return;
     }
     if (projInfo.ParamI("bns") != 0)
     {
         _noskew = true;
     }
 }
Example #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)
        {
            /* read some Parameters,
             * here Latitude Truescale */
            double ts = 0;

            if (projInfo.StandardParallel1 != null)
            {
                ts = projInfo.StandardParallel1.Value * Math.PI / 180;
            }
            _C_x = ts;

            /* we want Bessel as fixed ellipsoid */
            A = 6377397.155;
            E = Math.Sqrt(Es = 0.006674372230614);

            /* if latitude of projection center is not set, use 49d30'N */
            Phi0 = projInfo.LatitudeOfOrigin != null?projInfo.GetPhi0() : 0.863937979737193;


            /* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */
            /* that will correspond to using longitudes relative to greenwich    */
            /* as input and output, instead of lat/long relative to Ferro */
            Lam0 = projInfo.CentralMeridian != null?projInfo.GetLam0() : 0.7417649320975901 - 0.308341501185665;

            /* if scale not set default to 0.9999 */
            K0 = projInfo.CentralMeridian != null?projInfo.GetLam0() : 0.9999;

            if (!projInfo.Parameters.ContainsKey("czech"))
            {
                return;
            }
            int temp = projInfo.ParamI("czech");

            if (temp != 0)
            {
                _czech = true;
            }
        }
Example #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)
        {
            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;
            }
        }