[OSRS-PROJ] Re: Proj4 for Windows
Frank Warmerdam
warmerdam at pobox.com
Tue Jan 15 10:30:46 PST 2002
Børge Hansen wrote:
> Thanks a lot. I managed to compile it.
>
> Do you have an example of an application that uses this library to convert
> between GEO and UTM coordinates. Preferably a Visual Studio project, but
> I'll take anything...
>
> b.r
> Børge
>
Børge,
I don't have a visual studio project for you, but here is a simple program
for converting from lat/long to utm. The example demonstrates the modern
api. On Unix I can build the program like this:
% gcc -I/usr/local/include ll2utm.c -o ll2utm -lproj
ll2utm.c:
#include "proj_api.h"
int main()
{
projPJ src, dst;
double x, y;
int pj_err;
src = pj_init_plus( "+proj=latlong +datum=WGS84" );
dst = pj_init_plus( "+proj=utm +zone=11 +datum=WGS84" );
while( scanf( "%lf %lf", &x, &y ) == 2 )
{
if( pj_is_latlong( src ) )
{
x = x * DEG_TO_RAD;
y = y * DEG_TO_RAD;
}
if( (pj_err = pj_transform( src, dst, 1, 1, &x, &y, NULL )) != 0 )
{
printf( "pj_transform: %s", pj_strerrno( pj_err ) );
}
else
{
if( pj_is_latlong( dst ) )
printf( "%.8f %.8f\n", x * RAD_TO_DEG, y * RAD_TO_DEG );
else
printf( "%.3f %.3f\n", x, y );
}
}
}
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
----------------------------------------
PROJ.4 Discussion List
See http://www.remotesensing.org/proj for subscription, unsubscription
and other information.
More information about the Proj
mailing list