Coverage Report

Created: 2025-07-12 06:32

/src/PROJ/src/coordinates.cpp
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 * Project:  PROJ
3
 * Purpose:  Functions related to PJ_COORD 4D geodetic spatiotemporal
4
 *           data type.
5
 * Author:   Thomas Knudsen,  thokn@sdfe.dk,  2016-06-09/2016-11-06
6
 *
7
 ******************************************************************************
8
 * Copyright (c) 2016, 2017 Thomas Knudsen/SDFE
9
 *
10
 * Permission is hereby granted, free of charge, to any person obtaining a
11
 * copy of this software and associated documentation files (the "Software"),
12
 * to deal in the Software without restriction, including without limitation
13
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14
 * and/or sell copies of the Software, and to permit persons to whom the
15
 * Software is furnished to do so, subject to the following conditions:
16
 *
17
 * The above copyright notice and this permission notice shall be included
18
 * in all copies or substantial portions of the Software.
19
 *
20
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26
 * DEALINGS IN THE SOFTWARE.
27
 *****************************************************************************/
28
29
#define FROM_PROJ_CPP
30
31
#include "proj.h"
32
#include "proj_internal.h"
33
34
#include "proj/internal/internal.hpp"
35
36
using namespace NS_PROJ::internal;
37
38
/* Initialize PJ_COORD struct */
39
0
PJ_COORD proj_coord(double x, double y, double z, double t) {
40
0
    PJ_COORD res;
41
0
    res.v[0] = x;
42
0
    res.v[1] = y;
43
0
    res.v[2] = z;
44
0
    res.v[3] = t;
45
0
    return res;
46
0
}
47
48
0
PJ_DIRECTION pj_opposite_direction(PJ_DIRECTION dir) {
49
0
    return static_cast<PJ_DIRECTION>(-dir);
50
0
}
51
52
/*****************************************************************************/
53
0
int proj_angular_input(PJ *P, enum PJ_DIRECTION dir) {
54
    /******************************************************************************
55
        Returns 1 if the operator P expects angular input coordinates when
56
        operating in direction dir, 0 otherwise.
57
        dir: {PJ_FWD, PJ_INV}
58
    ******************************************************************************/
59
0
    if (PJ_FWD == dir)
60
0
        return pj_left(P) == PJ_IO_UNITS_RADIANS;
61
0
    return pj_right(P) == PJ_IO_UNITS_RADIANS;
62
0
}
63
64
/*****************************************************************************/
65
0
int proj_angular_output(PJ *P, enum PJ_DIRECTION dir) {
66
    /******************************************************************************
67
        Returns 1 if the operator P provides angular output coordinates when
68
        operating in direction dir, 0 otherwise.
69
        dir: {PJ_FWD, PJ_INV}
70
    ******************************************************************************/
71
0
    return proj_angular_input(P, pj_opposite_direction(dir));
72
0
}
73
74
/*****************************************************************************/
75
0
int proj_degree_input(PJ *P, enum PJ_DIRECTION dir) {
76
    /******************************************************************************
77
        Returns 1 if the operator P expects degree input coordinates when
78
        operating in direction dir, 0 otherwise.
79
        dir: {PJ_FWD, PJ_INV}
80
    ******************************************************************************/
81
0
    if (PJ_FWD == dir)
82
0
        return pj_left(P) == PJ_IO_UNITS_DEGREES;
83
0
    return pj_right(P) == PJ_IO_UNITS_DEGREES;
84
0
}
85
86
/*****************************************************************************/
87
0
int proj_degree_output(PJ *P, enum PJ_DIRECTION dir) {
88
    /******************************************************************************
89
        Returns 1 if the operator P provides degree output coordinates when
90
        operating in direction dir, 0 otherwise.
91
        dir: {PJ_FWD, PJ_INV}
92
    ******************************************************************************/
93
0
    return proj_degree_input(P, pj_opposite_direction(dir));
94
0
}
95
96
0
double proj_torad(double angle_in_degrees) {
97
0
    return PJ_TORAD(angle_in_degrees);
98
0
}
99
2.79k
double proj_todeg(double angle_in_radians) {
100
2.79k
    return PJ_TODEG(angle_in_radians);
101
2.79k
}
102
103
136
double proj_dmstor(const char *is, char **rs) { return dmstor(is, rs); }
104
105
0
char *proj_rtodms(char *s, double r, int pos, int neg) {
106
    // 40 is the size used for the buffer in proj.cpp
107
0
    size_t arbitrary_size = 40;
108
0
    return rtodms(s, arbitrary_size, r, pos, neg);
109
0
}
110
111
0
char *proj_rtodms2(char *s, size_t sizeof_s, double r, int pos, int neg) {
112
0
    return rtodms(s, sizeof_s, r, pos, neg);
113
0
}