<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>SPCS NC (3200) -> Lat Long Conversion Problem w/ Program</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Issue: Output from my VC program does not match values from Corpscon6 or cs2cs.</FONT>
</P>
<P><FONT SIZE=2>Input: SPCS 3200 - North Carolina - 2982350.290 849500.700</FONT>
</P>
<P><FONT SIZE=2>Proj4 Output (program): 75.764937678 33.842018951</FONT>
</P>
<P><FONT SIZE=2>Corpscon6 and cs2cs output: 75.676777193 36.038892808</FONT>
</P>
<P><FONT SIZE=2>Because the Corpscon6 and cs2cs output match, the problem likely lies in my source code below:</FONT>
</P>
<P><FONT SIZE=2>START OF CODE ***************************************</FONT>
</P>
<P><FONT SIZE=2>void ReProjectPoints(FILE *ifp, FILE *ofp)</FONT>
<BR><FONT SIZE=2>{</FONT>
<BR> <FONT SIZE=2>PJ *ref_in;</FONT>
<BR> <FONT SIZE=2>PJ *ref_out;</FONT>
</P>
<P> <FONT SIZE=2>static char *parms_in[] = {</FONT>
<BR> <FONT SIZE=2>"proj=lcc",</FONT>
<BR> <FONT SIZE=2>"a=6378137",</FONT>
<BR> <FONT SIZE=2>"es=.0066943800229",</FONT>
<BR> <FONT SIZE=2>"x_0=609601.22",</FONT>
<BR> <FONT SIZE=2>"lat_1=36d10", // first standard parallel</FONT>
<BR> <FONT SIZE=2>"lat_2=34d20", // second stardard parallel</FONT>
<BR> <FONT SIZE=2>"lat_0=33d45", // central parallel</FONT>
<BR> <FONT SIZE=2>"lon_0=-79", // central meridian</FONT>
<BR> <FONT SIZE=2>"units=us-ft",</FONT>
<BR> <FONT SIZE=2>"no_defs"</FONT>
<BR> <FONT SIZE=2>};</FONT>
<BR>
<BR> <FONT SIZE=2>static char *parms_out[] = {</FONT>
<BR> <FONT SIZE=2>"proj=latlong",</FONT>
<BR> <FONT SIZE=2>"a=6378137",</FONT>
<BR> <FONT SIZE=2>"es=.0066943800229",</FONT>
<BR> <FONT SIZE=2>"no_defs"</FONT>
<BR> <FONT SIZE=2>};</FONT>
<BR> <FONT SIZE=2>char cc;</FONT>
<BR> <FONT SIZE=2>double pntX, pntY, pntZ, pntI, GPSTime;</FONT>
<BR>
<BR> <FONT SIZE=2>// initialize the vars</FONT>
<BR> <FONT SIZE=2>pntX = 0.0;</FONT>
<BR> <FONT SIZE=2>pntY = 0.0;</FONT>
<BR> <FONT SIZE=2>pntZ = 0.0;</FONT>
<BR> <FONT SIZE=2>pntI = 0.0;</FONT>
<BR> <FONT SIZE=2>GPSTime = 0.0;</FONT>
</P>
<P> <FONT SIZE=2>printf("Trying to initialize input projection... ");</FONT>
<BR> <FONT SIZE=2>if ( ! (ref_in = pj_init(sizeof(parms_in)/sizeof(char *), parms_in)) ) {</FONT>
<BR> <FONT SIZE=2>printf("Failed,\n");</FONT>
<BR> <FONT SIZE=2>exit(FAILURE);</FONT>
<BR> <FONT SIZE=2>}</FONT>
<BR> <FONT SIZE=2>else {</FONT>
<BR> <FONT SIZE=2>printf("Succeeded.\n");</FONT>
<BR> <FONT SIZE=2>}</FONT>
<BR> <FONT SIZE=2>printf("Trying to initialize output projection... ");</FONT>
<BR> <FONT SIZE=2>if ( ! (ref_out = pj_init(sizeof(parms_out)/sizeof(char *), parms_out)) ) {</FONT>
<BR> <FONT SIZE=2>printf("Failed.\n");</FONT>
<BR> <FONT SIZE=2>exit(FAILURE);</FONT>
<BR> <FONT SIZE=2>}</FONT>
<BR> <FONT SIZE=2>else {</FONT>
<BR> <FONT SIZE=2>printf("Succeeded.\n");</FONT>
<BR> <FONT SIZE=2>}</FONT>
</P>
<P> <FONT SIZE=2>printf("Writing out new XYZ file...\n");</FONT>
</P>
<P> <FONT SIZE=2>while(!feof(ifp)) {</FONT>
</P>
<P> <FONT SIZE=2>if (fscanf(ifp, "%lf", &pntX) != 1)</FONT>
<BR> <FONT SIZE=2>{</FONT>
<BR> <FONT SIZE=2>break;</FONT>
<BR> <FONT SIZE=2>}</FONT>
<BR> <FONT SIZE=2>fscanf(ifp, "%c", &cc);</FONT>
<BR> <FONT SIZE=2>fscanf(ifp, "%c", &cc);</FONT>
<BR> <FONT SIZE=2>fscanf(ifp, "%lf", &pntY);</FONT>
<BR> <FONT SIZE=2>fscanf(ifp, "%c", &cc);</FONT>
<BR> <FONT SIZE=2>fscanf(ifp, "%lf", &pntZ);</FONT>
<BR> <FONT SIZE=2>fscanf(ifp, "%c", &cc);</FONT>
<BR> <FONT SIZE=2>fscanf(ifp, "%lf", &pntI);</FONT>
<BR> <FONT SIZE=2>fscanf(ifp, "%c", &cc);</FONT>
<BR> <FONT SIZE=2>fscanf(ifp, "%lf", &GPSTime);</FONT>
</P>
<P> <FONT SIZE=2>pj_transform(ref_in, ref_out, 1, 0, &pntX, &pntY, NULL);</FONT>
</P>
<P> <FONT SIZE=2>// convert results in radians to decimal degress</FONT>
</P>
<P> <FONT SIZE=2>pntX *= RAD_TO_DEG;</FONT>
<BR> <FONT SIZE=2>pntX *= -1;</FONT>
<BR> <FONT SIZE=2>pntY *= RAD_TO_DEG;</FONT>
</P>
<P> <FONT SIZE=2>// scale intensity factor by 10</FONT>
<BR> <FONT SIZE=2>pntI *= 10;</FONT>
</P>
<P> <FONT SIZE=2>// convert Z in ft to m</FONT>
<BR> <FONT SIZE=2>pntZ *= 0.3048;</FONT>
</P>
<P> <FONT SIZE=2>fprintf(ofp, "%.9lf ", pntX);</FONT>
<BR> <FONT SIZE=2>fprintf(ofp, "%.9lf ", pntY);</FONT>
<BR> <FONT SIZE=2>fprintf(ofp, "%.3lf ", pntZ);</FONT>
<BR> <FONT SIZE=2>fprintf(ofp, "%.1lf ", pntI);</FONT>
<BR> <FONT SIZE=2>fprintf(ofp, "%.4lf\n", GPSTime);</FONT>
</P>
<P> <FONT SIZE=2>}</FONT>
</P>
<P> <FONT SIZE=2>printf("Success.\n");</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>
<P><FONT SIZE=2>END OF CODE ***************************************</FONT>
</P>
<P><FONT SIZE=2>Any help/input/suggestions would be appreciated. Thank you.</FONT>
</P>
<P><FONT SIZE=2>Cheers,</FONT>
<BR><FONT SIZE=2>-- Kevin</FONT>
</P>
<P><FONT SIZE=2>Kevin Lim</FONT>
<BR><FONT SIZE=2>LiDAR Research Analyst</FONT>
<BR><FONT SIZE=2>MD Atlantic Technologies, Inc.</FONT>
<BR><FONT SIZE=2>A MacDonald Dettwiler Company</FONT>
<BR><FONT SIZE=2>2227 Drake Avenue, S.W., Building 14</FONT>
<BR><FONT SIZE=2>Huntsville, AL 35805</FONT>
<BR><FONT SIZE=2>[T] 256-882-7788 ext. 343 [F] 256-882-7774</FONT>
<BR><FONT SIZE=2>www.atlantictech.com</FONT>
</P>
</BODY>
</HTML>