[Proj] Correction and example.
Gerald I. Evenden
geraldi.evenden at gmail.com
Tue Apr 7 13:45:34 EST 2009
Correction to last email
proj_initstr will *not* be replaced with a macro in the near future.
--------------------------------------------------------
Example: instead of the crude example at
http://trac.osgeo.org/proj/wiki/ProjAPI
the following is a little more elegant and handles general input
data, including DMS:
#include "../lib_proj.h"
#include <stdio.h>
#define MAXLINE 1000
int main(int argc, char **argv) {
char options[] = "proj=merc ellps=clrk66 lat_ts=33";
char line[MAXLINE], *s;
PROJ *P;
PROJ_XY out;
PROJ_LP in;
if (!(P = proj_initstr(options))) {
fprintf(stderr, "projection init failure\n");
exit(1);
}
while (s = fgets(line, MAXLINE, stdin)) {
in.phi = proj_dmstor(s, &s);
in.lam = proj_dmstor(s, &s);
out = proj_fwd(in, P);
printf("%.2f\t%.2f\n", out.x, out.y);
}
exit(0);
}
Remember the mantra:
"CARTOGRAPHIC PROJECTIONS HAVE NOTHING TO DO WITH DATUMS"
Write that on the board 200 times and you may go home.
Anyway, I've had my say and I are auta here. TTFN
--
The whole religious complexion of the modern world is due
to the absence from Jerusalem of a lunatic asylum.
-- Havelock Ellis (1859-1939) British psychologist
More information about the Proj
mailing list