[GRASS-dev] convergence angle

Hamish hamish_b at yahoo.com
Tue Oct 21 06:11:42 EDT 2008


was: [GRASS-dev] porting r.in.wms to python

wrt: angle between grid north and true north


> Hamish wrote:
> > does anyone know of a libgis function that will return
> > the current projection+coordinate's convergence angle WRT true north?
> > A method to find that with the `proj` program is given here:
> http://grass.osgeo.org/wiki/Ps.map_scripts#Creating_a_fancy_North_Arrow

Glynn: 
> The -V option is handled by vprocess() in proj.c (in PROJ); after
> converting to/from lat/lon, it basically just calls pj_factors() (in
> pj_factors.c) then prints out all of the values.
> 
> The following code (from r.proj) will get you the "struct pj_info" for
> the current location.
> 
>     struct pj_info oproj;
> 
>     /* Get projection info for output mapset */
>     if ((out_proj_info = G_get_projinfo()) == NULL)
> 	G_fatal_error(_("Unable to get projection info of output raster map"));
> 
>     if ((out_unit_info = G_get_projunits()) == NULL)
> 	G_fatal_error(_("Unable to get projection units of output raster map"));
> 
>     if (pj_get_kv(&oproj, out_proj_info, out_unit_info) < 0)
> 	G_fatal_error(_("Unable to get projection key values of output raster map"));
> 
> The "pj" field (i.e. oproj.pj) is the projPJ* which the PROJ library
> wants. You should then be able to use pj_factors() directly to get the
> convergence angle, e.g.:
> 
> 	LP lp = { <lat, long> };
> 	struct FACTORS fact;
> 	pj_factors(lp, oproj.pj, 0.0, &fac);
> 	convergence = fac.conv;


Hi,

I am trying to add this as "g.region -n" now, some questions:

1) local_proto.h: what's next in this series:
#define PRINT_REG    0x01
#define PRINT_SH     0x02
#define PRINT_LL     0x04
#define PRINT_EXTENT 0x08
#define PRINT_CENTER 0x10
#define PRINT_METERS 0x20
#define PRINT_3D     0x40
#define PRINT_MBBOX  0x80

#define PRINT_NANGLE 0x ???


2) #include <projects.h> to get LP, FACTOR, and pj_factors() ?

3) The compiler complains that arg 2 of pj_factors(, oproj.pj,) is of
an incompatible pointer type. If I make it *oproj.pj it doesn't complain
but the output fact.conv is always 0.00000.


?


thanks,
Hamish



      



More information about the grass-dev mailing list