[Proj] Use of prj_fwd() function...

David.Jacques at CCRS.NRCan.gc.ca David.Jacques at CCRS.NRCan.gc.ca
Tue Nov 9 13:22:44 EST 2004


I want to project coordinate pairs from Decimal Degrees to LCC in my C
program.
I basically need the functionality in proj.exe without the printf output.
I've built a .lib file in MSVC++ which I include in my project.  
What I am not clear on is how to setup such a call. 
I've adapted a section of the latest proj4.3.pdf manual (from example2.c)

Is prj_fwd what proj.exe uses to compute the output coordinates ?

If so, what other than a valid projPJ projection reference (with valid
params)
and an output projUV variable does one need to reproject ? 
I am not getting valid results from my program at the moment. 
I know the parms[] values are correct, and the command line version of
proj accepts decimal degrees as input,  so I am stumped.

thanks in advance.



#include <stdio.h>
#include <string.h>
#include <projects.h>
#include <proj_api.h>
#include <math.h>

main(int argc, char **argv)
{	
	projUV dddata;
	projUV dmsdata;
	projUV lccdata;
	projPJ ref;
	static char *parms[] = { "proj=lcc",
                                "ellps=GRS80",
					"lat_0=49",
					"lon_0=-95",
					"lat_1=49",
					"lat_2=77",
					"datum=NAD83",
					"units=m",
					"no_defs"};
      char lon[40];
      char lat[40];

	//get the destination projection info
	if (! (ref = pj_init((sizeof(parms)/sizeof(char*)),parms)))
	{
		fprintf(stderr, "Projection initialization failed\n");
		exit(1);
	}	

	//project the input coordinates
	dddata.u = -70.8669968;
	dddata.v =  46.3959999;
	lccdata = pj_fwd(dddata,ref);
       printf("%lf,%lf\n",dddata.u,dddata.v);

}




More information about the Proj mailing list