示例#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));
            }
        }
示例#2
0
        public override Coordinate Project(double lplam, double lpphi, Coordinate coord)
        {
            double rho;

            if ((rho = _c - (!_spherical ? _n * ProjectionMath.Qsfn(Math.Sin(lpphi), _e, _oneEs) : _n2 *Math.Sin(lpphi))) < 0.0)
            {
                throw new ProjectionException("F");
            }
            rho     = _dd * Math.Sqrt(rho);
            coord.X = rho * Math.Sin(lplam *= _n);
            coord.Y = _rho0 - rho * Math.Cos(lplam);
            return(coord);
        }
 public override Coordinate Project(double lam, double phi, Coordinate xy)
 {
     if (Spherical)
     {
         xy.X = ScaleFactor * lam;
         xy.Y = Math.Sin(phi) / ScaleFactor;
     }
     else
     {
         xy.X = ScaleFactor * lam;
         xy.Y = 0.5 * ProjectionMath.Qsfn(Math.Sin(phi), Eccentricity, _oneEs) / ScaleFactor;
     }
     return(xy);
 }
        public override void Initialize()
        {
            base.Initialize();
            double t = TrueScaleLatitude;

            ScaleFactor = Math.Cos(t);
            if (EccentricitySquared != 0)
            {
                t            = Math.Sin(t);
                ScaleFactor /= Math.Sqrt(1.0 - EccentricitySquared * t * t);
                _apa         = ProjectionMath.AuthSet(EccentricitySquared);
                _qp          = ProjectionMath.Qsfn(1.0, Eccentricity, _oneEs);
            }
        }
        public override void Initialize()
        {
            base.Initialize();
            if (Spherical)
            {
                if (_mode == AzimuthalMode.Oblique)
                {
                    _sinphi0 = Math.Sin(ProjectionLatitude);
                    _cosphi0 = Math.Cos(ProjectionLatitude);
                }
            }
            else
            {
                double sinphi;

                _qp  = ProjectionMath.Qsfn(1.0, Eccentricity, _oneEs);
                _mmf = .5 / (1.0 - EccentricitySquared);
                _apa = ProjectionMath.AuthSet(EccentricitySquared);
                switch (_mode)
                {
                case AzimuthalMode.NorthPole:
                case AzimuthalMode.SouthPole:
                    _dd = 1.0;
                    break;

                case AzimuthalMode.Equator:
                    _dd  = 1.0 / (_rq = Math.Sqrt(.5 * _qp));
                    _xmf = 1.0;
                    _ymf = .5 * _qp;
                    break;

                case AzimuthalMode.Oblique:
                    _rq    = Math.Sqrt(.5 * _qp);
                    sinphi = Math.Sin(ProjectionLatitude);
                    _sinb1 = ProjectionMath.Qsfn(sinphi, Eccentricity, _oneEs) / _qp;
                    _cosb1 = Math.Sqrt(1.0 - _sinb1 * _sinb1);
                    _dd    = Math.Cos(ProjectionLatitude) / (Math.Sqrt(1.0 - EccentricitySquared * sinphi * sinphi) *
                                                             _rq * _cosb1);
                    _ymf  = (_xmf = _rq) / _dd;
                    _xmf *= _dd;
                    break;
                }
            }
        }
        public override void Initialize()
        {
            base.Initialize();
            double t;

            phi0 = _projectionLatitude;

            if (Math.Abs((t = Math.Abs(phi0)) - ProjectionMath.PiHalf) < ProjectionMath.EPS10)
            {
                mode = phi0 < 0.0 ? AzimuthalMode.SouthPole : AzimuthalMode.NorthPole;
            }
            else if (Math.Abs(t) < ProjectionMath.EPS10)
            {
                mode = AzimuthalMode.Equator;
            }
            else
            {
                mode = AzimuthalMode.Oblique;
            }
            if (!_spherical)
            {
                double sinphi;

                _e  = Math.Sqrt(_es);
                qp  = ProjectionMath.Qsfn(1.0, _e, _oneEs);
                mmf = 0.5 / (1.0 - _es);
                apa = ProjectionMath.AuthSet(_es);
                switch (mode)
                {
                case AzimuthalMode.NorthPole:
                case AzimuthalMode.SouthPole:
                    dd = 1.0;
                    break;

                case AzimuthalMode.Equator:
                    dd  = 1.0 / (rq = Math.Sqrt(.5 * qp));
                    xmf = 1.0;
                    ymf = .5 * qp;
                    break;

                case AzimuthalMode.Oblique:
                    rq     = Math.Sqrt(.5 * qp);
                    sinphi = Math.Sin(phi0);
                    sinb1  = ProjectionMath.Qsfn(sinphi, _e, _oneEs) / qp;
                    cosb1  = Math.Sqrt(1.0 - sinb1 * sinb1);
                    dd     = Math.Cos(phi0) / (Math.Sqrt(1.0 - _es * sinphi * sinphi) *
                                               rq * cosb1);
                    ymf  = (xmf = rq) / dd;
                    xmf *= dd;
                    break;
                }
            }
            else
            {
                if (mode == AzimuthalMode.Oblique)
                {
                    sinph0 = Math.Sin(phi0);
                    cosph0 = Math.Cos(phi0);
                }
            }
        }
        protected void ProjectNonSpherical(double lplam, double lpphi, Coordinate dst)
        {
            double coslam, sinlam, sinphi, q, sinb = 0.0, cosb = 0.0, b = 0.0;

            coslam = Math.Cos(lplam);
            sinlam = Math.Sin(lplam);
            sinphi = Math.Sin(lpphi);
            q      = ProjectionMath.Qsfn(sinphi, _e, _oneEs);
            if (mode == AzimuthalMode.Oblique || mode == AzimuthalMode.Equator)
            {
                sinb = q / qp;
                cosb = Math.Sqrt(1.0 - sinb * sinb);
            }
            switch (mode)
            {
            case AzimuthalMode.Oblique:
                b = 1.0 + sinb1 * sinb + cosb1 * cosb * coslam;
                break;

            case AzimuthalMode.Equator:
                b = 1.0 + cosb * coslam;
                break;

            case AzimuthalMode.NorthPole:
                b = ProjectionMath.PiHalf + lpphi;
                q = qp - q;
                break;

            case AzimuthalMode.SouthPole:
                b = lpphi - ProjectionMath.PiHalf;
                q = qp + q;
                break;
            }
            if (Math.Abs(b) < EPS10)
            {
                throw new ProjectionException("F");
            }

            switch (mode)
            {
            case AzimuthalMode.Oblique:
            case AzimuthalMode.Equator:
                if (mode == AzimuthalMode.Oblique)
                {
                    dst.Y = ymf * (b = Math.Sqrt(2.0 / b))
                            * (cosb1 * sinb - sinb1 * cosb * coslam);
                }
                else
                {
                    dst.Y = (b = Math.Sqrt(2.0 / (1.0 + cosb * coslam))) * sinb * ymf;
                }
                dst.X = xmf * b * cosb * sinlam;
                break;

            case AzimuthalMode.NorthPole:
            case AzimuthalMode.SouthPole:
                if (q >= 0.0)
                {
                    dst.X = (b = Math.Sqrt(q)) * sinlam;
                    dst.Y = coslam * (mode == AzimuthalMode.SouthPole ? b : -b);
                }
                else
                {
                    dst.X = dst.Y = 0.0;
                }
                break;
            }
        }
        public ProjCoordinate project(double lam, double phi, ProjCoordinate xy)
        {
            if (Spherical)
            {
                double coslam, cosphi, sinphi;

                sinphi = Math.Sin(phi);
                cosphi = Math.Cos(phi);
                coslam = Math.Cos(lam);
                switch (Mode)
                {
                case AzimuthalMode.Equator:
                    xy.Y = 1.0 + cosphi * coslam;
                    if (xy.Y <= EPS10)
                    {
                        throw new ProjectionException();
                    }
                    xy.X  = (xy.Y = Math.Sqrt(2.0 / xy.Y)) * cosphi * Math.Sin(lam);
                    xy.Y *= Mode == AzimuthalMode.Equator
                                ? sinphi
                                :
                            _cosphi0 * sinphi - _sinphi0 * cosphi * coslam;
                    break;

                case AzimuthalMode.Oblique:
                    xy.Y = 1.0
                           + _sinphi0 * sinphi + _cosphi0 * cosphi * coslam;
                    if (xy.Y <= EPS10)
                    {
                        throw new ProjectionException();
                    }
                    xy.X = (xy.Y = Math.Sqrt(2.0 / xy.Y))
                           * cosphi * Math.Sin(lam);
                    xy.Y *= Mode == AzimuthalMode.Equator
                                ? sinphi
                                :
                            _cosphi0 * sinphi - _sinphi0 * cosphi * coslam;
                    break;

                case AzimuthalMode.NorthPole:
                case AzimuthalMode.SouthPole:
                    if (Mode == AzimuthalMode.NorthPole)
                    {
                        coslam = -coslam;
                    }
                    if (Math.Abs(phi + ProjectionLatitude) < EPS10)
                    {
                        throw new ProjectionException();
                    }
                    xy.Y = ProjectionMath.PiFourth - phi * .5;
                    xy.Y = 2.0
                           * (Mode == AzimuthalMode.SouthPole ? Math.Cos(xy.Y) : Math.Sin(xy.Y));
                    xy.X  = xy.Y * Math.Sin(lam);
                    xy.Y *= coslam;
                    break;
                }
            }
            else
            {
                double coslam, sinlam, sinphi, q, sinb = 0, cosb = 0, b = 0;

                coslam = Math.Cos(lam);
                sinlam = Math.Sin(lam);
                sinphi = Math.Sin(phi);
                q      = ProjectionMath.Qsfn(sinphi, Eccentricity, _oneEs);
                if (Mode == AzimuthalMode.Oblique || Mode == AzimuthalMode.Equator)
                {
                    sinb = q / _qp;
                    cosb = Math.Sqrt(1.0 - sinb * sinb);
                }
                switch (Mode)
                {
                case AzimuthalMode.Oblique:
                    b = 1.0 + _sinb1 * sinb + _cosb1 * cosb * coslam;
                    break;

                case AzimuthalMode.Equator:
                    b = 1.0 + cosb * coslam;
                    break;

                case AzimuthalMode.NorthPole:
                    b = ProjectionMath.PiHalf + phi;
                    q = _qp - q;
                    break;

                case AzimuthalMode.SouthPole:
                    b = phi - ProjectionMath.PiHalf;
                    q = _qp + q;
                    break;
                }
                if (Math.Abs(b) < EPS10)
                {
                    throw new ProjectionException();
                }
                switch (Mode)
                {
                case AzimuthalMode.Oblique:
                    xy.Y = _ymf * (b = Math.Sqrt(2.0 / b))
                           * (_cosb1 * sinb - _sinb1 * cosb * coslam);
                    xy.X = _xmf * b * cosb * sinlam;
                    break;

                case AzimuthalMode.Equator:
                    xy.Y = (b = Math.Sqrt(2.0 / (1.0 + cosb * coslam))) * sinb * _ymf;
                    xy.X = _xmf * b * cosb * sinlam;
                    break;

                case AzimuthalMode.NorthPole:
                case AzimuthalMode.SouthPole:
                    if (q >= 0.0)
                    {
                        xy.X = (b = Math.Sqrt(q)) * sinlam;
                        xy.Y = coslam * (Mode == AzimuthalMode.SouthPole ? b : -b);
                    }
                    else
                    {
                        xy.X = xy.Y = 0.0;
                    }
                    break;
                }
            }
            return(xy);
        }