[Proj] SPCS NC (3200) -> Lat Long Conversion Problem w/ Program

Kevin S Lim KSLim at atlantictech.com
Sat Apr 30 14:34:04 EDT 2005


Issue:  Output from my VC program does not match values from Corpscon6 or
cs2cs.

Input:  SPCS 3200 - North Carolina - 2982350.290 849500.700

Proj4 Output (program): 75.764937678 33.842018951

Corpscon6 and cs2cs output: 75.676777193 36.038892808

Because the Corpscon6 and cs2cs output match, the problem likely lies in my
source code below:

START OF CODE ***************************************

void ReProjectPoints(FILE *ifp, FILE *ofp)
{
	PJ *ref_in;
	PJ *ref_out;

	static char *parms_in[] = {
		"proj=lcc",
		"a=6378137",
		"es=.0066943800229",
		"x_0=609601.22",
		"lat_1=36d10",	// first standard parallel
		"lat_2=34d20",	// second stardard parallel
		"lat_0=33d45",	// central parallel
		"lon_0=-79",	// central meridian
		"units=us-ft",
		"no_defs"
	};
	
	static char *parms_out[] = {
		"proj=latlong",
		"a=6378137",
		"es=.0066943800229",
		"no_defs"
	};
	char cc;
	double pntX, pntY, pntZ, pntI, GPSTime;
	
	// initialize the vars
	pntX = 0.0;
	pntY = 0.0;
	pntZ = 0.0;
	pntI = 0.0;
	GPSTime = 0.0;

	printf("Trying to initialize input projection... ");
	if ( ! (ref_in = pj_init(sizeof(parms_in)/sizeof(char *), parms_in))
) {
		printf("Failed,\n");
		exit(FAILURE);
	}
	else {
		printf("Succeeded.\n");
	}
	printf("Trying to initialize output projection... ");
	if ( ! (ref_out = pj_init(sizeof(parms_out)/sizeof(char *),
parms_out)) ) {
		printf("Failed.\n");
		exit(FAILURE);
	}
	else {
		printf("Succeeded.\n");
	}

	printf("Writing out new XYZ file...\n");

	while(!feof(ifp)) {

		if (fscanf(ifp, "%lf", &pntX) != 1)
		{
			break;
		}
		fscanf(ifp, "%c", &cc);
		fscanf(ifp, "%c", &cc);
		fscanf(ifp, "%lf", &pntY);
		fscanf(ifp, "%c", &cc);
		fscanf(ifp, "%lf", &pntZ);
		fscanf(ifp, "%c", &cc);
		fscanf(ifp, "%lf", &pntI);
		fscanf(ifp, "%c", &cc);
		fscanf(ifp, "%lf", &GPSTime);

		pj_transform(ref_in, ref_out, 1, 0, &pntX, &pntY, NULL);

		// convert results in radians to decimal degress

		pntX *= RAD_TO_DEG;
		pntX *= -1;
		pntY *= RAD_TO_DEG;

		// scale intensity factor by 10
		pntI *= 10;

		// convert Z in ft to m
		pntZ *= 0.3048;

		fprintf(ofp, "%.9lf ", pntX);
		fprintf(ofp, "%.9lf ", pntY);
		fprintf(ofp, "%.3lf ", pntZ);
		fprintf(ofp, "%.1lf ", pntI);
		fprintf(ofp, "%.4lf\n", GPSTime);

	}

	printf("Success.\n");
}

END OF CODE ***************************************

Any help/input/suggestions would be appreciated.  Thank you.

Cheers,
-- Kevin

Kevin Lim
LiDAR Research Analyst
MD Atlantic Technologies, Inc.
A MacDonald Dettwiler Company
2227 Drake Avenue, S.W., Building 14
Huntsville, AL  35805
[T] 256-882-7788 ext. 343  [F] 256-882-7774
www.atlantictech.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/proj/attachments/20050430/f48132b2/attachment.html


More information about the Proj mailing list