Coverage Report

Created: 2025-07-23 06:58

/src/PROJ/src/projections/times.cpp
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 * Project:  PROJ.4
3
 * Purpose:  Implementation of the Times projection.
4
 * Author:   Kristian Evers <kristianevers@gmail.com>
5
 *
6
 ******************************************************************************
7
 * Copyright (c) 2016, Kristian Evers
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a
10
 * copy of this software and associated documentation files (the "Software"),
11
 * to deal in the Software without restriction, including without limitation
12
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13
 * and/or sell copies of the Software, and to permit persons to whom the
14
 * Software is furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included
17
 * in all copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
 * DEALINGS IN THE SOFTWARE.
26
 *****************************************************************************
27
 * Based on description of the Times Projection in
28
 *
29
 * Flattening the Earth, Snyder, J.P., 1993, p.213-214.
30
 *****************************************************************************/
31
32
#include <math.h>
33
34
#include "proj.h"
35
#include "proj_internal.h"
36
37
PROJ_HEAD(times, "Times") "\n\tCyl, Sph";
38
39
0
static PJ_XY times_s_forward(PJ_LP lp, PJ *P) { /* Spheroidal, forward */
40
0
    double T, S, S2;
41
0
    PJ_XY xy = {0.0, 0.0};
42
0
    (void)P;
43
44
0
    T = tan(lp.phi / 2.0);
45
0
    S = sin(M_FORTPI * T);
46
0
    S2 = S * S;
47
48
0
    xy.x = lp.lam * (0.74482 - 0.34588 * S2);
49
0
    xy.y = 1.70711 * T;
50
51
0
    return xy;
52
0
}
53
54
0
static PJ_LP times_s_inverse(PJ_XY xy, PJ *P) { /* Spheroidal, inverse */
55
0
    double T, S, S2;
56
0
    PJ_LP lp = {0.0, 0.0};
57
0
    (void)P;
58
59
0
    T = xy.y / 1.70711;
60
0
    S = sin(M_FORTPI * T);
61
0
    S2 = S * S;
62
63
0
    lp.lam = xy.x / (0.74482 - 0.34588 * S2);
64
0
    lp.phi = 2 * atan(T);
65
66
0
    return lp;
67
0
}
68
69
23
PJ *PJ_PROJECTION(times) {
70
23
    P->es = 0.0;
71
72
23
    P->inv = times_s_inverse;
73
23
    P->fwd = times_s_forward;
74
75
23
    return P;
76
23
}