Coverage Report

Created: 2025-07-12 06:32

/src/PROJ/src/projections/nell_h.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_h, "Nell-Hammer") "\n\tPCyl, Sph";
9
10
0
#define NITER 9
11
0
#define EPS 1e-7
12
13
0
static PJ_XY nell_h_s_forward(PJ_LP lp, PJ *P) { /* Spheroidal, forward */
14
0
    PJ_XY xy = {0.0, 0.0};
15
0
    (void)P;
16
17
0
    xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
18
0
    xy.y = 2.0 * (lp.phi - tan(0.5 * lp.phi));
19
20
0
    return xy;
21
0
}
22
23
0
static PJ_LP nell_h_s_inverse(PJ_XY xy, PJ *P) { /* Spheroidal, inverse */
24
0
    PJ_LP lp = {0.0, 0.0};
25
0
    int i;
26
0
    (void)P;
27
28
0
    const double p = 0.5 * xy.y;
29
0
    for (i = NITER; i; --i) {
30
0
        const double c = cos(0.5 * lp.phi);
31
0
        const double V = (lp.phi - tan(lp.phi / 2) - p) / (1. - 0.5 / (c * c));
32
0
        lp.phi -= V;
33
0
        if (fabs(V) < EPS)
34
0
            break;
35
0
    }
36
0
    if (!i) {
37
0
        lp.phi = p < 0. ? -M_HALFPI : M_HALFPI;
38
0
        lp.lam = 2. * xy.x;
39
0
    } else
40
0
        lp.lam = 2. * xy.x / (1. + cos(lp.phi));
41
42
0
    return lp;
43
0
}
44
45
7
PJ *PJ_PROJECTION(nell_h) {
46
7
    P->es = 0.;
47
7
    P->inv = nell_h_s_inverse;
48
7
    P->fwd = nell_h_s_forward;
49
50
7
    return P;
51
7
}
52
53
#undef NITER
54
#undef EPS