示例#1
0
        public override void Initialize()
        {
            base.Initialize();

            double c;

            //_phi1 = pj_param(params, "rlat_1").f;
            _phi1 = ProjectionMath.PiHalf;
            if (Math.Abs(_phi1) < EPS10)
            {
                throw new ProjectionException("-23");
            }
            if (!_spherical)
            {
                _en = ProjectionMath.enfn(_es);
                _m1 = ProjectionMath.mlfn(_phi1, _am1 = Math.Sin(_phi1),
                                          c = Math.Cos(_phi1), _en);
                _am1 = c / (Math.Sqrt(1.0 - _es * _am1 * _am1) * _am1);
            }
            else
            {
                if (Math.Abs(_phi1) + EPS10 >= ProjectionMath.PiHalf)
                {
                    _cphi1 = 0.0;
                }
                else
                {
                    _cphi1 = 1.0 / Math.Tan(_phi1);
                }
            }
        }
示例#2
0
        public override Coordinate Project(double lplam, double lpphi, Coordinate coord)
        {
            if (_spherical)
            {
                double E, rh;

                rh = _cphi1 + _phi1 - lpphi;
                if (Math.Abs(rh) > EPS10)
                {
                    coord.X = rh * Math.Sin(E = lplam * Math.Cos(lpphi) / rh);
                    coord.Y = _cphi1 - rh * Math.Cos(E);
                }
                else
                {
                    coord.X = coord.Y = 0.0;
                }
            }
            else
            {
                double E = Math.Sin(lpphi), c = Math.Cos(lpphi);

                double rh = _am1 + _m1 - ProjectionMath.mlfn(lpphi, E, c, _en);
                E       = c * lplam / (rh * Math.Sqrt(1.0 - _es * E * E));
                coord.X = rh * Math.Sin(E);
                coord.Y = _am1 - rh * Math.Cos(E);
            }
            return(coord);
        }
示例#3
0
 public override void Initialize()
 {
     base.Initialize();
     if (!_spherical)
     {
         if ((_en = ProjectionMath.enfn(_es)) == null)
         {
             throw new ProjectionException();
         }
         _m0 = ProjectionMath.mlfn(ProjectionLatitude, Math.Sin(ProjectionLatitude), Math.Cos(ProjectionLatitude), _en);
     }
 }
示例#4
0
 public override void Initialize()
 {
     base.Initialize();
     if (_spherical)
     {
         _esp = ScaleFactor;
         _ml0 = .5 * _esp;
     }
     else
     {
         _en  = ProjectionMath.enfn(_es);
         _ml0 = ProjectionMath.mlfn(_projectionLatitude, Math.Sin(_projectionLatitude), Math.Cos(_projectionLatitude), _en);
         _esp = _es / (1.0 - _es);
     }
 }
示例#5
0
 public override void Initialize()
 {
     base.Initialize();
     _spherical = true;//FIXME
     if (!Spherical)
     {
         _en = ProjectionMath.enfn(EccentricitySquared);
         if (_en == null)
         {
             throw new ProjectionException("E");
         }
         _ml0 = ProjectionMath.mlfn(ProjectionLatitude, Math.Sin(ProjectionLatitude), Math.Cos(ProjectionLatitude), _en);
     }
     else
     {
         _ml0 = -ProjectionLatitude;
     }
 }
        public override void Initialize()
        {
            base.Initialize();
            if (Math.Abs(Math.Abs(ProjectionLatitude) - ProjectionMath.PiHalf) < EPS10)
            {
                _mode    = ProjectionLatitude < 0.0 ? AzimuthalMode.SouthPole : AzimuthalMode.NorthPole;
                _sinphi0 = ProjectionLatitude < 0.0 ? -1.0 : 1.0;
                _cosphi0 = 0.0;
            }
            else if (Math.Abs(ProjectionLatitude) < EPS10)
            {
                _mode    = AzimuthalMode.Equator;
                _sinphi0 = 0.0;
                _cosphi0 = 1.0;
            }
            else
            {
                _mode    = AzimuthalMode.Oblique;
                _sinphi0 = Math.Sin(ProjectionLatitude);
                _cosphi0 = Math.Cos(ProjectionLatitude);
            }
            if (!Spherical)
            {
                _en = ProjectionMath.enfn(EccentricitySquared);
                switch (Mode)
                {
                case AzimuthalMode.NorthPole:
                    _mp = ProjectionMath.mlfn(ProjectionMath.PiHalf, 1.0, 0.0, _en);
                    break;

                case AzimuthalMode.SouthPole:
                    _mp = ProjectionMath.mlfn(-ProjectionMath.PiHalf, -1.0, 0.0, _en);
                    break;

                case AzimuthalMode.Equator:
                case AzimuthalMode.Oblique:
                    _n1  = 1.0 / Math.Sqrt(1.0 - EccentricitySquared * _sinphi0 * _sinphi0);
                    _g   = _sinphi0 * (_he = Eccentricity / Math.Sqrt(_oneEs));
                    _he *= _cosphi0;
                    break;
                }
            }
        }
