Coverage Report

Created: 2025-10-10 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PROJ/src/projections/putp2.cpp
Line
Count
Source
1
2
3
#include <math.h>
4
5
#include "proj.h"
6
#include "proj_internal.h"
7
8
PROJ_HEAD(putp2, "Putnins P2") "\n\tPCyl, Sph";
9
10
168
#define C_x 1.89490
11
168
#define C_y 1.71848
12
168
#define C_p 0.6141848493043784
13
496
#define EPS 1e-10
14
168
#define NITER 10
15
0
#define PI_DIV_3 1.0471975511965977
16
17
168
static PJ_XY putp2_s_forward(PJ_LP lp, PJ *P) { /* Spheroidal, forward */
18
168
    PJ_XY xy = {0.0, 0.0};
19
168
    int i;
20
168
    (void)P;
21
22
168
    const double p = C_p * sin(lp.phi);
23
168
    const double phi_pow_2 = lp.phi * lp.phi;
24
168
    lp.phi *= 0.615709 + phi_pow_2 * (0.00909953 + phi_pow_2 * 0.0046292);
25
496
    for (i = NITER; i; --i) {
26
496
        const double c = cos(lp.phi);
27
496
        const double s = sin(lp.phi);
28
496
        const double V =
29
496
            (lp.phi + s * (c - 1.) - p) / (1. + c * (c - 1.) - s * s);
30
496
        lp.phi -= V;
31
496
        if (fabs(V) < EPS)
32
168
            break;
33
496
    }
34
168
    if (!i)
35
0
        lp.phi = lp.phi < 0 ? -PI_DIV_3 : PI_DIV_3;
36
168
    xy.x = C_x * lp.lam * (cos(lp.phi) - 0.5);
37
168
    xy.y = C_y * sin(lp.phi);
38
39
168
    return xy;
40
168
}
41
42
0
static PJ_LP putp2_s_inverse(PJ_XY xy, PJ *P) { /* Spheroidal, inverse */
43
0
    PJ_LP lp = {0.0, 0.0};
44
45
0
    lp.phi = aasin(P->ctx, xy.y / C_y);
46
0
    const double c = cos(lp.phi);
47
0
    lp.lam = xy.x / (C_x * (c - 0.5));
48
0
    lp.phi = aasin(P->ctx, (lp.phi + sin(lp.phi) * (c - 1.)) / C_p);
49
50
0
    return lp;
51
0
}
52
53
13
PJ *PJ_PROJECTION(putp2) {
54
13
    P->es = 0.;
55
13
    P->inv = putp2_s_inverse;
56
13
    P->fwd = putp2_s_forward;
57
58
13
    return P;
59
13
}
60
61
#undef C_x
62
#undef C_y
63
#undef C_p
64
#undef EPS
65
#undef NITER
66
#undef PI_DIV_3