Exemplo n.º 1
0
        public override void Initialize()
        {
            base.Initialize();
            double  cosphi, sinphi;
            Boolean secant;

            _phi1 = ProjectionLatitude1;
            _phi2 = ProjectionLatitude2;

            if (Math.Abs(_phi1 + _phi2) < EPS10)
            {
                throw new ProjectionException("-21");
            }
            _n     = sinphi = Math.Sin(_phi1);
            cosphi = Math.Cos(_phi1);
            secant = Math.Abs(_phi1 - _phi2) >= EPS10;
            //spherical = es > 0.0;
            if (!_spherical)
            {
                double ml1, m1;

                if ((_en = ProjectionMath.enfn(_es)) == null)
                {
                    throw new ProjectionException("0");
                }
                m1  = ProjectionMath.msfn(sinphi, cosphi, _es);
                ml1 = ProjectionMath.Qsfn(sinphi, _e, _oneEs);
                if (secant)
                {
                    /* secant cone */
                    double ml2, m2;

                    sinphi = Math.Sin(_phi2);
                    cosphi = Math.Cos(_phi2);
                    m2     = ProjectionMath.msfn(sinphi, cosphi, _es);
                    ml2    = ProjectionMath.Qsfn(sinphi, _e, _oneEs);
                    _n     = (m1 * m1 - m2 * m2) / (ml2 - ml1);
                }
                _ec = 1.0 - .5 * _oneEs * Math.Log((1.0 - _e) /
                                                   (1.0 + _e)) / _e;
                _c    = m1 * m1 + _n * ml1;
                _dd   = 1.0 / _n;
                _rho0 = _dd * Math.Sqrt(_c - _n * ProjectionMath.Qsfn(Math.Sin(ProjectionLatitude),
                                                                      _e, _oneEs));
            }
            else
            {
                if (secant)
                {
                    _n = .5 * (_n + Math.Sin(_phi2));
                }
                _n2   = _n + _n;
                _c    = cosphi * cosphi + _n2 * sinphi;
                _dd   = 1.0 / _n;
                _rho0 = _dd * Math.Sqrt(_c - _n2 * Math.Sin(ProjectionLatitude));
            }
        }
Exemplo n.º 2
0
        public override void Initialize()
        {
            base.Initialize();
            double  cosphi, sinphi;
            Boolean secant;

            if (ProjectionLatitude1 == 0)
            {
                ProjectionLatitude1 = ProjectionLatitude2 = ProjectionLatitude;
            }

            if (Math.Abs(ProjectionLatitude1 + ProjectionLatitude2) < 1e-10)
            {
                throw new ProjectionException();
            }
            n          = sinphi = Math.Sin(ProjectionLatitude1);
            cosphi     = Math.Cos(ProjectionLatitude1);
            secant     = Math.Abs(ProjectionLatitude1 - ProjectionLatitude2) >= 1e-10;
            _spherical = (EccentricitySquared == 0.0);
            if (!Spherical)
            {
                double ml1, m1;

                m1  = ProjectionMath.msfn(sinphi, cosphi, EccentricitySquared);
                ml1 = ProjectionMath.tsfn(ProjectionLatitude1, sinphi, Eccentricity);
                if (secant)
                {
                    n = Math.Log(m1 /
                                 ProjectionMath.msfn(sinphi = Math.Sin(ProjectionLatitude2), Math.Cos(ProjectionLatitude2), EccentricitySquared));
                    n /= Math.Log(ml1 / ProjectionMath.tsfn(ProjectionLatitude2, sinphi, Eccentricity));
                }
                c     = (rho0 = m1 * Math.Pow(ml1, -n) / n);
                rho0 *= (Math.Abs(Math.Abs(ProjectionLatitude) - ProjectionMath.PiHalf) < 1e-10) ? 0.0 :
                        Math.Pow(ProjectionMath.tsfn(ProjectionLatitude, Math.Sin(ProjectionLatitude), Eccentricity), n);
            }
            else
            {
                if (secant)
                {
                    n = Math.Log(cosphi / Math.Cos(ProjectionLatitude2)) /
                        Math.Log(Math.Tan(ProjectionMath.PiFourth + .5 * ProjectionLatitude2) /
                                 Math.Tan(ProjectionMath.PiFourth + .5 * ProjectionLatitude1));
                }
                c    = cosphi * Math.Pow(Math.Tan(ProjectionMath.PiFourth + .5 * ProjectionLatitude1), n) / n;
                rho0 = (Math.Abs(Math.Abs(ProjectionLatitude) - ProjectionMath.PiHalf) < 1e-10) ? 0.0 :
                       c *Math.Pow(Math.Tan(ProjectionMath.PiFourth + .5 * ProjectionLatitude), -n);
            }
        }
Exemplo n.º 3
0
        public override Coordinate Project(double lplam, double lpphi, Coordinate xy)
        {
            if (Spherical)
            {
                double cot, E;

                if (Math.Abs(lpphi) <= Tolerance)
                {
                    xy.X = lplam;
                    xy.Y = _ml0;
                }
                else
                {
                    cot  = 1.0 / Math.Tan(lpphi);
                    xy.X = Math.Sin(E = lplam * Math.Sin(lpphi)) * cot;
                    xy.Y = lpphi - ProjectionLatitude + cot * (1.0 - Math.Cos(E));
                }
            }
            else
            {
                double ms, sp, cp;

                if (Math.Abs(lpphi) <= Tolerance)
                {
                    xy.X = lplam;
                    xy.Y = -_ml0;
                }
                else
                {
                    sp = Math.Sin(lpphi);
                    ms = Math.Abs(cp = Math.Cos(lpphi)) > Tolerance?ProjectionMath.msfn(sp, cp, EccentricitySquared) / sp : 0.0;

                    xy.X = ms * Math.Sin(xy.X *= sp);
                    xy.Y = (ProjectionMath.mlfn(lpphi, sp, cp, _en) - _ml0) + ms * (1.0 - Math.Cos(lplam));
                }
            }
            return(xy);
        }