示例#7
0
        public override Coordinate Project(double lplam, double lpphi, Coordinate xy)
        {
            if (_spherical)
            {
                double cosphi = Math.Cos(lpphi);
                double b      = cosphi * Math.Sin(lplam);

                xy.X = _ml0 * _scaleFactor * Math.Log((1.0 + b) / (1.0 - b));
                double ty = cosphi * Math.Cos(lplam) / Math.Sqrt(1.0 - b * b);
                ty = ProjectionMath.Acos(ty);
                if (lpphi < 0.0)
                {
                    ty = -ty;
                }
                xy.Y = _esp * (ty - _projectionLatitude);
            }
            else
            {
                double al, als, n, t;
                double sinphi = Math.Sin(lpphi);
                double cosphi = Math.Cos(lpphi);
                t    = Math.Abs(cosphi) > 1e-10 ? sinphi / cosphi : 0.0;
                t   *= t;
                al   = cosphi * lplam;
                als  = al * al;
                al  /= Math.Sqrt(1.0 - _es * sinphi * sinphi);
                n    = _esp * cosphi * cosphi;
                xy.X = _scaleFactor * al * (FC1 +
                                            FC3 * als * (1.0 - t + n +
                                                         FC5 * als * (5.0 + t * (t - 18.0) + n * (14.0 - 58.0 * t)
                                                                      + FC7 * als * (61.0 + t * (t * (179.0 - t) - 479.0))
                                                                      )));
                xy.Y = _scaleFactor * (ProjectionMath.mlfn(lpphi, sinphi, cosphi, _en) - _ml0 +
                                       sinphi * al * lplam * FC2 * (1.0 +
                                                                    FC4 * als * (5.0 - t + n * (9.0 + 4.0 * n) +
                                                                                 FC6 * als * (61.0 + t * (t - 58.0) + n * (270.0 - 330 * t)
                                                                                              + FC8 * als * (1385.0 + t * (t * (543.0 - t) - 3111.0))
                                                                                              ))));
            }
            return(xy);
        }
示例#8
0
 public override Coordinate Project(double lplam, double lpphi, Coordinate xy)
 {
     if (_spherical)
     {
         xy.X = Math.Asin(Math.Cos(lpphi) * Math.Sin(lplam));
         xy.Y = Math.Atan2(Math.Tan(lpphi), Math.Cos(lplam)) - ProjectionLatitude;
     }
     else
     {
         xy.Y = ProjectionMath.mlfn(lpphi, _n = Math.Sin(lpphi), _c = Math.Cos(lpphi), _en);
         _n   = 1.0 / Math.Sqrt(1.0 - _es * _n * _n);
         _tn  = Math.Tan(lpphi); _t = _tn * _tn;
         _a1  = lplam * _c;
         _c  *= _es * _c / (1 - _es);
         _a2  = _a1 * _a1;
         xy.X = _n * _a1 * (1.0 - _a2 * _t *
                            (C1 - (8.0 - _t + 8.0 * _c) * _a2 * C2));
         xy.Y -= _m0 - _n * _tn * _a2 *
                 (.5 + (5.0 - _t + 6.0 * _c) * _a2 * C3);
     }
     return(xy);
 }
