root / trunk / libraries / libjni-proj4 / src / geod_set.c @ 7098
History | View | Annotate | Download (2.05 KB)
1 |
#ifndef lint
|
---|---|
2 |
static const char SCCSID[]="@(#)geod_set.c 4.8 95/09/23 GIE REL"; |
3 |
#endif
|
4 |
|
5 |
#define _IN_GEOD_SET
|
6 |
|
7 |
#include <string.h> |
8 |
#include "projects.h" |
9 |
#include "geodesic.h" |
10 |
#include "emess.h" |
11 |
void
|
12 |
geod_set(int argc, char **argv) { |
13 |
paralist *start = 0, *curr;
|
14 |
double es;
|
15 |
char *name;
|
16 |
int i;
|
17 |
|
18 |
/* put arguments into internal linked list */
|
19 |
if (argc <= 0) |
20 |
emess(1, "no arguments in initialization list"); |
21 |
for (i = 0; i < argc; ++i) |
22 |
if (i)
|
23 |
curr = curr->next = pj_mkparam(argv[i]); |
24 |
else
|
25 |
start = curr = pj_mkparam(argv[i]); |
26 |
/* set elliptical parameters */
|
27 |
if (pj_ell_set(start, &geod_a, &es)) emess(1,"ellipse setup failure"); |
28 |
/* set units */
|
29 |
if (name = pj_param(start, "sunits").s) { |
30 |
char *s;
|
31 |
struct PJ_UNITS *unit_list = pj_get_units_ref();
|
32 |
for (i = 0; (s = unit_list[i].id) && strcmp(name, s) ; ++i) ; |
33 |
if (!s)
|
34 |
emess(1,"%s unknown unit conversion id", name); |
35 |
fr_meter = 1. / (to_meter = atof(unit_list[i].to_meter));
|
36 |
} else
|
37 |
to_meter = fr_meter = 1.;
|
38 |
if (ellipse = es != 0.) { |
39 |
onef = sqrt(1. - es);
|
40 |
geod_f = 1 - onef;
|
41 |
f2 = geod_f/2;
|
42 |
f4 = geod_f/4;
|
43 |
f64 = geod_f*geod_f/64;
|
44 |
} else {
|
45 |
onef = 1.;
|
46 |
geod_f = f2 = f4 = f64 = 0.;
|
47 |
} |
48 |
/* check if line or arc mode */
|
49 |
if (pj_param(start, "tlat_1").i) { |
50 |
double del_S;
|
51 |
#undef f
|
52 |
phi1 = pj_param(start, "rlat_1").f;
|
53 |
lam1 = pj_param(start, "rlon_1").f;
|
54 |
if (pj_param(start, "tlat_2").i) { |
55 |
phi2 = pj_param(start, "rlat_2").f;
|
56 |
lam2 = pj_param(start, "rlon_2").f;
|
57 |
geod_inv(); |
58 |
geod_pre(); |
59 |
} else if (geod_S = pj_param(start, "dS").f) { |
60 |
al12 = pj_param(start, "rA").f;
|
61 |
geod_pre(); |
62 |
geod_for(); |
63 |
} else emess(1,"incomplete geodesic/arc info"); |
64 |
if ((n_alpha = pj_param(start, "in_A").i) > 0) { |
65 |
if (!(del_alpha = pj_param(start, "rdel_A").f)) |
66 |
emess(1,"del azimuth == 0"); |
67 |
} else if (del_S = fabs(pj_param(start, "ddel_S").f)) { |
68 |
n_S = geod_S / del_S + .5;
|
69 |
} else if ((n_S = pj_param(start, "in_S").i) <= 0) |
70 |
emess(1,"no interval divisor selected"); |
71 |
} |
72 |
/* free up linked list */
|
73 |
for ( ; start; start = curr) {
|
74 |
curr = start->next; |
75 |
pj_dalloc(start); |
76 |
} |
77 |
} |