A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
geocentric-topocentric-conversion-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 University of Padova
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Matteo Pagin <mattpagg@gmail.com>
18 */
19
20#include <ns3/angles.h>
21#include <ns3/geographic-positions.h>
22#include <ns3/log.h>
23#include <ns3/test.h>
24
25NS_LOG_COMPONENT_DEFINE("GeocentricTopocentricConversionTest");
26
27namespace
28{
29
30/// Test tolerance with respect to the expected values, in meters
31constexpr double TOLERANCE_M = 5;
32/// Test tolerance with respect to the expected values, in degrees
33constexpr double TOLERANCE_DEG = 5e-3;
34
35/**
36 * Reference point 1 for geocentric <--> topocentric conversion.
37 * In particular, this points is used for the example conversion of
38 * Sec. 4.1.3. of "IOGP Publication 373-7-2 – Geomatics Guidance
39 * Note number 7, part 2 – September 2019".
40 */
41const ns3::Vector REFP_1_COORD{55.0, 5.0, 200.0};
42
43/**
44 * Table of <longitude (deg), latitude (deg), altitude (m)> coordinates, obtained as the
45 * cartesian product of the longitude values
46 * (2.1295495 0.0 30.0 60.0 90.0 120.0 150.0 180.0), latitude values
47 * (53.80939444 0.0 20.0 40.0 60.0 80.0) and altitude values
48 * (73.0 500.0 1000.0).
49 * The first coordinate, i.e., (2.1295495, 53.80939444, 73.0) corresponds to that of the
50 * example provided in Sec. 4.1.3. of "IOGP Publication 373-7-2 – Geomatics Guidance
51 * Note number 7, part 2 – September 2019".
52 * This set of coordinates is, in principle, independent from the reference point.
53 */
54const std::vector<ns3::Vector> TEST_COORD = {
55 {53.809394, 2.129549, 73.000000}, {53.809394, 2.129549, 500.000000},
56 {53.809394, 2.129549, 1000.000000}, {0.000000, 2.129549, 73.000000},
57 {0.000000, 2.129549, 500.000000}, {0.000000, 2.129549, 1000.000000},
58 {20.000000, 2.129549, 73.000000}, {20.000000, 2.129549, 500.000000},
59 {20.000000, 2.129549, 1000.000000}, {40.000000, 2.129549, 73.000000},
60 {40.000000, 2.129549, 500.000000}, {40.000000, 2.129549, 1000.000000},
61 {60.000000, 2.129549, 73.000000}, {60.000000, 2.129549, 500.000000},
62 {60.000000, 2.129549, 1000.000000}, {80.000000, 2.129549, 73.000000},
63 {80.000000, 2.129549, 500.000000}, {80.000000, 2.129549, 1000.000000},
64 {53.809394, 0.000000, 73.000000}, {53.809394, 0.000000, 500.000000},
65 {53.809394, 0.000000, 1000.000000}, {0.000000, 0.000000, 73.000000},
66 {0.000000, 0.000000, 500.000000}, {0.000000, 0.000000, 1000.000000},
67 {20.000000, 0.000000, 73.000000}, {20.000000, 0.000000, 500.000000},
68 {20.000000, 0.000000, 1000.000000}, {40.000000, 0.000000, 73.000000},
69 {40.000000, 0.000000, 500.000000}, {40.000000, 0.000000, 1000.000000},
70 {60.000000, 0.000000, 73.000000}, {60.000000, 0.000000, 500.000000},
71 {60.000000, 0.000000, 1000.000000}, {80.000000, 0.000000, 73.000000},
72 {80.000000, 0.000000, 500.000000}, {80.000000, 0.000000, 1000.000000},
73 {53.809394, 30.000000, 73.000000}, {53.809394, 30.000000, 500.000000},
74 {53.809394, 30.000000, 1000.000000}, {0.000000, 30.000000, 73.000000},
75 {0.000000, 30.000000, 500.000000}, {0.000000, 30.000000, 1000.000000},
76 {20.000000, 30.000000, 73.000000}, {20.000000, 30.000000, 500.000000},
77 {20.000000, 30.000000, 1000.000000}, {40.000000, 30.000000, 73.000000},
78 {40.000000, 30.000000, 500.000000}, {40.000000, 30.000000, 1000.000000},
79 {60.000000, 30.000000, 73.000000}, {60.000000, 30.000000, 500.000000},
80 {60.000000, 30.000000, 1000.000000}, {80.000000, 30.000000, 73.000000},
81 {80.000000, 30.000000, 500.000000}, {80.000000, 30.000000, 1000.000000},
82 {53.809394, 60.000000, 73.000000}, {53.809394, 60.000000, 500.000000},
83 {53.809394, 60.000000, 1000.000000}, {0.000000, 60.000000, 73.000000},
84 {0.000000, 60.000000, 500.000000}, {0.000000, 60.000000, 1000.000000},
85 {20.000000, 60.000000, 73.000000}, {20.000000, 60.000000, 500.000000},
86 {20.000000, 60.000000, 1000.000000}, {40.000000, 60.000000, 73.000000},
87 {40.000000, 60.000000, 500.000000}, {40.000000, 60.000000, 1000.000000},
88 {60.000000, 60.000000, 73.000000}, {60.000000, 60.000000, 500.000000},
89 {60.000000, 60.000000, 1000.000000}, {80.000000, 60.000000, 73.000000},
90 {80.000000, 60.000000, 500.000000}, {80.000000, 60.000000, 1000.000000},
91 {53.809394, 90.000000, 73.000000}, {53.809394, 90.000000, 500.000000},
92 {53.809394, 90.000000, 1000.000000}, {0.000000, 90.000000, 73.000000},
93 {0.000000, 90.000000, 500.000000}, {0.000000, 90.000000, 1000.000000},
94 {20.000000, 90.000000, 73.000000}, {20.000000, 90.000000, 500.000000},
95 {20.000000, 90.000000, 1000.000000}, {40.000000, 90.000000, 73.000000},
96 {40.000000, 90.000000, 500.000000}, {40.000000, 90.000000, 1000.000000},
97 {60.000000, 90.000000, 73.000000}, {60.000000, 90.000000, 500.000000},
98 {60.000000, 90.000000, 1000.000000}, {80.000000, 90.000000, 73.000000},
99 {80.000000, 90.000000, 500.000000}, {80.000000, 90.000000, 1000.000000},
100 {53.809394, 120.000000, 73.000000}, {53.809394, 120.000000, 500.000000},
101 {53.809394, 120.000000, 1000.000000}, {0.000000, 120.000000, 73.000000},
102 {0.000000, 120.000000, 500.000000}, {0.000000, 120.000000, 1000.000000},
103 {20.000000, 120.000000, 73.000000}, {20.000000, 120.000000, 500.000000},
104 {20.000000, 120.000000, 1000.000000}, {40.000000, 120.000000, 73.000000},
105 {40.000000, 120.000000, 500.000000}, {40.000000, 120.000000, 1000.000000},
106 {60.000000, 120.000000, 73.000000}, {60.000000, 120.000000, 500.000000},
107 {60.000000, 120.000000, 1000.000000}, {80.000000, 120.000000, 73.000000},
108 {80.000000, 120.000000, 500.000000}, {80.000000, 120.000000, 1000.000000},
109 {53.809394, 150.000000, 73.000000}, {53.809394, 150.000000, 500.000000},
110 {53.809394, 150.000000, 1000.000000}, {0.000000, 150.000000, 73.000000},
111 {0.000000, 150.000000, 500.000000}, {0.000000, 150.000000, 1000.000000},
112 {20.000000, 150.000000, 73.000000}, {20.000000, 150.000000, 500.000000},
113 {20.000000, 150.000000, 1000.000000}, {40.000000, 150.000000, 73.000000},
114 {40.000000, 150.000000, 500.000000}, {40.000000, 150.000000, 1000.000000},
115 {60.000000, 150.000000, 73.000000}, {60.000000, 150.000000, 500.000000},
116 {60.000000, 150.000000, 1000.000000}, {80.000000, 150.000000, 73.000000},
117 {80.000000, 150.000000, 500.000000}, {80.000000, 150.000000, 1000.000000},
118 {53.809394, 180.000000, 73.000000}, {53.809394, 180.000000, 500.000000},
119 {53.809394, 180.000000, 1000.000000}, {0.000000, 180.000000, 73.000000},
120 {0.000000, 180.000000, 500.000000}, {0.000000, 180.000000, 1000.000000},
121 {20.000000, 180.000000, 73.000000}, {20.000000, 180.000000, 500.000000},
122 {20.000000, 180.000000, 1000.000000}, {40.000000, 180.000000, 73.000000},
123 {40.000000, 180.000000, 500.000000}, {40.000000, 180.000000, 1000.000000},
124 {60.000000, 180.000000, 73.000000}, {60.000000, 180.000000, 500.000000},
125 {60.000000, 180.000000, 1000.000000}, {80.000000, 180.000000, 73.000000},
126 {80.000000, 180.000000, 500.000000}, {80.000000, 180.000000, 1000.000000}};
127
128/**
129 * Table of expected geocentric coordinates <U, V, W> (meters) for spheroid type SPHERE
130 * and reference point 1
131 */
132const std::vector<ns3::Vector> SPHERE_REFP_1 = {
133 {-188390.250, -128514.834, -4209.801}, {-188402.876, -128523.447, -3783.074},
134 {-188417.661, -128533.533, -3283.395}, {-319049.537, -5212326.981, -2721486.356},
135 {-319070.921, -5212676.320, -2721241.747}, {-319095.960, -5213085.382, -2720955.318},
136 {-299808.496, -3648142.487, -1156630.460}, {-299828.590, -3648386.992, -1156280.970},
137 {-299852.118, -3648673.297, -1155871.733}, {-244406.125, -1643938.169, -220728.246},
138 {-244422.506, -1644048.348, -220316.032}, {-244441.687, -1644177.364, -219833.344},
139 {-159524.769, 558549.355, -26663.336}, {-159535.460, 558586.790, -26238.115},
140 {-159547.980, 558630.625, -25740.197}, {-55402.371, 2693667.583, -597842.821},
141 {-55406.084, 2693848.117, -597455.881}, {-55410.432, 2694059.516, -597002.790},
142 {-327875.291, -120654.830, -9713.435}, {-327897.266, -120662.917, -9287.077},
143 {-327922.997, -120672.386, -8787.830}, {-555275.338, -5199015.620, -2730807.072},
144 {-555312.553, -5199364.067, -2730563.087}, {-555356.131, -5199772.084, -2730277.390},
145 {-521788.138, -3635633.899, -1165389.067}, {-521823.109, -3635877.566, -1165040.165},
146 {-521864.059, -3636162.889, -1164631.614}, {-425365.587, -1633741.074, -227868.329},
147 {-425394.096, -1633850.571, -227456.592}, {-425427.478, -1633978.786, -226974.465},
148 {-277637.669, 565205.035, -31323.694}, {-277656.277, 565242.916, -30898.785},
149 {-277678.066, 565287.274, -30401.233}, {-96422.551, 2695979.077, -599461.346},
150 {-96429.013, 2696159.766, -599074.515}, {-96436.580, 2696371.345, -598621.550},
151 {1589867.531, 156341.271, -203668.193}, {1589974.086, 156351.749, -203254.835},
152 {1590098.859, 156364.019, -202770.808}, {2692530.529, -4729907.065, -3059280.418},
153 {2692710.987, -4730224.072, -3059058.447}, {2692922.296, -4730595.274, -3058798.529},
154 {2530151.069, -3194816.053, -1474053.046}, {2530320.644, -3195030.175, -1473724.831},
155 {2530519.210, -3195280.903, -1473340.505}, {2062598.050, -1274383.073, -479493.510},
156 {2062736.288, -1274468.485, -479098.638}, {2062898.161, -1274568.498, -478636.259},
157 {1346265.264, 799759.313, -195560.367}, {1346355.493, 799812.914, -195146.465},
158 {1346461.148, 799875.679, -194661.803}, {467553.020, 2777438.922, -656500.144},
159 {467584.356, 2777625.071, -656117.136}, {467621.049, 2777843.044, -655668.648},
160 {3081606.632, 1181688.408, -921623.987}, {3081813.166, 1181767.607, -921258.748},
161 {3082055.010, 1181860.345, -920831.067}, {5218875.015, -2993423.733, -4275179.137},
162 {5219224.793, -2993624.357, -4275038.659}, {5219634.369, -2993859.280, -4274874.164},
163 {4904138.340, -1563055.479, -2616624.101}, {4904467.024, -1563160.237, -2616372.463},
164 {4904851.900, -1563282.906, -2616077.805}, {3997890.204, 55840.334, -1410925.968},
165 {3998158.150, 55844.077, -1410593.522}, {3998471.903, 55848.459, -1410204.241},
166 {2609437.507, 1668000.979, -803509.727}, {2609612.396, 1668112.771, -803136.571},
167 {2609817.184, 1668243.676, -802699.620}, {906248.136, 3078976.088, -867638.741},
168 {906308.874, 3079182.447, -867269.883}, {906379.996, 3079424.084, -866837.965},
169 {3747631.724, 2680645.643, -1971205.143}, {3747882.897, 2680825.304, -1970910.248},
170 {3748177.010, 2681035.681, -1970564.938}, {6346826.155, -454854.928, -6052704.150},
171 {6347251.530, -454885.413, -6052682.805}, {6347749.628, -454921.110, -6052657.809},
172 {5964065.703, 822418.894, -4286951.239}, {5964465.425, 822474.014, -4286811.549},
173 {5964933.484, 822538.557, -4286647.978}, {4861950.908, 2000496.861, -2772589.126},
174 {4862276.764, 2000630.937, -2772347.942}, {4862658.329, 2000787.936, -2772065.524},
175 {3173413.078, 2937285.381, -1692272.233}, {3173625.765, 2937482.243, -1691958.644},
176 {3173874.814, 2937712.761, -1691591.443}, {1102114.796, 3519793.935, -1176302.720},
177 {1102188.661, 3520029.838, -1175954.550}, {1102275.155, 3520306.070, -1175546.856},
178 {3409481.922, 4251568.596, -3071177.236}, {3409710.432, 4251853.543, -3070956.063},
179 {3409978.007, 4252187.205, -3070697.079}, {5774150.353, 2205591.887, -7915569.065},
180 {5774537.346, 2205739.710, -7915672.572}, {5774990.500, 2205912.804, -7915793.774},
181 {5425926.478, 3322421.135, -6037471.653}, {5426290.133, 3322643.809, -6037449.286},
182 {5426715.958, 3322904.552, -6037423.096}, {4423255.791, 4038517.360, -4199626.443},
183 {4423552.246, 4038788.028, -4199480.900}, {4423899.382, 4039104.970, -4199310.476},
184 {2887075.176, 4267508.789, -2623704.691}, {2887268.673, 4267794.805, -2623453.527},
185 {2887495.250, 4268129.718, -2623159.425}, {1002670.686, 3981775.676, -1499785.818},
186 {1002737.887, 3982042.542, -1499459.328}, {1002816.576, 3982355.031, -1499077.021},
187 {2157764.193, 5473529.730, -3926803.634}, {2157908.810, 5473896.575, -3926639.806},
188 {2158078.151, 5474326.136, -3926447.971}, {3654295.626, 4275052.137, -9364620.733},
189 {3654540.543, 4275338.659, -9364821.357}, {3654827.332, 4275674.164, -9365056.280},
190 {3433914.634, 5267077.661, -7399134.812}, {3434144.781, 5267430.669, -7399203.706},
191 {3434414.274, 5267844.028, -7399284.378}, {2799352.858, 5623815.885, -5309664.420},
192 {2799540.475, 5624192.802, -5309593.275}, {2799760.168, 5624634.158, -5309509.966},
193 {1827147.813, 5302238.914, -3348230.524}, {1827270.272, 5302594.279, -3348027.920},
194 {1827413.666, 5303010.398, -3347790.678}, {634561.776, 4341133.678, -1751411.000},
195 {634604.306, 4341424.628, -1751101.374}, {634654.106, 4341765.319, -1750738.814},
196 {327875.291, 6019105.546, -4308819.933}, {327897.266, 6019508.957, -4308681.709},
197 {327922.997, 6019981.334, -4308519.854}, {555275.338, 5199015.620, -10011586.928},
198 {555312.553, 5199364.067, -10011830.913}, {555356.131, 5199772.084, -10012116.610},
199 {521788.138, 6135319.327, -8007084.172}, {521823.109, 6135730.527, -8007193.812},
200 {521864.059, 6136212.025, -8007322.196}, {425365.587, 6331612.976, -5805269.279},
201 {425394.096, 6332037.331, -5805231.350}, {425427.478, 6332534.235, -5805186.936},
202 {277637.669, 5764220.655, -3671713.622}, {277656.277, 5764606.983, -3671532.698},
203 {277678.066, 5765059.358, -3671320.843}, {96422.551, 4501578.253, -1863755.500},
204 {96429.013, 4501879.956, -1863453.404}, {96436.580, 4502233.239, -1863099.661}};
205
206/**
207 * Table of expected geocentric coordinates <U, V, W> (meters) for spheroid type GRS80
208 * and reference point 1
209 */
210const std::vector<ns3::Vector> GRS80_REFP_1 = {
211 {-189013.904, -128642.088, -4220.173}, {-189026.530, -128650.701, -3793.446},
212 {-189041.315, -128660.787, -3293.767}, {-319407.093, -5198061.834, -2710194.751},
213 {-319428.477, -5198411.173, -2709950.141}, {-319453.515, -5198820.235, -2709663.713},
214 {-300262.077, -3641934.701, -1153507.066}, {-300282.171, -3642179.206, -1153157.577},
215 {-300305.699, -3642465.511, -1152748.339}, {-245019.116, -1643718.675, -220614.182},
216 {-245035.496, -1643828.854, -220201.967}, {-245054.677, -1643957.870, -219719.280},
217 {-160105.977, 559428.176, -26712.769}, {-160116.668, 559465.611, -26287.548},
218 {-160129.188, 559509.446, -25789.630}, {-55645.391, 2701392.816, -599873.698},
219 {-55649.104, 2701573.351, -599486.758}, {-55653.452, 2701784.749, -599033.667},
220 {-328960.701, -120756.064, -9742.026}, {-328982.676, -120764.150, -9315.669},
221 {-329008.407, -120773.619, -8816.421}, {-555897.630, -5184735.555, -2719525.912},
222 {-555934.845, -5185084.002, -2719281.927}, {-555978.423, -5185492.019, -2718996.230},
223 {-522577.552, -3629407.189, -1162278.924}, {-522612.523, -3629650.855, -1161930.022},
224 {-522653.473, -3629936.179, -1161521.471}, {-426432.439, -1633496.005, -227772.172},
225 {-426460.948, -1633605.501, -227360.436}, {-426494.330, -1633733.717, -226878.309},
226 {-278649.206, 566108.106, -31390.106}, {-278667.814, 566145.987, -30965.197},
227 {-278689.603, 566190.344, -30467.646}, {-96845.504, 2703714.449, -601499.323},
228 {-96851.967, 2703895.138, -601112.492}, {-96859.534, 2704106.718, -600659.527},
229 {1595130.685, 157157.015, -204338.859}, {1595237.241, 157167.493, -203925.501},
230 {1595362.013, 157179.763, -203441.475}, {2695548.023, -4715101.275, -3048367.375},
231 {2695728.481, -4715418.281, -3048145.405}, {2695939.790, -4715789.483, -3047885.487},
232 {2533978.941, -3187922.428, -1471409.882}, {2534148.516, -3188136.550, -1471081.667},
233 {2534347.082, -3188387.278, -1470697.340}, {2067771.215, -1273236.705, -480028.450},
234 {2067909.453, -1273322.116, -479633.578}, {2068071.326, -1273422.129, -479171.199},
235 {1351170.209, 801516.952, -196225.155}, {1351260.438, 801570.553, -195811.253},
236 {1351366.092, 801633.318, -195326.590}, {469603.923, 2785531.615, -658788.320},
237 {469635.260, 2785717.764, -658405.311}, {469671.953, 2785935.737, -657956.823},
238 {3091808.092, 1185898.498, -924671.400}, {3092014.626, 1185977.696, -924306.160},
239 {3092256.470, 1186070.435, -923878.479}, {5224723.760, -2976671.881, -4265628.741},
240 {5225073.538, -2976872.506, -4265488.263}, {5225483.114, -2977107.429, -4265323.768},
241 {4911557.823, -1553693.159, -2615709.535}, {4911886.507, -1553797.918, -2615457.897},
242 {4912271.382, -1553920.586, -2615163.239}, {4007917.241, 60323.012, -1413797.017},
243 {4008185.186, 60326.755, -1413464.571}, {4008498.940, 60331.137, -1413075.290},
244 {2618944.657, 1672921.945, -806389.500}, {2619119.546, 1673033.737, -806016.344},
245 {2619324.334, 1673164.641, -805579.393}, {910223.359, 3088391.463, -870853.068},
246 {910284.098, 3088597.821, -870484.210}, {910355.220, 3088839.459, -870052.292},
247 {3760038.018, 2689817.934, -1977727.126}, {3760289.190, 2689997.596, -1977432.231},
248 {3760583.303, 2690207.972, -1977086.921}, {6353938.985, -435258.126, -6045145.811},
249 {6354364.360, -435288.611, -6045124.465}, {6354862.458, -435324.308, -6045099.469},
250 {5973088.753, 835390.203, -4288563.715}, {5973488.475, 835445.323, -4288424.025},
251 {5973956.533, 835509.867, -4288260.454}, {4874145.079, 2009856.896, -2778875.338},
252 {4874470.935, 2009990.973, -2778634.153}, {4874852.500, 2010147.972, -2778351.735},
253 {3184975.000, 2946830.821, -1698390.098}, {3185187.687, 2947027.683, -1698076.509},
254 {3185436.736, 2947258.201, -1697709.308}, {1106949.181, 3531142.941, -1180870.991},
255 {1107023.047, 3531378.844, -1180522.820}, {1107109.540, 3531655.076, -1180115.126},
256 {3420768.793, 4265941.326, -3081340.607}, {3420997.302, 4266226.274, -3081119.434},
257 {3421264.877, 4266559.936, -3080860.449}, {5780621.390, 2228170.228, -7910098.421},
258 {5781008.384, 2228318.050, -7910201.928}, {5781461.538, 2228491.145, -7910323.130},
259 {5434135.375, 3339174.703, -6041732.496}, {5434499.030, 3339397.377, -6041710.129},
260 {5434924.855, 3339658.120, -6041683.938}, {4434349.680, 4052988.918, -4209491.781},
261 {4434646.134, 4053259.586, -4209346.239}, {4434993.270, 4053576.528, -4209175.814},
262 {2897593.863, 4281900.727, -2633216.110}, {2897787.360, 4282186.743, -2632964.947},
263 {2898013.937, 4282521.656, -2632670.844}, {1007068.864, 3995151.148, -1505773.035},
264 {1007136.064, 3995418.013, -1505446.544}, {1007214.754, 3995730.502, -1505064.237},
265 {2164907.333, 5491947.684, -3939799.500}, {2165051.950, 5492314.529, -3939635.673},
266 {2165221.290, 5492744.090, -3939443.837}, {3658390.962, 4299949.703, -9360774.028},
267 {3658635.879, 4300236.225, -9360974.652}, {3658922.667, 4300571.730, -9361209.575},
268 {3439109.812, 5286773.305, -7405455.718}, {3439339.959, 5287126.313, -7405524.612},
269 {3439609.452, 5287539.672, -7405605.284}, {2806373.864, 5642263.501, -5322313.825},
270 {2806561.482, 5642640.419, -5322242.679}, {2806781.174, 5643081.775, -5322159.370},
271 {1833804.791, 5320400.758, -3360381.660}, {1833927.250, 5320756.123, -3360179.056},
272 {1834070.644, 5321172.242, -3359941.814}, {637345.258, 4356085.459, -1758501.961},
273 {637387.787, 4356376.410, -1758192.335}, {637437.587, 4356717.101, -1757829.775},
274 {328960.701, 6039329.594, -4323080.440}, {328982.676, 6039733.004, -4322942.215},
275 {329008.407, 6040205.382, -4322780.361}, {555897.630, 5224948.663, -10008465.272},
276 {555934.845, 5225297.110, -10008709.257}, {555978.423, 5225705.128, -10008994.954},
277 {522577.552, 6156328.536, -8014324.846}, {522612.523, 6156739.736, -8014434.486},
278 {522653.473, 6157221.234, -8014562.870}, {426432.439, 6351835.806, -5819161.701},
279 {426460.948, 6352260.161, -5819123.772}, {426494.330, 6352757.065, -5819079.358},
280 {278649.206, 5784065.670, -3685043.327}, {278667.814, 5784451.998, -3684862.403},
281 {278689.603, 5784904.373, -3684650.548}, {96845.504, 4517233.818, -1871339.256},
282 {96851.967, 4517535.522, -1871037.160}, {96859.534, 4517888.805, -1870683.417}};
283
284/**
285 * Table of expected geocentric coordinates <U, V, W> (meters) for spheroid type WGS84
286 * and reference point 1
287 */
288const std::vector<ns3::Vector> WGS_84_REFP_1 = {
289 {-189013.904, -128642.088, -4220.173}, {-189026.530, -128650.701, -3793.446},
290 {-189041.315, -128660.787, -3293.767}, {-319407.093, -5198061.834, -2710194.751},
291 {-319428.477, -5198411.173, -2709950.141}, {-319453.515, -5198820.235, -2709663.713},
292 {-300262.077, -3641934.701, -1153507.066}, {-300282.171, -3642179.206, -1153157.577},
293 {-300305.699, -3642465.511, -1152748.339}, {-245019.116, -1643718.675, -220614.182},
294 {-245035.496, -1643828.854, -220201.967}, {-245054.677, -1643957.870, -219719.280},
295 {-160105.977, 559428.176, -26712.769}, {-160116.668, 559465.611, -26287.548},
296 {-160129.188, 559509.446, -25789.630}, {-55645.391, 2701392.816, -599873.698},
297 {-55649.104, 2701573.351, -599486.758}, {-55653.452, 2701784.749, -599033.667},
298 {-328960.701, -120756.064, -9742.026}, {-328982.676, -120764.150, -9315.669},
299 {-329008.407, -120773.619, -8816.421}, {-555897.630, -5184735.555, -2719525.912},
300 {-555934.845, -5185084.002, -2719281.927}, {-555978.423, -5185492.019, -2718996.230},
301 {-522577.552, -3629407.189, -1162278.924}, {-522612.523, -3629650.855, -1161930.022},
302 {-522653.473, -3629936.179, -1161521.471}, {-426432.439, -1633496.005, -227772.172},
303 {-426460.948, -1633605.501, -227360.436}, {-426494.330, -1633733.717, -226878.309},
304 {-278649.206, 566108.106, -31390.106}, {-278667.814, 566145.987, -30965.197},
305 {-278689.603, 566190.344, -30467.646}, {-96845.504, 2703714.449, -601499.323},
306 {-96851.967, 2703895.138, -601112.492}, {-96859.534, 2704106.718, -600659.527},
307 {1595130.685, 157157.015, -204338.859}, {1595237.241, 157167.493, -203925.501},
308 {1595362.013, 157179.763, -203441.475}, {2695548.023, -4715101.275, -3048367.375},
309 {2695728.481, -4715418.282, -3048145.405}, {2695939.790, -4715789.483, -3047885.487},
310 {2533978.941, -3187922.428, -1471409.882}, {2534148.516, -3188136.550, -1471081.667},
311 {2534347.082, -3188387.278, -1470697.340}, {2067771.214, -1273236.705, -480028.450},
312 {2067909.453, -1273322.116, -479633.578}, {2068071.326, -1273422.129, -479171.199},
313 {1351170.209, 801516.952, -196225.155}, {1351260.438, 801570.553, -195811.253},
314 {1351366.092, 801633.318, -195326.590}, {469603.923, 2785531.615, -658788.320},
315 {469635.260, 2785717.764, -658405.311}, {469671.953, 2785935.737, -657956.823},
316 {3091808.092, 1185898.498, -924671.400}, {3092014.626, 1185977.696, -924306.160},
317 {3092256.470, 1186070.435, -923878.479}, {5224723.760, -2976671.881, -4265628.741},
318 {5225073.538, -2976872.506, -4265488.263}, {5225483.114, -2977107.429, -4265323.768},
319 {4911557.823, -1553693.160, -2615709.535}, {4911886.507, -1553797.918, -2615457.897},
320 {4912271.382, -1553920.586, -2615163.239}, {4007917.241, 60323.012, -1413797.016},
321 {4008185.186, 60326.755, -1413464.571}, {4008498.940, 60331.137, -1413075.290},
322 {2618944.657, 1672921.945, -806389.500}, {2619119.546, 1673033.737, -806016.344},
323 {2619324.334, 1673164.641, -805579.393}, {910223.359, 3088391.463, -870853.068},
324 {910284.098, 3088597.821, -870484.210}, {910355.220, 3088839.459, -870052.292},
325 {3760038.017, 2689817.934, -1977727.126}, {3760289.190, 2689997.596, -1977432.231},
326 {3760583.303, 2690207.972, -1977086.921}, {6353938.985, -435258.126, -6045145.811},
327 {6354364.360, -435288.611, -6045124.465}, {6354862.458, -435324.308, -6045099.470},
328 {5973088.753, 835390.203, -4288563.715}, {5973488.475, 835445.323, -4288424.025},
329 {5973956.533, 835509.867, -4288260.454}, {4874145.079, 2009856.896, -2778875.338},
330 {4874470.935, 2009990.973, -2778634.153}, {4874852.500, 2010147.972, -2778351.735},
331 {3184975.000, 2946830.821, -1698390.098}, {3185187.687, 2947027.683, -1698076.509},
332 {3185436.736, 2947258.201, -1697709.308}, {1106949.181, 3531142.941, -1180870.990},
333 {1107023.047, 3531378.843, -1180522.820}, {1107109.540, 3531655.076, -1180115.126},
334 {3420768.793, 4265941.326, -3081340.607}, {3420997.302, 4266226.274, -3081119.434},
335 {3421264.877, 4266559.936, -3080860.449}, {5780621.390, 2228170.228, -7910098.421},
336 {5781008.384, 2228318.050, -7910201.928}, {5781461.538, 2228491.145, -7910323.130},
337 {5434135.375, 3339174.703, -6041732.496}, {5434499.030, 3339397.377, -6041710.129},
338 {5434924.855, 3339658.120, -6041683.938}, {4434349.679, 4052988.918, -4209491.781},
339 {4434646.134, 4053259.586, -4209346.239}, {4434993.270, 4053576.528, -4209175.814},
340 {2897593.863, 4281900.727, -2633216.110}, {2897787.360, 4282186.743, -2632964.947},
341 {2898013.937, 4282521.656, -2632670.844}, {1007068.864, 3995151.148, -1505773.035},
342 {1007136.064, 3995418.013, -1505446.544}, {1007214.754, 3995730.502, -1505064.237},
343 {2164907.333, 5491947.684, -3939799.500}, {2165051.950, 5492314.529, -3939635.673},
344 {2165221.290, 5492744.090, -3939443.837}, {3658390.962, 4299949.703, -9360774.028},
345 {3658635.879, 4300236.225, -9360974.652}, {3658922.667, 4300571.730, -9361209.575},
346 {3439109.812, 5286773.305, -7405455.718}, {3439339.959, 5287126.313, -7405524.612},
347 {3439609.452, 5287539.672, -7405605.284}, {2806373.864, 5642263.501, -5322313.825},
348 {2806561.482, 5642640.419, -5322242.679}, {2806781.174, 5643081.775, -5322159.370},
349 {1833804.791, 5320400.758, -3360381.660}, {1833927.250, 5320756.123, -3360179.056},
350 {1834070.644, 5321172.242, -3359941.814}, {637345.258, 4356085.459, -1758501.961},
351 {637387.787, 4356376.410, -1758192.335}, {637437.587, 4356717.101, -1757829.775},
352 {328960.701, 6039329.593, -4323080.439}, {328982.676, 6039733.004, -4322942.215},
353 {329008.407, 6040205.382, -4322780.361}, {555897.630, 5224948.663, -10008465.272},
354 {555934.845, 5225297.110, -10008709.257}, {555978.423, 5225705.128, -10008994.954},
355 {522577.552, 6156328.536, -8014324.846}, {522612.523, 6156739.736, -8014434.486},
356 {522653.473, 6157221.234, -8014562.870}, {426432.439, 6351835.806, -5819161.701},
357 {426460.948, 6352260.161, -5819123.772}, {426494.330, 6352757.065, -5819079.358},
358 {278649.206, 5784065.670, -3685043.327}, {278667.814, 5784451.998, -3684862.403},
359 {278689.603, 5784904.373, -3684650.548}, {96845.504, 4517233.818, -1871339.256},
360 {96851.967, 4517535.522, -1871037.160}, {96859.534, 4517888.805, -1870683.417}};
361} // namespace
362
363using namespace ns3;
364
365/**
366 * \ingroup mobility-test
367 *
368 * \brief Geographic to/from Topocentric Test Case
369 *
370 * This test verifies the accuracy of the GeographicToTopocentricCoordinates and
371 * TopocentricToGeographicCoordinates methods in the GeographicPositions class,
372 * which convert geocentric (topocentric) coordinates to topocentric (geocentric)
373 * coordinates, respectively. In "IOGP Publication 373-7-2 – Geomatics Guidance Note number 7, part
374 * 2 – September 2019", the two operations are also referred to as EPSG Dataset coordinate operation
375 * method code 9837.
376 *
377 * To this end, the values generated using the above methods are compared with the coordinates
378 * obtained using PROJ coordinate conversion utilities
379 * (https://proj.org/en/latest/operations/conversions/topocentric.html), for both sphere, GRS80 and
380 * WGS84 ellipsoid models. For instance, the coordinate (long, lat, alt) has been first
381 * converted to the topocentric coordinate system with reference point in (LONG_0, LAT_0, ALT_0)
382 * with the command echo $long $lat $alt | cct -d 3 +proj=pipeline +ellps=$ellps +step +proj=cart
383 * +step +proj=topocentric +lon_0=$LONG_0 +lat_0=$LAT_0 +h_0=$ALT_0. Then, the value obtained via
384 * PROJ is used to check both the forward (geo -> topo) and reverse (topo -> geo) conversion
385 */
387{
388 public:
389 /**
390 * @brief Constructor
391 *
392 * @param posToConvert a vector of positions to convert in geocentric coordinates, i.e.,
393 * represented as a vector (latitude (deg), longitude (deg), altitude (m))
394 * @param refPoint the reference point, in geocentric coordinates, i.e., represented as a
395 * vector (latitude (deg), longitude (deg), altitude (m))
396 * @param expectedTopoCoord a vector of the corresponding expected topocentric coordinates,
397 * i.e., represented as (U (m), V (m), W (m)) with respect to the provided reference point
398 * @param sphereType spheroid type
399 */
400 GeoToAndFromTopocentricTestCase(const std::vector<Vector> posToConvert,
401 Vector refPoint,
402 const std::vector<Vector> expectedTopoCoord,
404
405 private:
406 void DoRun() override;
407
408 /**
409 * @brief Test the forward and backward conversion for geocentric to topocentric coordinates
410 * for a given reference point
411 *
412 * @param posToConvert the position to convert, in geocentric coordinates, i.e., represented as
413 * a vector (latitude (deg), longitude (deg), altitude (m))
414 * @param refPoint the reference point, in geocentric coordinates, i.e., represented as a
415 * vector (latitude (deg), longitude (deg), altitude (m))
416 * @param expectedTopoCoord the expected corresponding topocentric coordinates, i.e.,
417 * represented as (U (m), V (m), W (m)) with respect to the provided reference point
418 * @param sphereType spheroid type
419 */
420 void TestReferencePoint(Vector posToConvert,
421 Vector refPoint,
422 Vector expectedTopoCoord,
424
425 /**
426 * Manually check the test condition, i.e. equality between the expected
427 * and the obtained values, up to a given tolerance.
428 * @param actual the obtained test value
429 * @param limit the expected test value
430 * @param tol the tolerance error
431 * @param coord the string to display to describe the value
432 * @return whether the provided values satisfy the equality condition
433 */
434 bool CheckTestPass(double actual, double limit, double tol, std::string coord);
435
436 /// The position to convert, in geocentric coordinates, i.e.,
437 /// represented as a vector (latitude (deg), longitude (deg)///< altitude (m))
438 const std::vector<Vector> m_posToConvertGeoCoord;
439
440 /// The reference point, in geocentric coordinates, i.e., represented
441 /// as a vector (latitude (deg), longitude (deg), altitude (m))
443
444 /// The expected corresponding topocentric coordinates, i.e.,
445 /// represented as (U (m), V (m), W (m)) with respect to the
446 /// provided reference point
447 const std::vector<Vector> m_expectedTopoCoord;
448
450};
451
453 const std::vector<Vector> posToConvert,
454 Vector refPoint,
455 const std::vector<Vector> expectedTopoCoord,
457 : TestCase("Creating GeoToAndFromTopocentricTestCase"),
458 m_posToConvertGeoCoord(posToConvert),
459 m_refPointGeoCoord(refPoint),
460 m_expectedTopoCoord(expectedTopoCoord),
461 m_sphereType(sphereType)
462{
463}
464
465void
467 Vector posToConvert,
468 Vector refPoint,
469 Vector expectedTopoCoord,
471{
472 // Check forward conversion from geocentric to topocentric
473 Vector topoForwardConv =
474 GeographicPositions::GeographicToTopocentricCoordinates(posToConvert, refPoint, sphereType);
475
476 bool passGeoToTopo = (CheckTestPass(topoForwardConv.x, expectedTopoCoord.x, TOLERANCE_M, "U") &&
477 CheckTestPass(topoForwardConv.y, expectedTopoCoord.y, TOLERANCE_M, "V") &&
478 CheckTestPass(topoForwardConv.z, expectedTopoCoord.z, TOLERANCE_M, "W"));
479
480 // Check reverse conversion from topocentric to geocentric
481 Vector geoReverseConv = GeographicPositions::TopocentricToGeographicCoordinates(topoForwardConv,
482 refPoint,
483 sphereType);
484 geoReverseConv.x = WrapTo360(geoReverseConv.x);
485 geoReverseConv.y = WrapTo360(geoReverseConv.y);
486
487 bool passTopoToGeo = (CheckTestPass(geoReverseConv.x, posToConvert.x, TOLERANCE_DEG, "LAT") &&
488 CheckTestPass(geoReverseConv.y, posToConvert.y, TOLERANCE_DEG, "LONG") &&
489 CheckTestPass(geoReverseConv.z, posToConvert.z, TOLERANCE_M, "ALT"));
490
491 std::string geoToTopoMsg = passGeoToTopo ? "PASS" : "FAIL";
492 std::string topoToGeoMsg = passTopoToGeo ? "PASS" : "FAIL";
493
494 std::cout << geoToTopoMsg << " geocentric->topocentric for spheroid " << sphereType << " pos "
495 << posToConvert << " reference point " << refPoint << " expected coord "
496 << expectedTopoCoord << " actual " << topoForwardConv << std::endl;
497 std::cout << topoToGeoMsg << " topocentric->geocentric for spheroid " << sphereType << " pos "
498 << topoForwardConv << " reference point " << refPoint << " expected coord "
499 << posToConvert << " actual " << geoReverseConv << std::endl;
500}
501
502void
504{
505 // Loop through test coordinates
506 for (unsigned int i = 0; i < m_posToConvertGeoCoord.size(); i++)
507 {
512 }
513}
514
515bool
517 double limit,
518 double tol,
519 std::string coord)
520{
521 bool pass = ((actual) < (limit) + (tol) && (actual) > (limit) - (tol));
522
524 limit,
525 tol,
526 "Mismatch between expected " + coord + " and actual coordinates");
527
528 return pass;
529}
530
531/**
532 * \ingroup mobility-test
533 *
534 * \brief Geographic cartesian <--> Topocentric conversion test
535 */
537{
538 public:
540};
541
543 : TestSuite("geographic-topocentric-test", Type::UNIT)
544{
545 NS_LOG_INFO("creating GeoToAndFromTopocentricTestSuite");
546
547 // Test conversion for sphere ellipsoid model
549 REFP_1_COORD, // ref point
550 SPHERE_REFP_1, // expected topo coord
552 TestCase::Duration::QUICK);
553
554 // Test conversion for GRS80 ellipsoid model
556 REFP_1_COORD, // ref point
557 GRS80_REFP_1, // expected topo coord
559 TestCase::Duration::QUICK);
560
561 // Test conversion for WGS84 ellipsoid model
563 REFP_1_COORD, // ref point
564 WGS_84_REFP_1, // expected topo coord
566 TestCase::Duration::QUICK);
567}
568
569/**
570 * \ingroup mobility-test
571 * Static variable for test initialization
572 */
Geographic to/from Topocentric Test Case.
const std::vector< Vector > m_expectedTopoCoord
The expected corresponding topocentric coordinates, i.e., represented as (U (m), V (m),...
GeoToAndFromTopocentricTestCase(const std::vector< Vector > posToConvert, Vector refPoint, const std::vector< Vector > expectedTopoCoord, GeographicPositions::EarthSpheroidType sphereType)
Constructor.
void TestReferencePoint(Vector posToConvert, Vector refPoint, Vector expectedTopoCoord, GeographicPositions::EarthSpheroidType sphereType)
Test the forward and backward conversion for geocentric to topocentric coordinates for a given refere...
void DoRun() override
Implementation to actually run this TestCase.
GeographicPositions::EarthSpheroidType m_sphereType
spheroid type
const std::vector< Vector > m_posToConvertGeoCoord
The position to convert, in geocentric coordinates, i.e., represented as a vector (latitude (deg),...
Vector m_refPointGeoCoord
The reference point, in geocentric coordinates, i.e., represented as a vector (latitude (deg),...
bool CheckTestPass(double actual, double limit, double tol, std::string coord)
Manually check the test condition, i.e.
Geographic cartesian <--> Topocentric conversion test.
EarthSpheroidType
The possible Earth spheroid models. .
static Vector TopocentricToGeographicCoordinates(Vector pos, Vector refPoint, EarthSpheroidType sphType)
Conversion from topocentric to geographic.
static Vector GeographicToTopocentricCoordinates(Vector pos, Vector refPoint, EarthSpheroidType sphType)
Conversion from geographic to topocentric coordinates.
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:302
A suite of tests to run.
Definition: test.h:1273
Type
Type of test.
Definition: test.h:1280
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
static GeoToAndFromTopocentricTestSuite g_GeoToAndFromTopocentricTestSuite
Static variable for test initialization.
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Definition: test.h:511
const std::vector< ns3::Vector > WGS_84_REFP_1
Table of expected geocentric coordinates <U, V, W> (meters) for spheroid type WGS84 and reference poi...
constexpr double TOLERANCE_DEG
Test tolerance with respect to the expected values, in degrees.
const ns3::Vector REFP_1_COORD
Reference point 1 for geocentric <--> topocentric conversion.
const std::vector< ns3::Vector > GRS80_REFP_1
Table of expected geocentric coordinates <U, V, W> (meters) for spheroid type GRS80 and reference poi...
const std::vector< ns3::Vector > SPHERE_REFP_1
Table of expected geocentric coordinates <U, V, W> (meters) for spheroid type SPHERE and reference po...
const std::vector< ns3::Vector > TEST_COORD
Table of <longitude (deg), latitude (deg), altitude (m)> coordinates, obtained as the cartesian produ...
constexpr double TOLERANCE_M
Test tolerance with respect to the expected values, in meters.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double WrapTo360(double a)
Wrap angle in [0, 360)
Definition: angles.cc:75