PJ_INIT(3U)

NAME
pj_init - initialize cartographic projection
pj_fwd - forward cartographic projection
pj_inv - inverse cartographic projection
pj_free - de-initialize projection

SYNOPSIS
#include <projects.h>
PJ *pj_init(int argc, char **argv)
UV pj_fwd(UV val, PJ *proj)
UV pj_inv(UV val, PJ *proj)
void pj_free(PJ *proj)

DESCRIPTION
Procedure pj_init selects and initializes a cartographic projection with its argument control parameters. Argc is the number of elements in the array of control strings argv that each contain individual cartographic control keyword assignments (+ proj arguments). The list must contain at least the proj=projection and Earth's radius or elliptical parameters. If the initialization of the projection is successful a valid address is returned otherwise a NULL value. Once initialization is performed either forward or inverse projections can be performed with the returned value of pj_init used as the argument proj. The argument structure UV values u and v contain respective longitude and latitude or x and y. Latitude and longitude are in radians. If a projection operation fails, both elements of UV are set to HUGE_VAL (defined in math.h). Note: all projections have a forward mode, but some do not have an inverse projection. If the projection does not have an inverse the PJ structure element inv will be NULL. Memory associated with the projection may be freed with pj_free.

EXAMPLE
The following program reads latitude and longitude values in decimal degress, performs Mercator projection with a Clarke 1866 ellipsoid and a 33° latitude of true scale and prints the projected cartesian values in meters:

#include <projects.h>
main(int argc, char **argv) {
	char *args[] = { "proj=merc", "ellps=clrk66", "lat_ts=33" };
	UV p;
	PJ *pj;
	if (!(pj = pj_init(3, args)))
	   exit(1);
	while (scanf("%lf %lf", &p.v, &p.u) == 2) {
	   p.u *= DEG_TO_RAD;
	   p.v *= DEG_TO_RAD;
	   p = pj_fwd(p, pj);
	   printf("%.2f\t%.2f\n", p.u, p.v);
	}
	exit(0);
}

LIBRARY
libpj.a - library of projections and support procedures

SEE ALSO
proj(1U),
Cartographic Projection Procedures for the UNIX Environment—A User's Manual, (Evenden, 1990, Open-file report 90-284).

AUTHOR/MAINTENANCE
Gerald I. Evenden, USGS, Woods Hole, MA 02543