Coverage Report

Created: 2026-04-11 06:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PROJ/src/projections/latlong.cpp
Line
Count
Source
1
/******************************************************************************
2
 * Project:  PROJ.4
3
 * Purpose:  Stub projection implementation for lat/long coordinates. We
4
 *           don't actually change the coordinates, but we want proj=latlong
5
 *           to act sort of like a projection.
6
 * Author:   Frank Warmerdam, warmerdam@pobox.com
7
 *
8
 ******************************************************************************
9
 * Copyright (c) 2000, Frank Warmerdam
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a
12
 * copy of this software and associated documentation files (the "Software"),
13
 * to deal in the Software without restriction, including without limitation
14
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
 * and/or sell copies of the Software, and to permit persons to whom the
16
 * Software is furnished to do so, subject to the following conditions:
17
 *
18
 * The above copyright notice and this permission notice shall be included
19
 * in all copies or substantial portions of the Software.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
 * DEALINGS IN THE SOFTWARE.
28
 *****************************************************************************/
29
30
/* very loosely based upon DMA code by Bradford W. Drew */
31
32
#include "proj_internal.h"
33
34
PROJ_HEAD(lonlat, "Lat/long (Geodetic)") "\n\t";
35
PROJ_HEAD(latlon, "Lat/long (Geodetic alias)") "\n\t";
36
PROJ_HEAD(latlong, "Lat/long (Geodetic alias)") "\n\t";
37
PROJ_HEAD(longlat, "Lat/long (Geodetic alias)") "\n\t";
38
39
324k
static PJ_XY latlong_forward(PJ_LP lp, PJ *P) {
40
324k
    PJ_XY xy = {0.0, 0.0};
41
324k
    (void)P;
42
324k
    xy.x = lp.lam;
43
324k
    xy.y = lp.phi;
44
324k
    return xy;
45
324k
}
46
47
97.3k
static PJ_LP latlong_inverse(PJ_XY xy, PJ *P) {
48
97.3k
    PJ_LP lp = {0.0, 0.0};
49
97.3k
    (void)P;
50
97.3k
    lp.phi = xy.y;
51
97.3k
    lp.lam = xy.x;
52
97.3k
    return lp;
53
97.3k
}
54
55
0
static PJ_XYZ latlong_forward_3d(PJ_LPZ lpz, PJ *P) {
56
0
    PJ_XYZ xyz = {0, 0, 0};
57
0
    (void)P;
58
0
    xyz.x = lpz.lam;
59
0
    xyz.y = lpz.phi;
60
0
    xyz.z = lpz.z;
61
0
    return xyz;
62
0
}
63
64
0
static PJ_LPZ latlong_inverse_3d(PJ_XYZ xyz, PJ *P) {
65
0
    PJ_LPZ lpz = {0, 0, 0};
66
0
    (void)P;
67
0
    lpz.lam = xyz.x;
68
0
    lpz.phi = xyz.y;
69
0
    lpz.z = xyz.z;
70
0
    return lpz;
71
0
}
72
73
88.9k
static void latlong_forward_4d(PJ_COORD &, PJ *) {}
74
75
327k
static void latlong_inverse_4d(PJ_COORD &, PJ *) {}
76
77
20.6k
static PJ *latlong_setup(PJ *P) {
78
20.6k
    P->is_latlong = 1;
79
20.6k
    P->x0 = 0;
80
20.6k
    P->y0 = 0;
81
20.6k
    P->inv = latlong_inverse;
82
20.6k
    P->fwd = latlong_forward;
83
20.6k
    P->inv3d = latlong_inverse_3d;
84
20.6k
    P->fwd3d = latlong_forward_3d;
85
20.6k
    P->inv4d = latlong_inverse_4d;
86
20.6k
    P->fwd4d = latlong_forward_4d;
87
20.6k
    P->left = PJ_IO_UNITS_RADIANS;
88
20.6k
    P->right = PJ_IO_UNITS_RADIANS;
89
20.6k
    return P;
90
20.6k
}
91
92
9
PJ *PJ_PROJECTION(latlong) { return latlong_setup(P); }
93
94
3.61k
PJ *PJ_PROJECTION(longlat) { return latlong_setup(P); }
95
96
66
PJ *PJ_PROJECTION(latlon) { return latlong_setup(P); }
97
98
17.0k
PJ *PJ_PROJECTION(lonlat) { return latlong_setup(P); }