Coverage Report

Created: 2025-07-11 06:33

/src/PROJ/src/projections/nell.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(nell, "Nell") "\n\tPCyl, Sph";
9
10
10.6k
#define MAX_ITER 10
11
24.4k
#define LOOP_TOL 1e-7
12
13
10.6k
static PJ_XY nell_s_forward(PJ_LP lp, PJ *P) { /* Spheroidal, forward */
14
10.6k
    PJ_XY xy = {0.0, 0.0};
15
10.6k
    int i;
16
10.6k
    (void)P;
17
18
10.6k
    const double k = 2. * sin(lp.phi);
19
10.6k
    const double phi_pow_2 = lp.phi * lp.phi;
20
10.6k
    lp.phi *= 1.00371 + phi_pow_2 * (-0.0935382 + phi_pow_2 * -0.011412);
21
24.4k
    for (i = MAX_ITER; i; --i) {
22
24.4k
        const double V = (lp.phi + sin(lp.phi) - k) / (1. + cos(lp.phi));
23
24.4k
        lp.phi -= V;
24
24.4k
        if (fabs(V) < LOOP_TOL)
25
10.6k
            break;
26
24.4k
    }
27
10.6k
    xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
28
10.6k
    xy.y = lp.phi;
29
30
10.6k
    return xy;
31
10.6k
}
32
33
0
static PJ_LP nell_s_inverse(PJ_XY xy, PJ *P) { /* Spheroidal, inverse */
34
0
    PJ_LP lp = {0.0, 0.0};
35
0
    lp.lam = 2. * xy.x / (1. + cos(xy.y));
36
0
    lp.phi = aasin(P->ctx, 0.5 * (xy.y + sin(xy.y)));
37
38
0
    return lp;
39
0
}
40
41
162
PJ *PJ_PROJECTION(nell) {
42
43
162
    P->es = 0;
44
162
    P->inv = nell_s_inverse;
45
162
    P->fwd = nell_s_forward;
46
47
162
    return P;
48
162
}
49
50
#undef MAX_ITER
51
#undef LOOP_TOL