Coverage Report

Created: 2025-06-09 08:44

/src/gdal/proj/src/projections/wink1.cpp
Line
Count
Source (jump to first uncovered line)
1
2
3
#include <errno.h>
4
#include <math.h>
5
6
#include "proj.h"
7
#include "proj_internal.h"
8
9
PROJ_HEAD(wink1, "Winkel I") "\n\tPCyl, Sph\n\tlat_ts=";
10
11
namespace { // anonymous namespace
12
struct pj_wink1_data {
13
    double cosphi1;
14
};
15
} // anonymous namespace
16
17
256
static PJ_XY wink1_s_forward(PJ_LP lp, PJ *P) { /* Spheroidal, forward */
18
256
    PJ_XY xy = {0.0, 0.0};
19
256
    xy.x =
20
256
        .5 * lp.lam *
21
256
        (static_cast<struct pj_wink1_data *>(P->opaque)->cosphi1 + cos(lp.phi));
22
256
    xy.y = lp.phi;
23
256
    return (xy);
24
256
}
25
26
352
static PJ_LP wink1_s_inverse(PJ_XY xy, PJ *P) { /* Spheroidal, inverse */
27
352
    PJ_LP lp = {0.0, 0.0};
28
352
    lp.phi = xy.y;
29
352
    lp.lam =
30
352
        2. * xy.x /
31
352
        (static_cast<struct pj_wink1_data *>(P->opaque)->cosphi1 + cos(lp.phi));
32
352
    return (lp);
33
352
}
34
35
14.4k
PJ *PJ_PROJECTION(wink1) {
36
14.4k
    struct pj_wink1_data *Q = static_cast<struct pj_wink1_data *>(
37
14.4k
        calloc(1, sizeof(struct pj_wink1_data)));
38
14.4k
    if (nullptr == Q)
39
0
        return pj_default_destructor(P, PROJ_ERR_OTHER /*ENOMEM*/);
40
14.4k
    P->opaque = Q;
41
42
14.4k
    static_cast<struct pj_wink1_data *>(P->opaque)->cosphi1 =
43
14.4k
        cos(pj_param(P->ctx, P->params, "rlat_ts").f);
44
14.4k
    P->es = 0.;
45
14.4k
    P->inv = wink1_s_inverse;
46
14.4k
    P->fwd = wink1_s_forward;
47
48
14.4k
    return P;
49
14.4k
}