Coverage Report

Created: 2025-10-13 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PROJ/src/units.cpp
Line
Count
Source
1
/* definition of standard cartesian units */
2
3
#include <stddef.h>
4
5
#include "proj.h"
6
7
#include "proj_internal.h"
8
9
/* Field 2 that contains the multiplier to convert named units to meters
10
** may be expressed by either a simple floating point constant or a
11
** numerator/denomenator values (e.g. 1/1000) */
12
static const struct PJ_UNITS pj_units[] = {
13
    {"km", "1000", "Kilometer", 1000.0},
14
    {"m", "1", "Meter", 1.0},
15
    {"dm", "1/10", "Decimeter", 0.1},
16
    {"cm", "1/100", "Centimeter", 0.01},
17
    {"mm", "1/1000", "Millimeter", 0.001},
18
    {"kmi", "1852", "International Nautical Mile", 1852.0},
19
    {"in", "0.0254", "International Inch", 0.0254},
20
    {"ft", "0.3048", "International Foot", 0.3048},
21
    {"yd", "0.9144", "International Yard", 0.9144},
22
    {"mi", "1609.344", "International Statute Mile", 1609.344},
23
    {"fath", "1.8288", "International Fathom", 1.8288},
24
    {"ch", "20.1168", "International Chain", 20.1168},
25
    {"link", "0.201168", "International Link", 0.201168},
26
    {"us-in", "1/39.37", "U.S. Surveyor's Inch", 100 / 3937.0},
27
    {"us-ft", "0.304800609601219", "U.S. Surveyor's Foot", 1200 / 3937.0},
28
    {"us-yd", "0.914401828803658", "U.S. Surveyor's Yard", 3600 / 3937.0},
29
    {"us-ch", "20.11684023368047", "U.S. Surveyor's Chain", 79200 / 3937.0},
30
    {"us-mi", "1609.347218694437", "U.S. Surveyor's Statute Mile",
31
     6336000 / 3937.0},
32
    {"ind-yd", "0.91439523", "Indian Yard", 0.91439523},
33
    {"ind-ft", "0.30479841", "Indian Foot", 0.30479841},
34
    {"ind-ch", "20.11669506", "Indian Chain", 20.11669506},
35
    {nullptr, nullptr, nullptr, 0.0}};
36
37
// For internal use
38
388k
const PJ_UNITS *pj_list_linear_units() { return pj_units; }
39
40
0
const PJ_UNITS *proj_list_units() { return pj_units; }
41
42
/* M_PI / 200 */
43
#define GRAD_TO_RAD 0.015707963267948967
44
45
const struct PJ_UNITS pj_angular_units[] = {
46
    {"rad", "1.0", "Radian", 1.0},
47
    {"deg", "0.017453292519943296", "Degree", DEG_TO_RAD},
48
    {"grad", "0.015707963267948967", "Grad", GRAD_TO_RAD},
49
    {nullptr, nullptr, nullptr, 0.0}};
50
51
// For internal use
52
874k
const PJ_UNITS *pj_list_angular_units() { return pj_angular_units; }
53
54
0
const PJ_UNITS *proj_list_angular_units() { return pj_angular_units; }