aboutsummaryrefslogtreecommitdiff
path: root/man/man3/pj_init.3
blob: 306339e107fa3736d1a807976e20ef8f6a0ccc79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.\" @(#)pj_init.3 - 4.1
.nr LL 5.5i
.TH PJ_INIT 3U "2000/03/21 Rel. 4.4" 
.ad b
.hy 1
.SH NAME
pj_init \- initialize cartographic projection
.br
pj_fwd \- forward cartographic projection
.br
pj_inv \- inverse cartographic projection
.br
pj_free \- de-initialize projection
.SH SYNOPSIS
.nf
#include <projects.h>

PJ *pj_init(int argc, char **argv)

projUV pj_fwd(projUV val, PJ *proj)

projUV pj_inv(projUV val, PJ *proj)

void pj_free(PJ *proj)

.SH DESCRIPTION
Procedure \fBpj_init\fR selects and initializes a cartographic projection
with its argument control parameters.
\fBArgc\fR is the number of elements in the array of control strings
\fBargv\fR that each contain individual cartographic control keyword
assignments (\f(CW+\fR \fBproj\fR arguments).
The list must contain at least the \fBproj=\fIprojection\fR 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 \fBpj_init\fR
used as the argument \fBproj\fR.
The argument structure \fBprojUV\fR values \fBu\fR and \fBv\fR contain
respective longitude and latitude or x and y.
Latitude and longitude are in radians.
If a projection operation fails, both elements of \fBprojUV\fR are
set to HUGE_VAL (defined in \fImath.h\fR).

\fBNote:\fR 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
\fIinv\fR will be NULL.

Memory associated with the projection may be freed with \fBpj_free\fR.
.SH EXAMPLE
The following program reads latitude and longitude values in decimal
degress, performs Mercator projection with a Clarke 1866 ellipsoid and
a 33\(de latitude of true scale and prints the projected
cartesian values in meters:
.nf
\f(CW
#include <projects.h>
main(int argc, char **argv) {
	char *args[] = { "proj=merc", "ellps=clrk66", "lat_ts=33" };
	projUV 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\et%.2f\en", p.u, p.v);
	}
	exit(0);
} \fR
.br
.fi
.SH LIBRARY
libproj.a \- library of projections and support procedures
.SH SEE ALSO
.B proj(1U),
.br
.I "Cartographic Projection Procedures for the UNIX Environment\(emA User's Manual,"
(Evenden, 1990, Open-file report 90\-284).
.SH HOME PAGE
http://www.remotesensing.org/proj