PJ_goode.c
1.03 KB
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
#define PROJ_PARMS__ \
struct PJconsts *sinu; \
struct PJconsts *moll;
#define PJ_LIB__
#include <projects.h>
PROJ_HEAD(goode, "Goode Homolosine") "\n\tPCyl, Sph.";
C_NAMESPACE PJ
*pj_sinu(PJ *), *pj_moll(PJ *);
#define Y_COR 0.05280
#define PHI_LIM .71093078197902358062
FORWARD(s_forward); /* spheroid */
if (fabs(lp.phi) <= PHI_LIM)
xy = P->sinu->fwd(lp, P->sinu);
else {
xy = P->moll->fwd(lp, P->moll);
xy.y -= lp.phi >= 0.0 ? Y_COR : -Y_COR;
}
return (xy);
}
INVERSE(s_inverse); /* spheroid */
if (fabs(xy.y) <= PHI_LIM)
lp = P->sinu->inv(xy, P->sinu);
else {
xy.y += xy.y >= 0.0 ? Y_COR : -Y_COR;
lp = P->moll->inv(xy, P->moll);
}
return (lp);
}
FREEUP;
if (P) {
if (P->sinu)
(*(P->sinu->pfree))(P->sinu);
if (P->moll)
(*(P->moll->pfree))(P->moll);
pj_dalloc(P);
}
}
ENTRY2(goode, sinu, moll)
P->es = 0.;
if (!(P->sinu = pj_sinu(0)) || !(P->moll = pj_moll(0)))
E_ERROR_0;
if (!(P->sinu = pj_sinu(P->sinu)) || !(P->moll = pj_moll(P->moll)))
E_ERROR_0;
P->fwd = s_forward;
P->inv = s_inverse;
ENDENTRY(P)