예제 #1
0
		// general forward projection

		// forward projection entry
		public static XYZ pj_fwd3d(LPZ lpz, PJ P)
		{
			XYZ xyz;

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

			// proceed with projection
			P.ctx.last_errno = 0;
			pj_errno = 0;
			Libc.errno = 0;

			if (Math.Abs(t) <= EPS12) lpz.phi = lpz.phi < 0.0 ? -HALFPI : HALFPI;
			else if (P.geoc) lpz.phi = Math.Atan(P.rone_es * Math.Tan(lpz.phi)); // Maybe redundant and never used.
			lpz.lam -= P.lam0; // compute del lp.lam
			if (!P.over) lpz.lam = adjlon(lpz.lam); // adjust del longitude

			// Check for NULL pointer
			if (P.fwd3d != null)
			{
				xyz = P.fwd3d(lpz); // project
				if (P.ctx.last_errno != 0) xyz.x = xyz.y = xyz.z = Libc.HUGE_VAL;
				// adjust for major axis and easting/northings
				else
				{
					xyz.x = P.fr_meter * (P.a * xyz.x + P.x0);
					xyz.y = P.fr_meter * (P.a * xyz.y + P.y0);
					// z is not scaled since this handled by vto_meter outside
				}
			}
			else
			{
				xyz.x = xyz.y = xyz.z = Libc.HUGE_VAL;
			}

			return xyz;
		}
예제 #2
0
		XYZ forward3d(LPZ lpz)
		{
			XYZ xyz;
			xyz.x = xyz.y = xyz.z = 0;

			double temp0, temp1, temp2;

			// Convert lat lon to geocentric coordinates
			if (elp_0.pj_Convert_Geodetic_To_Geocentric(lpz.phi, lpz.lam, lpz.z, out temp0, out temp1, out temp2) != 0) { Proj.pj_ctx_set_errno(ctx, -20); return xyz; }

			// Adjust for offset
			temp0 -= xyzoff[0];
			temp1 -= xyzoff[1];
			temp2 -= xyzoff[2];

			// Apply rotation
			double pxyz0 = transMat[0] * temp0 + transMat[3] * temp1 + transMat[6] * temp2;
			double pxyz1 = transMat[1] * temp0 + transMat[4] * temp1 + transMat[7] * temp2;
			double pxyz2 = transMat[2] * temp0 + transMat[5] * temp1 + transMat[8] * temp2;

			// Convert to local lat,lon
			sph.pj_Convert_Geocentric_To_Geodetic(pxyz0, pxyz1, pxyz2, out temp0, out temp1, out temp2);

			// Scale by radius
			xyz.x = temp1 * rcurv / a;
			xyz.y = temp0 * rcurv / a;
			xyz.z = temp2;

			//printf("FORWARD: \n");
			//printf("LPZ: %f %f %f \n", lpz.lam, lpz.phi, lpz.z);
			//printf("XYZ: %f %f %f \n", xyz.x, xyz.y, xyz.z);
			return xyz;
		}