/src/proj/src/projections/fahey.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | |
2 | | |
3 | | #include <math.h> |
4 | | |
5 | | #include "proj.h" |
6 | | #include "proj_internal.h" |
7 | | |
8 | | PROJ_HEAD(fahey, "Fahey") "\n\tPcyl, Sph"; |
9 | | |
10 | 0 | #define TOL 1e-6 |
11 | | |
12 | 0 | static PJ_XY fahey_s_forward(PJ_LP lp, PJ *P) { /* Spheroidal, forward */ |
13 | 0 | PJ_XY xy = {0.0, 0.0}; |
14 | 0 | (void)P; |
15 | |
|
16 | 0 | xy.x = tan(0.5 * lp.phi); |
17 | 0 | xy.y = 1.819152 * xy.x; |
18 | 0 | xy.x = 0.819152 * lp.lam * asqrt(1 - xy.x * xy.x); |
19 | 0 | return xy; |
20 | 0 | } |
21 | | |
22 | 0 | static PJ_LP fahey_s_inverse(PJ_XY xy, PJ *P) { /* Spheroidal, inverse */ |
23 | 0 | PJ_LP lp = {0.0, 0.0}; |
24 | 0 | (void)P; |
25 | |
|
26 | 0 | xy.y /= 1.819152; |
27 | 0 | lp.phi = 2. * atan(xy.y); |
28 | 0 | xy.y = 1. - xy.y * xy.y; |
29 | 0 | lp.lam = fabs(xy.y) < TOL ? 0. : xy.x / (0.819152 * sqrt(xy.y)); |
30 | 0 | return lp; |
31 | 0 | } |
32 | | |
33 | 3 | PJ *PJ_PROJECTION(fahey) { |
34 | 3 | P->es = 0.; |
35 | 3 | P->inv = fahey_s_inverse; |
36 | 3 | P->fwd = fahey_s_forward; |
37 | | |
38 | 3 | return P; |
39 | 3 | } |