示例#9
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);
        }
        public override Coordinate Project(double lam, double phi, Coordinate xy)
        {
            if (Spherical)
            {
                double coslam, cosphi, sinphi;

                sinphi = Math.Sin(phi);
                cosphi = Math.Cos(phi);
                coslam = Math.Cos(lam);
                switch (Mode)
                {
                case AzimuthalMode.Equator:
                case AzimuthalMode.Oblique:
                    if (Mode == AzimuthalMode.Equator)
                    {
                        xy.Y = cosphi * coslam;
                    }
                    else
                    {
                        xy.Y = _sinphi0 * sinphi + _cosphi0 * cosphi * coslam;
                    }
                    if (Math.Abs(Math.Abs(xy.Y) - 1.0) < Tolerance)
                    {
                        if (xy.Y < 0.0)
                        {
                            throw new ProjectionException();
                        }
                        else
                        {
                            xy.X = xy.Y = 0.0;
                        }
                    }
                    else
                    {
                        xy.Y  = Math.Acos(xy.Y);
                        xy.Y /= Math.Sin(xy.Y);
                        xy.X  = 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)
                    {
                        phi    = -phi;
                        coslam = -coslam;
                    }
                    if (Math.Abs(phi - ProjectionMath.PiHalf) < EPS10)
                    {
                        throw new ProjectionException();
                    }
                    xy.X  = (xy.Y = (ProjectionMath.PiHalf + phi)) * Math.Sin(lam);
                    xy.Y *= coslam;
                    break;
                }
            }
            else
            {
                double coslam, cosphi, sinphi, rho, s, H, H2, c, Az, t, ct, st, cA, sA;

                coslam = Math.Cos(lam);
                cosphi = Math.Cos(phi);
                sinphi = Math.Sin(phi);
                switch (Mode)
                {
                case AzimuthalMode.NorthPole:
                case AzimuthalMode.SouthPole:
                    if (Mode == AzimuthalMode.NorthPole)
                    {
                        coslam = -coslam;
                    }
                    xy.X = (rho = Math.Abs(_mp - ProjectionMath.mlfn(phi, sinphi, cosphi, _en))) *
                           Math.Sin(lam);
                    xy.Y = rho * coslam;
                    break;

                case AzimuthalMode.Equator:
                case AzimuthalMode.Oblique:
                    if (Math.Abs(lam) < EPS10 && Math.Abs(phi - ProjectionLatitude) < EPS10)
                    {
                        xy.X = xy.Y = 0.0;
                        break;
                    }
                    t = Math.Atan2(_oneEs * sinphi + EccentricitySquared * _n1 * _sinphi0 *
                                   Math.Sqrt(1.0 - EccentricitySquared * sinphi * sinphi), cosphi);
                    ct = Math.Cos(t); st = Math.Sin(t);
                    Az = Math.Atan2(Math.Sin(lam) * ct, _cosphi0 * st - _sinphi0 * coslam * ct);
                    cA = Math.Cos(Az); sA = Math.Sin(Az);
                    s  = ProjectionMath.Asin(Math.Abs(sA) < Tolerance ?
                                             (_cosphi0 * st - _sinphi0 * coslam * ct) / cA :
                                             Math.Sin(lam) * ct / sA);
                    H  = _he * cA;
                    H2 = H * H;
                    c  = _n1 * s * (1.0 + s * s * (-H2 * (1.0 - H2) / 6.0 +
                                                   s * (_g * H * (1.0 - 2.0 * H2 * H2) / 8.0 +
                                                        s * ((H2 * (4.0 - 7.0 * H2) - 3.0 * _g * _g * (1.0 - 7.0 * H2)) /
                                                             120.0 - s * _g * H / 48.0))));
                    xy.X = c * sA;
                    xy.Y = c * cA;
                    break;
                }
            }
            return(xy);
        }
示例#11
0
        public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate lp)
        {
            double lpphi;

            if (Spherical)
            {
                double B, dphi, tp;
                int    i;

                if (Math.Abs(lpphi = ProjectionLatitude + xyy) <= Tolerance)
                {
                    lp.X = xyx; lp.Y = 0.0;
                }
                else
                {
                    lpphi = xyy;
                    B     = xyx * xyx + xyy * xyy;
                    i     = N_ITER;
                    do
                    {
                        tp     = Math.Tan(lpphi);
                        lpphi -= (dphi = (xyy * (lpphi * tp + 1.0) - lpphi -
                                          0.5 * (lpphi * lpphi + B) * tp) /
                                         ((lpphi - xyy) / tp - 1.0));
                    } while (Math.Abs(dphi) > CONV && --i > 0);
                    if (i == 0)
                    {
                        throw new ProjectionException("I");
                    }
                    lp.X = Math.Asin(xyx * Math.Tan(lpphi)) / Math.Sin(lpphi);
                    lp.Y = lpphi;
                }
            }
            else
            {
                xyy += _ml0;
                if (Math.Abs(xyy) <= Tolerance)
                {
                    lp.X = xyx; lp.Y = 0.0;
                }
                else
                {
                    double r, c, sp, cp, s2ph, ml, mlb, mlp, dPhi;
                    int    i;

                    r = xyy * xyy + xyx * xyx;
                    for (lpphi = xyy, i = I_ITER; i > 0; --i)
                    {
                        sp   = Math.Sin(lpphi);
                        s2ph = sp * (cp = Math.Cos(lpphi));
                        if (Math.Abs(cp) < ITOL)
                        {
                            throw new ProjectionException("I");
                        }
                        c      = sp * (mlp = Math.Sqrt(1.0 - EccentricitySquared * sp * sp)) / cp;
                        ml     = ProjectionMath.mlfn(lpphi, sp, cp, _en);
                        mlb    = ml * ml + r;
                        mlp    = (1.0 / EccentricitySquared) / (mlp * mlp * mlp);
                        lpphi += (dPhi =
                                      (ml + ml + c * mlb - 2.0 * xyy * (c * ml + 1.0)) / (
                                          EccentricitySquared * s2ph * (mlb - 2.0 * xyy * ml) / c +
                                          2.0 * (xyy - ml) * (c * mlp - 1.0 / s2ph) - mlp - mlp));
                        if (Math.Abs(dPhi) <= ITOL)
                        {
                            break;
                        }
                    }
                    if (i == 0)
                    {
                        throw new ProjectionException("I");
                    }
                    c    = Math.Sin(lpphi);
                    lp.X = Math.Asin(xyx * Math.Tan(lpphi) * Math.Sqrt(1.0 - EccentricitySquared * c * c)) / Math.Sin(lpphi);
                    lp.Y = lpphi;
                }
            }
            return(lp);
        }