Beispiel #1
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;
            double fa;

            if (mode)
            {
                fa = Math.Tan(lp.lam * fxb) * fxa;
            }
            else
            {
                fa = 0.5 * lp.lam;
            }

            if (Math.Abs(lp.phi) < EPS)
            {
                xy.x = fa + fa;
                xy.y = -phi0;
            }
            else
            {
                xy.y = 1.0 / Math.Tan(lp.phi);
                fa   = 2.0 * Math.Atan(fa * Math.Sin(lp.phi));
                xy.x = Math.Sin(fa) * xy.y;
                xy.y = lp.phi - phi0 + (1.0 - Math.Cos(fa)) * xy.y;
            }

            return(xy);
        }
Beispiel #2
0
        // general forward projection

        // forward projection entry
        public static XY pj_fwd(LP lp, PJ P)
        {
            XY xy;

            // check for forward and latitude or longitude overange
            double t = Math.Abs(lp.phi) - HALFPI;

            if (t > EPS12 || Math.Abs(lp.lam) > 10.0)
            {
                xy.x = xy.y = Libc.HUGE_VAL;
                pj_ctx_set_errno(P.ctx, -14);
                return(xy);
            }

            // proceed with projection
            Libc.errno       = pj_errno = 0;
            P.ctx.last_errno = 0;
            if (Math.Abs(t) <= EPS12)
            {
                lp.phi = lp.phi < 0.0?-HALFPI:HALFPI;
            }
            else if (P.geoc)
            {
                lp.phi = Math.Atan(P.rone_es * Math.Tan(lp.phi));
            }

            lp.lam -= P.lam0;           // compute del lp.lam
            if (!P.over)
            {
                lp.lam = adjlon(lp.lam); // adjust del longitude
            }
            xy = P.fwd(lp);              // project
            if (P.ctx.last_errno != 0)
            {
                xy.x = xy.y = Libc.HUGE_VAL;
            }
            else             // adjust for major axis and easting/northings
            {
                xy.x = P.fr_meter * (P.a * xy.x + P.x0);
                xy.y = P.fr_meter * (P.a * xy.y + P.y0);
            }

            if (pj_errno == 0)
            {
                pj_errno = Libc.errno;
            }

            return(xy);
        }
Beispiel #3
0
		// general forward projection

		// forward projection entry
		public static XY pj_fwd(LP lp, PJ P)
		{
			XY xy;

			// check for forward and latitude or longitude overange
			double t=Math.Abs(lp.phi)-HALFPI;
			if(t>EPS12||Math.Abs(lp.lam)>10.0)
			{
				xy.x=xy.y=Libc.HUGE_VAL;
				pj_ctx_set_errno(P.ctx, -14);
				return xy;
			}

			// proceed with projection
			Libc.errno=pj_errno=0;
			P.ctx.last_errno=0;
			if(Math.Abs(t)<=EPS12) lp.phi=lp.phi<0.0?-HALFPI:HALFPI;
			else if(P.geoc) lp.phi=Math.Atan(P.rone_es*Math.Tan(lp.phi));

			lp.lam-=P.lam0; // compute del lp.lam
			if(!P.over) lp.lam=adjlon(lp.lam); // adjust del longitude

			// Check for NULL pointer
			if (P.fwd != null)
			{
				xy = P.fwd(lp); // project
				if (P.ctx.last_errno != 0)
				{
					xy.x = xy.y = Libc.HUGE_VAL;
				}
				else // adjust for major axis and easting/northings
				{
					xy.x = P.fr_meter * (P.a * xy.x + P.x0);
					xy.y = P.fr_meter * (P.a * xy.y + P.y0);
				}
			}
			else
			{
				xy.x = xy.y = Libc.HUGE_VAL;
			}

			if(pj_errno==0) pj_errno=Libc.errno;

			return xy;
		}
Beispiel #4
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;
            double fa;

            if(mode) fa=Math.Tan(lp.lam*fxb)*fxa;
            else fa=0.5*lp.lam;

            if(Math.Abs(lp.phi)<EPS)
            {
                xy.x=fa+fa;
                xy.y=-phi0;
            }
            else
            {
                xy.y=1.0/Math.Tan(lp.phi);
                fa=2.0*Math.Atan(fa*Math.Sin(lp.phi));
                xy.x=Math.Sin(fa)*xy.y;
                xy.y=lp.phi-phi0+(1.0-Math.Cos(fa))*xy.y;
            }

            return xy;
        }