]> pd.if.org Git - isea/blob - pjtail.c
Initial checkin.
[isea] / pjtail.c
1 /*
2  * Proj 4 integration code follows
3  */
4
5 #define PROJ_PARMS__ \
6         struct isea_dgg dgg;
7
8 #define PJ_LIB__
9 #include <projects.h>
10
11 PROJ_HEAD(isea, "Icosahedral Snyder Equal Area") "\n\tSph";
12
13 FORWARD(s_forward);
14         struct isea_pt out;
15         struct isea_geo in;
16
17         in.lon = lp.lam;
18         in.lat = lp.phi;
19
20         out = isea_forward(&P->dgg, &in);
21         
22         xy.x = out.x;
23         xy.y = out.y;
24
25         return xy;
26 }
27 FREEUP; if (P) pj_dalloc(P); }
28
29 ENTRY0(isea)
30         char *opt;
31
32         P->fwd = s_forward;
33         isea_grid_init(&P->dgg);
34
35         P->dgg.output = ISEA_PLANE;
36 /*              P->dgg.radius = P->a; /* otherwise defaults to 1 */
37         /* calling library will scale, I think */
38
39         opt = pj_param(P->ctx,P->params, "sorient").s;
40         if (opt) {
41                 if (!strcmp(opt, "isea")) {
42                         isea_orient_isea(&P->dgg);
43                 } else if (!strcmp(opt, "pole")) {
44                         isea_orient_pole(&P->dgg);
45                 } else {
46                         E_ERROR(-34);
47                 }
48         }
49
50         if (pj_param(P->ctx,P->params, "tazi").i) {
51                 P->dgg.o_az = pj_param(P->ctx,P->params, "razi").f;
52         }
53
54         if (pj_param(P->ctx,P->params, "tlon_0").i) {
55                 P->dgg.o_lon = pj_param(P->ctx,P->params, "rlon_0").f;
56         }
57
58         if (pj_param(P->ctx,P->params, "tlat_0").i) {
59                 P->dgg.o_lat = pj_param(P->ctx,P->params, "rlat_0").f;
60         }
61
62         if (pj_param(P->ctx,P->params, "taperture").i) {
63                 P->dgg.aperture = pj_param(P->ctx,P->params, "iaperture").i;
64         }
65
66         if (pj_param(P->ctx,P->params, "tresolution").i) {
67                 P->dgg.resolution = pj_param(P->ctx,P->params, "iresolution").i;
68         }
69
70         opt = pj_param(P->ctx,P->params, "smode").s;
71         if (opt) {
72                 if (!strcmp(opt, "plane")) {
73                         P->dgg.output = ISEA_PLANE;
74                 } else if (!strcmp(opt, "di")) {
75                         P->dgg.output = ISEA_Q2DI;
76                 }
77                 else if (!strcmp(opt, "dd")) {
78                         P->dgg.output = ISEA_Q2DD;
79                 }
80                 else if (!strcmp(opt, "hex")) {
81                         P->dgg.output = ISEA_HEX;
82                 }
83                 else {
84                         /* TODO verify error code.  Possibly eliminate magic */
85                         E_ERROR(-34);
86                 }
87         }
88
89         if (pj_param(P->ctx,P->params, "trescale").i) {
90                 P->dgg.radius = ISEA_SCALE;
91         }
92
93         if (pj_param(P->ctx,P->params, "tresolution").i) {
94                 P->dgg.resolution = pj_param(P->ctx,P->params, "iresolution").i;
95         } else {
96                 P->dgg.resolution = 4;
97         }
98
99         if (pj_param(P->ctx,P->params, "taperture").i) {
100                 P->dgg.aperture = pj_param(P->ctx,P->params, "iaperture").i;
101         } else {
102                 P->dgg.aperture = 3;
103         }
104
105 ENDENTRY(P)