[Proj] PROJ INFO

Andrea Antonini antonini at lamma.rete.toscana.it
Fri Nov 30 08:36:04 PST 2007


Dear all,
I'm a new proj user. I'm studying the proj API to use the proj libraries 
in a C program. I have some problems also in basics operation. For 
example I cannot execute this very simple program:
----------------------------------------------------------------------------------------------------------------------
/*
 To compile:
 
 gcc -o utm_to_lat_lon utm_to_lat_lon.c -L /usr/local/lib/libproj.so.0 
-lproj
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#include <proj_api.h>

int main (int argc, char *argv[]){
    projPJ llpj;
    projPJ utmpj;
    char *llargs[] = {"proj=latlon", "ellps=WGS84"};
    char *utmargs[] = { "proj=utm", "ellps=WGS84", "lat_ts=32" };
    double x,y,z;   

   
    if (!(llpj = pj_init(2, llargs))){
        printf("Error1\n");
        exit(1);
    }
       
    if (!(utmpj = pj_init(3, utmargs))){
        printf("Error2\n");       
        exit(1);
    }
       
    y = 4842939.0;
    x = 672393.0;
    z = 401.0;
   
    if (pj_transform(utmpj, llpj, 1, 1, &x, &y, &z)!=0) {
        printf ("Error3\n");
        exit (-1);
    }
    printf("Lat = %f; Lon = %f; H=%f\n",x,y,z);
   
    pj_free(llpj);
    pj_free(utmpj);
   
   
    return(0);
}
----------------------------------------------------------------------------------------------------------------------

The compilation is ok, but when I execute the command the result is 
always Error1

Could someone give me an help, please?

Thanks!

Andrea




More information about the Proj mailing list