[OSRS-PROJ] lib call results differ from exec results

Frank Warmerdam warmerdam at pobox.com
Tue Jul 15 09:56:11 EDT 2003


Sharon Mingus wrote:
> projXY is the return type of pj_fwd as defined in
> proj_api.h:
> 
> projXY pj_fwd(projLP, projPJ);
> 
> so I'm just sticking with the types provided.  They're
> all the same anyway I guess XY, UV, projUV, projXY,
> projLP, etc. through defines.  This leads me to
> another question: is there any api documentation or
> examples?

Gerald / Sharon,

The projXY, and projUV names were put in place in proj_api.h
because it is dangerous for a package that hopes to be widely
used to define symbols as undistinguished as XY and UV, and
in fact at least one of these conflicted with something
pulled in by windows.h.

> Still there's the question of the pj_fwd results being
> different than the proj exe results.  Now I'm not sure
> if these parameters make sense, but I figured since
> they're the same, they should result in equal values. 
> So the new test is:
> 
> echo "-110.969,39.7621" | ./proj +proj=aea
> +ellps=clrk66 +lat_1=20.0n +lat_2=60.0n +lon_0=110w
> +lat_0=40n
> -122731.33      -4386453.20,39.7621  
> 
> $ ./proj_test -110.969 39.7621
> FWD -7043726.8331, 4640224.1375
> 
> where the modified code with new proj parameters is:
> 
>        char *parms[] = {
>                 "proj=aea",
>                 "ellps=clrk66",
>                 "lat_1=20.0n",
>                 "lat_2=60.0n"
>                 "lon_0=110w",
>                 "lat_0=40n"
>         };

One issue is the comma that Gerald mentioned.  It isn't
an acceptable delimeter for PROJ.4.

warmerda at gdal2200[163]% proj +proj=aea +ellps=clrk66 +lat_1=20.0n +lat_2=60.0n +lon_0=110w +lat_0=40n
-110.969,39.7621
-122731.33      -4386453.20,39.7621
-110.969 39.7621
-78175.38       -27659.27

The second more fundamental reason is that you forgot the comma
after the string "lat_2=60.0n", so that string and the next
are concatenated by the compiler.  PROJ.4 ends up essentially
discarding the lon_0 value giving different results.

I get the following results:

warmerda at gdal2200[106]% ./proj_test -110.969 39.7621
FWD -78175.3815, -27659.2741

with this form of proj_test.c:
#include "proj_api.h"
#include <stdlib.h>
#include <stdio.h>

int main( int argc, char** argv )
{
     char *parms[] = {
         "proj=aea",
         "ellps=clrk66",
         "lat_1=20.0n",
         "lat_2=60.0n",
         "lon_0=110w",
         "lat_0=40n",
         "no_defs",
         NULL
     };

     projPJ pj = pj_init( 7, parms );
     if( !pj )
     {
         printf( "COULD NOT INIT\n" );
         return -1;
     }

     projXY xy;
     xy.u = atof( argv[1] ) * DEG_TO_RAD;
     xy.v = atof( argv[2] ) * DEG_TO_RAD;

     printf( "FWD " );
     xy = pj_fwd( xy, pj );

     printf( "%10.4f, %10.4f\n\n", xy.u, xy.v );

     return 1;
}

There is a pj_init() man page distributed with PROJ.4, but there is no
other API documentation as far as I know.  Well, actually it likely also
appears in one of Geralds reports.

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