INSTINCT Code Coverage Report


Directory: src/
File: Nodes/DataProvider/GNSS/FileReader/RinexObsFile.cpp
Date: 2025-06-02 15:19:59
Exec Total Coverage
Lines: 299 391 76.5%
Functions: 17 21 81.0%
Branches: 486 1040 46.7%

Line Branch Exec Source
1 // This file is part of INSTINCT, the INS Toolkit for Integrated
2 // Navigation Concepts and Training by the Institute of Navigation of
3 // the University of Stuttgart, Germany.
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9 #include "RinexObsFile.hpp"
10
11 #include "util/Eigen.hpp"
12
13 #include "internal/NodeManager.hpp"
14 #include "util/Logger.hpp"
15 namespace nm = NAV::NodeManager;
16 #include "internal/FlowManager.hpp"
17 #include "internal/gui/widgets/HelpMarker.hpp"
18
19 #include "util/StringUtil.hpp"
20
21 #include "Navigation/GNSS/Core/SatelliteSystem.hpp"
22 #include "Navigation/GNSS/Core/Code.hpp"
23 #include "NodeData/GNSS/GnssObs.hpp"
24
25 #include "util/Vendor/RINEX/RINEXUtilities.hpp"
26
27 namespace NAV
28 {
29
30 159 RinexObsFile::RinexObsFile()
31
4/8
✓ Branch 1 taken 159 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 159 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 159 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 159 times.
✗ Branch 14 not taken.
159 : Node(typeStatic())
32 {
33 LOG_TRACE("{}: called", name);
34
35 159 _hasConfig = true;
36 159 _guiConfigDefaultWindowSize = { 517, 118 };
37
38
4/8
✓ Branch 1 taken 159 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 159 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 159 times.
✓ Branch 9 taken 159 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
477 nm::CreateOutputPin(this, "GnssObs", Pin::Type::Flow, { NAV::GnssObs::type() }, &RinexObsFile::pollData);
39 318 }
40
41 412 RinexObsFile::~RinexObsFile()
42 {
43 LOG_TRACE("{}: called", nameId());
44 412 }
45
46 271 std::string RinexObsFile::typeStatic()
47 {
48
1/2
✓ Branch 1 taken 271 times.
✗ Branch 2 not taken.
542 return "RinexObsFile";
49 }
50
51 std::string RinexObsFile::type() const
52 {
53 return typeStatic();
54 }
55
56 112 std::string RinexObsFile::category()
57 {
58
1/2
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
224 return "Data Provider";
59 }
60
61 void RinexObsFile::guiConfig()
62 {
63 if (auto res = FileReader::guiConfig(R"(Rinex Obs (.obs .rnx .*o){.obs,.rnx,(.+[.]\d\d?[oO])},.*)",
64 { ".obs", ".rnx", "(.+[.]\\d\\d?[oO])" }, size_t(id), nameId()))
65 {
66 LOG_DEBUG("{}: Path changed to {}", nameId(), _path);
67 flow::ApplyChanges();
68 if (res == FileReader::PATH_CHANGED)
69 {
70 doReinitialize();
71 }
72 else
73 {
74 doDeinitialize();
75 }
76 }
77 ImGui::Text("Supported versions: ");
78 std::ranges::for_each(_supportedVersions, [](double x) {
79 ImGui::SameLine();
80 ImGui::Text("%0.2f", x);
81 });
82
83 ImGui::Checkbox("Erase less precise codes", &_eraseLessPreciseCodes);
84 ImGui::SameLine();
85 gui::widgets::HelpMarker("Whether to remove less precise codes (e.g. if G1X (L1C combined) is present, don't use G1L (L1C pilot) and G1S (L1C data))");
86 }
87
88 [[nodiscard]] json RinexObsFile::save() const
89 {
90 LOG_TRACE("{}: called", nameId());
91
92 json j;
93
94 j["FileReader"] = FileReader::save();
95 j["eraseLessPreciseCodes"] = _eraseLessPreciseCodes;
96
97 return j;
98 }
99
100 47 void RinexObsFile::restore(json const& j)
101 {
102 LOG_TRACE("{}: called", nameId());
103
104
1/2
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
47 if (j.contains("FileReader"))
105 {
106 47 FileReader::restore(j.at("FileReader"));
107 }
108
1/2
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
47 if (j.contains("eraseLessPreciseCodes"))
109 {
110 47 j.at("eraseLessPreciseCodes").get_to(_eraseLessPreciseCodes);
111 }
112 47 }
113
114 47 bool RinexObsFile::initialize()
115 {
116 LOG_TRACE("{}: called", nameId());
117
118 47 return FileReader::initialize();
119 }
120
121 47 void RinexObsFile::deinitialize()
122 {
123 LOG_TRACE("{}: called", nameId());
124
125 47 FileReader::deinitialize();
126
127 47 _version = 0.0;
128 47 _timeSystem = TimeSys_None;
129 47 _obsDescription.clear();
130 47 _rcvClockOffsAppl = false;
131 47 _receiverInfo = {};
132 94 }
133
134 94 bool RinexObsFile::resetNode()
135 {
136 LOG_TRACE("{}: called", nameId());
137
138 94 FileReader::resetReader();
139
140 94 return true;
141 }
142
143 46 FileReader::FileType RinexObsFile::determineFileType()
144 {
145 1571 auto extHeaderLabel = [](std::string line) {
146 // Remove any trailing non text characters
147
2/4
✓ Branch 3 taken 1574 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1573 times.
✗ Branch 8 not taken.
116885 line.erase(std::ranges::find_if(line, [](int ch) { return std::iscntrl(ch); }), line.end());
148
149
1/2
✓ Branch 2 taken 1573 times.
✗ Branch 3 not taken.
1573 return str::trim_copy(std::string_view(line).substr(60, 20));
150 };
151
152
1/2
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
46 std::filesystem::path filepath = getFilepath();
153
154
1/2
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
47 auto filestreamHeader = std::ifstream(filepath);
155
1/2
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
46 if (filestreamHeader.good())
156 {
157 46 std::string line;
158 // --------------------------------------- RINEX VERSION / TYPE ------------------------------------------
159
1/2
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
47 std::getline(filestreamHeader, line);
160
1/2
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
47 str::rtrim(line);
161
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
46 if (line.size() != 80)
162 {
163 LOG_ERROR("{}: Not a valid RINEX OBS file. Lines should be 80 characters long but the file has {}.", nameId(), line.size() - 1);
164 return FileReader::FileType::NONE;
165 }
166
167
3/6
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 42 times.
46 if (extHeaderLabel(line) != "RINEX VERSION / TYPE")
168 {
169 LOG_ERROR("{}: Not a valid RINEX OBS file. Could not read 'RINEX VERSION / TYPE' line.", nameId());
170 return FileReader::FileType::NONE;
171 }
172
173
3/6
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 44 times.
✗ Branch 8 not taken.
42 double version = std::stod(str::trim_copy(line.substr(0, 20))); // FORMAT: F9.2,11X
174
2/4
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 45 times.
44 if (!_supportedVersions.contains(version))
175 {
176 LOG_ERROR("{}: RINEX version {} is not supported. Supported versions are [{}]", nameId(),
177 version, fmt::join(_supportedVersions.begin(), _supportedVersions.end(), ", "));
178 return FileReader::FileType::NONE;
179 }
180
181
2/4
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
45 std::string fileType = str::trim_copy(line.substr(20, 20)); // FORMAT: A1,19X
182
2/4
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
45 if (fileType.at(0) != 'O')
183 {
184 LOG_ERROR("{}: Not a valid RINEX OBS file. File type '{}' not recognized.", nameId(), fileType);
185 doDeinitialize();
186 return FileReader::FileType::NONE;
187 }
188
2/4
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
44 std::string satSystem = str::trim_copy(line.substr(40, 20)); // FORMAT: A1,19X
189
7/12
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 43 times.
✓ Branch 8 taken 3 times.
✓ Branch 10 taken 41 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 41 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 44 times.
46 if (SatelliteSystem::fromChar(satSystem.at(0)) == SatSys_None && satSystem.at(0) != 'M')
190 {
191 LOG_ERROR("{}: Not a valid RINEX OBS file. Satellite System '{}' not recognized.", nameId(), satSystem.at(0));
192 doDeinitialize();
193 return FileReader::FileType::NONE;
194 }
195 // ---------------------------------------- PGM / RUN BY / DATE ------------------------------------------
196
1/2
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
44 std::getline(filestreamHeader, line);
197
1/2
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
43 str::rtrim(line);
198
3/6
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 46 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 46 times.
44 if (extHeaderLabel(line) != "PGM / RUN BY / DATE")
199 {
200 LOG_ERROR("{}: Not a valid RINEX OBS file. Could not read 'PGM / RUN BY / DATE' line.", nameId());
201 return FileReader::FileType::NONE;
202 }
203
204 // ----------------------------------------- END OF HEADER -------------------------------------------
205
4/6
✓ Branch 1 taken 1479 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1478 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1477 times.
✓ Branch 7 taken 1 times.
1480 while (std::getline(filestreamHeader, line))
206 {
207
1/2
✓ Branch 1 taken 1481 times.
✗ Branch 2 not taken.
1477 str::rtrim(line);
208
4/6
✓ Branch 2 taken 1479 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1481 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 47 times.
✓ Branch 10 taken 1434 times.
1481 if (extHeaderLabel(line) == "END OF HEADER")
209 {
210 47 return FileReader::FileType::ASCII;
211 }
212 }
213
0/6
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1 LOG_ERROR("{}: Not a valid RINEX NAV file. Could not read 'END OF HEADER' line.", nameId());
214 return FileReader::FileType::NONE;
215 47 }
216
217 LOG_ERROR("{}: Could not determine file type because file could not be opened '{}' line.", nameId(), filepath.string());
218 return FileReader::FileType::NONE;
219 47 }
220
221 47 void RinexObsFile::readHeader()
222 {
223 LOG_TRACE("{}: called", nameId());
224
225 47 std::string line;
226
227 // --------------------------------------- RINEX VERSION / TYPE ------------------------------------------
228
1/2
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
47 getline(line);
229
3/6
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 45 times.
✗ Branch 8 not taken.
47 _version = std::stod(str::trim_copy(line.substr(0, 20)));
230
3/6
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 47 times.
✗ Branch 9 not taken.
45 LOG_DEBUG("{}: Version: {:3.2f}", nameId(), _version); // FORMAT: F9.2,11X
231
5/10
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 47 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 47 times.
✗ Branch 11 not taken.
✓ Branch 14 taken 47 times.
✗ Branch 15 not taken.
47 LOG_DEBUG("{}: SatSys : {}", nameId(), str::trim_copy(line.substr(40, 20))); // FORMAT: A1,19X
232
233 // #######################################################################################################
234
7/12
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1427 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1426 times.
✓ Branch 7 taken 1 times.
✓ Branch 9 taken 1428 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1428 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1431 times.
✗ Branch 14 not taken.
1433 while (getline(line) && !eof())
235 {
236
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1430 times.
1431 if (line.size() < 60)
237 {
238 LOG_WARN("{}: Skipping header line because it does not include a header label: '{}'", nameId(), line);
239 continue;
240 }
241
2/4
✓ Branch 1 taken 1432 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1430 times.
✗ Branch 5 not taken.
1430 auto headerLabel = str::trim_copy(line.substr(60, 20));
242
3/4
✓ Branch 1 taken 1429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1383 times.
✓ Branch 4 taken 46 times.
1430 if (headerLabel == "PGM / RUN BY / DATE")
243 {
244 // Name of program creating current file
245 LOG_DATA("{}: Program: {}", nameId(), str::trim_copy(line.substr(0, 20))); // FORMAT: A20
246 // Name of agency creating current file
247 LOG_DATA("{}: Run by : {}", nameId(), str::trim_copy(line.substr(20, 20))); // FORMAT: A20
248 // Date and time of file creation
249 LOG_DATA("{}: Date : {}", nameId(), str::trim_copy(line.substr(40, 20))); // FORMAT: A20
250 }
251
3/4
✓ Branch 1 taken 1384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1294 times.
✓ Branch 4 taken 90 times.
1383 else if (headerLabel == "COMMENT")
252 {
253 LOG_DATA("{}: Comment: {}", nameId(), line.substr(0, 60)); // FORMAT: A60
254 }
255
3/4
✓ Branch 1 taken 1293 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 1246 times.
1294 else if (headerLabel == "MARKER NAME")
256 {
257
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 auto markerName = str::trim_copy(line.substr(0, 60)); // FORMAT: A60
258 47 if (!markerName.empty())
259 {
260 LOG_DATA("{}: Marker name: {}", nameId(), markerName);
261 }
262 47 }
263
3/4
✓ Branch 1 taken 1247 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 1210 times.
1246 else if (headerLabel == "MARKER NUMBER")
264 {
265
2/4
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
37 auto markerNumber = str::trim_copy(line.substr(0, 20)); // FORMAT: A20
266 37 if (!markerNumber.empty())
267 {
268 LOG_DATA("{}: Marker number: {}", nameId(), markerNumber);
269 }
270 37 }
271
3/4
✓ Branch 1 taken 1210 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✓ Branch 4 taken 1168 times.
1210 else if (headerLabel == "MARKER TYPE")
272 {
273
2/4
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
42 auto markerType = str::trim_copy(line.substr(0, 60)); // FORMAT: A20,40X
274 42 if (!markerType.empty())
275 {
276 LOG_DATA("{}: Marker type: {}", nameId(), markerType);
277 }
278 42 }
279
3/4
✓ Branch 1 taken 1168 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 1121 times.
1168 else if (headerLabel == "OBSERVER / AGENCY")
280 {
281
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 auto observer = str::trim_copy(line.substr(0, 20)); // FORMAT: A20,A40
282
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 auto agency = str::trim_copy(line.substr(20, 40));
283
3/4
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 34 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
47 if (!observer.empty() || !agency.empty())
284 {
285 LOG_DATA("{}: Observer '{}', Agency '{}'", nameId(), observer, agency);
286 }
287 47 }
288
3/4
✓ Branch 1 taken 1121 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 1074 times.
1121 else if (headerLabel == "REC # / TYPE / VERS")
289 {
290
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 auto receiverNumber = str::trim_copy(line.substr(0, 20)); // FORMAT: 3A20
291
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 auto receiverType = str::trim_copy(line.substr(20, 20));
292
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 auto receiverVersion = str::trim_copy(line.substr(40, 20));
293
5/6
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 33 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
47 if (!receiverNumber.empty() || !receiverType.empty() || !receiverVersion.empty())
294 {
295 LOG_DATA("{}: RecNum '{}', recType '{}', recVersion '{}'", nameId(),
296 receiverNumber, receiverType, receiverVersion);
297 }
298 47 }
299
3/4
✓ Branch 1 taken 1074 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 1027 times.
1074 else if (headerLabel == "ANT # / TYPE")
300 {
301
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 auto antennaNumber = str::trim_copy(line.substr(0, 20)); // FORMAT: 2A20
302
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 auto antennaType = str::trim_copy(line.substr(20, 20));
303
4/4
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 30 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 14 times.
47 if (!antennaNumber.empty() || !antennaType.empty())
304 {
305 LOG_DATA("{}: antNum '{}', antType '{}'", nameId(), antennaNumber, antennaType);
306 }
307
5/8
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 33 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 47 times.
✗ Branch 9 not taken.
47 if (!antennaType.empty() || antennaType != "Unknown")
308 {
309
1/2
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
47 _receiverInfo.antennaType = antennaType;
310 }
311 47 }
312
3/4
✓ Branch 1 taken 1026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✓ Branch 4 taken 984 times.
1027 else if (headerLabel == "APPROX POSITION XYZ")
313 {
314 // Geocentric approximate marker position (Units: Meters, System: ITRS recommended)
315 // Optional for moving platforms
316
3/6
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 42 times.
✗ Branch 8 not taken.
84 Eigen::Vector3d position_xyz{ std::stod(str::trim_copy(line.substr(0, 14))),
317
3/6
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 42 times.
✗ Branch 8 not taken.
84 std::stod(str::trim_copy(line.substr(14, 14))),
318
4/8
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 42 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 41 times.
✗ Branch 11 not taken.
42 std::stod(str::trim_copy(line.substr(28, 14))) }; // FORMAT: 3F14.4
319
320 LOG_DATA("{}: Approx Position XYZ: {} (not used yet)", nameId(), position_xyz.transpose());
321
322
1/2
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
42 _receiverInfo.e_approxPos = position_xyz;
323 }
324
3/4
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 936 times.
984 else if (headerLabel == "ANTENNA: DELTA H/E/N")
325 {
326 // Antenna height: Height of the antenna reference point (ARP) above the marker [m]
327
3/6
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 47 times.
✗ Branch 8 not taken.
47 double antennaHeight = std::stod(str::trim_copy(line.substr(0, 14))); // FORMAT: F14.4,
328 // Horizontal eccentricity of ARP relative to the marker (east) [m]
329
3/6
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 47 times.
✗ Branch 8 not taken.
47 double antennaEccentricityEast = std::stod(str::trim_copy(line.substr(14, 14))); // FORMAT: 2F14.4,
330 // Horizontal eccentricity of ARP relative to the marker (north) [m]
331
3/6
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 47 times.
✗ Branch 8 not taken.
47 double antennaEccentricityNorth = std::stod(str::trim_copy(line.substr(28, 14)));
332
333 LOG_DATA("{}: Antenna delta H/E/N: {}, {}, {} (not used yet)", nameId(),
334 antennaHeight, antennaEccentricityEast, antennaEccentricityNorth);
335
336
1/2
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
47 _receiverInfo.antennaDeltaNEU = Eigen::Vector3d(antennaEccentricityNorth, antennaEccentricityEast, antennaHeight);
337 }
338
2/4
✓ Branch 1 taken 939 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 939 times.
936 else if (headerLabel == "ANTENNA: DELTA X/Y/Z")
339 {
340 // Position of antenna reference point for antenna on vehicle (m): XYZ vector in body-fixed coordinate system
341 [[maybe_unused]] Eigen::Vector3d antennaDeltaXYZ{ std::stod(str::trim_copy(line.substr(0, 14))),
342 std::stod(str::trim_copy(line.substr(14, 14))),
343 std::stod(str::trim_copy(line.substr(28, 14))) }; // FORMAT: 3F14.4
344
345 LOG_DATA("{}: Antenna Delta XYZ: {} (not used yet)", nameId(), antennaDeltaXYZ.transpose());
346 }
347
2/4
✓ Branch 1 taken 939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 939 times.
✗ Branch 4 not taken.
939 else if (headerLabel == "ANTENNA: PHASECENTER")
348 {
349 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "ANTENNA: PHASECENTER");
350 }
351
2/4
✓ Branch 1 taken 939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 939 times.
✗ Branch 4 not taken.
939 else if (headerLabel == "ANTENNA: B.SIGHT XYZ")
352 {
353 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "ANTENNA: B.SIGHT XYZ");
354 }
355
2/4
✓ Branch 1 taken 939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 939 times.
✗ Branch 4 not taken.
939 else if (headerLabel == "ANTENNA: ZERODIR AZI")
356 {
357 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "ANTENNA: ZERODIR AZI");
358 }
359
2/4
✓ Branch 1 taken 939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 939 times.
✗ Branch 4 not taken.
939 else if (headerLabel == "ANTENNA: ZERODIR XYZ")
360 {
361 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "ANTENNA: ZERODIR XYZ");
362 }
363
2/4
✓ Branch 1 taken 940 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 940 times.
✗ Branch 4 not taken.
939 else if (headerLabel == "CENTER OF MASS: XYZ")
364 {
365 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "CENTER OF MASS: XYZ");
366 }
367
3/4
✓ Branch 1 taken 936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 218 times.
✓ Branch 4 taken 718 times.
940 else if (headerLabel == "SYS / # / OBS TYPES")
368 {
369 // Satellite system code (G/R/E/J/C/I/S) - FORMAT: A1,
370
2/4
✓ Branch 1 taken 219 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 221 times.
✗ Branch 5 not taken.
218 auto satSys = SatelliteSystem::fromChar(line.at(0));
371
372 // Number of different observation types for the specified satellite system - Format: 2X,I3,
373
2/4
✓ Branch 1 taken 221 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 221 times.
✗ Branch 5 not taken.
221 size_t numSpecifications = std::stoul(line.substr(3, 3));
374
375 221 std::string debugOutput;
376
2/2
✓ Branch 0 taken 2763 times.
✓ Branch 1 taken 221 times.
2984 for (size_t n = 0, nLine = 1, i = 7; n < numSpecifications; n++, nLine++, i += 4)
377 {
378 // Observation descriptors: Type, Band, Attribute - FORMAT 13(1X,A3)
379
380
2/4
✓ Branch 1 taken 2762 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2759 times.
✗ Branch 5 not taken.
2763 NAV::vendor::RINEX::ObsType type = NAV::vendor::RINEX::obsTypeFromChar(line.at(i));
381
2/4
✓ Branch 1 taken 2753 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2744 times.
✗ Branch 5 not taken.
2759 Frequency freq = NAV::vendor::RINEX::getFrequencyFromBand(satSys, line.at(i + 1) - '0');
382
1/2
✓ Branch 1 taken 2752 times.
✗ Branch 2 not taken.
2744 auto attribute = line.at(i + 2);
383
4/6
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 2717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2765 times.
2752 if (freq == B01 && attribute == 'I') { freq = B02; }
384
1/2
✓ Branch 1 taken 2762 times.
✗ Branch 2 not taken.
2765 Code code = Code::fromFreqAttr(freq, attribute);
385
386
2/4
✓ Branch 1 taken 2752 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2752 times.
✗ Branch 5 not taken.
2762 _obsDescription[satSys].push_back(NAV::vendor::RINEX::ObservationDescription{ .type = type, .code = code });
387
388
2/4
✓ Branch 1 taken 2754 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2756 times.
✗ Branch 6 not taken.
5513 debugOutput += fmt::format("({},{},{})", NAV::vendor::RINEX::obsTypeToChar(type), freq, code);
389
390
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2668 times.
2761 if (nLine == 13)
391 {
392
1/2
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
93 getline(line);
393 96 nLine = 0;
394 96 i = 3;
395 }
396 }
397
398 LOG_DATA("{}: Obs Type {} with {} specifications [{}]", nameId(),
399 satSys, numSpecifications, debugOutput);
400 221 }
401
3/4
✓ Branch 1 taken 718 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 693 times.
✓ Branch 4 taken 25 times.
718 else if (headerLabel == "SIGNAL STRENGTH UNIT")
402 {
403 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SIGNAL STRENGTH UNIT");
404 }
405
3/4
✓ Branch 1 taken 693 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 660 times.
✓ Branch 4 taken 33 times.
693 else if (headerLabel == "INTERVAL")
406 {
407 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "INTERVAL");
408 }
409
3/4
✓ Branch 1 taken 660 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 613 times.
660 else if (headerLabel == "TIME OF FIRST OBS")
410 {
411
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 [[maybe_unused]] auto year = std::stoi(line.substr(0, 6));
412
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 [[maybe_unused]] auto month = std::stoi(line.substr(6, 6));
413
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 [[maybe_unused]] auto day = std::stoi(line.substr(12, 6));
414
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 [[maybe_unused]] auto hour = std::stoi(line.substr(18, 6));
415
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 [[maybe_unused]] auto min = std::stoi(line.substr(24, 6));
416
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 [[maybe_unused]] auto sec = std::stold(line.substr(30, 13));
417
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
47 _timeSystem = TimeSystem::fromString(line.substr(30 + 13 + 5, 3));
418 LOG_DATA("{}: Time of first obs: {} GPST (originally in '{}' time)", nameId(),
419 InsTime{ static_cast<uint16_t>(year),
420 static_cast<uint16_t>(month),
421 static_cast<uint16_t>(day),
422 static_cast<uint16_t>(hour),
423 static_cast<uint16_t>(min),
424 sec,
425 _timeSystem }
426 .toYMDHMS(GPST),
427 std::string(_timeSystem));
428 }
429
3/4
✓ Branch 1 taken 613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 574 times.
✓ Branch 4 taken 39 times.
613 else if (headerLabel == "TIME OF LAST OBS")
430 {
431 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "TIME OF LAST OBS");
432 }
433
2/4
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 574 times.
574 else if (headerLabel == "RCV CLOCK OFFS APPL")
434 {
435 if (str::stoi(line.substr(0, 6), 0))
436 {
437 _rcvClockOffsAppl = true;
438 LOG_INFO("{}: Data (epoch, pseudorange, phase) corrected by the reported clock offset.", nameId());
439 }
440 LOG_TRACE("{}: Receiver clock offset applies: {}", nameId(), _rcvClockOffsAppl);
441 }
442
2/4
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 574 times.
✗ Branch 4 not taken.
574 else if (headerLabel == "SYS / DCBS APPLIED")
443 {
444 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SYS / DCBS APPLIED");
445 }
446
2/4
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 574 times.
✗ Branch 4 not taken.
574 else if (headerLabel == "SYS / PCVS APPLIED")
447 {
448 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SYS / PCVS APPLIED");
449 }
450
2/4
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 574 times.
✗ Branch 4 not taken.
574 else if (headerLabel == "SYS / SCALE FACTOR")
451 {
452 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SYS / SCALE FACTOR");
453 }
454
3/4
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 395 times.
574 else if (headerLabel == "SYS / PHASE SHIFT")
455 {
456 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SYS / PHASE SHIFT");
457 }
458
3/4
✓ Branch 1 taken 179 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
✓ Branch 4 taken 52 times.
179 else if (headerLabel == "GLONASS SLOT / FRQ #")
459 {
460 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "GLONASS SLOT / FRQ #");
461 }
462
3/4
✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87 times.
✓ Branch 4 taken 40 times.
127 else if (headerLabel == "GLONASS COD/PHS/BIS")
463 {
464 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "GLONASS COD/PHS/BIS");
465 }
466
3/4
✓ Branch 1 taken 87 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
✓ Branch 4 taken 20 times.
87 else if (headerLabel == "LEAP SECONDS")
467 {
468 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "LEAP SECONDS");
469 }
470
3/4
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 20 times.
67 else if (headerLabel == "# OF SATELLITES")
471 {
472 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "# OF SATELLITES");
473 }
474
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
47 else if (headerLabel == "PRN / # OF OBS")
475 {
476 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "PRN / # OF OBS");
477 }
478
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
47 else if (headerLabel == "END OF HEADER")
479 {
480 47 break;
481 }
482 else
483 {
484 LOG_WARN("{}: Unknown header label '{}' in line '{}'", nameId(), headerLabel, line);
485 }
486 1432 }
487
488
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
44 if (_timeSystem == TimeSys_None) // If time system not set, try to apply default value
489 {
490 if (_obsDescription.size() == 1)
491 {
492 switch (SatelliteSystem_(_obsDescription.begin()->first))
493 {
494 case GPS:
495 _timeSystem = GPST;
496 break;
497 case GLO:
498 _timeSystem = GLNT;
499 break;
500 case GAL:
501 _timeSystem = UTC;
502 break;
503 case QZSS:
504 _timeSystem = QZSST;
505 break;
506 case BDS:
507 _timeSystem = BDT;
508 break;
509 case IRNSS:
510 _timeSystem = IRNSST;
511 break;
512 default:
513 LOG_CRITICAL("{}: Could not determine time system of the file because satellite system '{}' has no default.",
514 nameId(), SatelliteSystem(_obsDescription.begin()->first));
515 break;
516 }
517 }
518 else
519 {
520 LOG_CRITICAL("{}: Could not determine time system of the file.", nameId());
521 }
522 }
523 47 }
524
525 7428 std::shared_ptr<const NodeData> RinexObsFile::pollData()
526 {
527 7428 std::string line;
528
529 7429 InsTime epochTime;
530
531 // 0: OK | 1: power failure between previous and current epoch | > 1 : Special event
532 7429 int epochFlag = -1;
533 7429 size_t nSatellites = 0;
534
10/14
✓ Branch 0 taken 7429 times.
✓ Branch 1 taken 7380 times.
✓ Branch 3 taken 7428 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7381 times.
✓ Branch 6 taken 47 times.
✓ Branch 8 taken 7382 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7382 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7382 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 7382 times.
✓ Branch 16 taken 7427 times.
14809 while (epochFlag != 0 && !eof() && getline(line)) // Read lines till epoch record with valid epoch flag
535 {
536
1/2
✓ Branch 1 taken 7382 times.
✗ Branch 2 not taken.
7382 str::trim(line);
537
538
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7382 times.
7382 if (line.empty())
539 {
540 continue;
541 }
542
2/4
✓ Branch 1 taken 7382 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7382 times.
✗ Branch 4 not taken.
7382 if (line.at(0) == '>') // EPOCH record - Record identifier: > - Format: A1,
543 {
544
2/4
✓ Branch 1 taken 7382 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7382 times.
✗ Branch 5 not taken.
7382 auto year = std::stoi(line.substr(2, 4)); // Format: 1X,I4,
545
2/4
✓ Branch 1 taken 7382 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7382 times.
✗ Branch 5 not taken.
7382 auto month = std::stoi(line.substr(7, 2)); // Format: 1X,I2.2,
546
2/4
✓ Branch 1 taken 7382 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7382 times.
✗ Branch 5 not taken.
7382 auto day = std::stoi(line.substr(10, 2)); // Format: 1X,I2.2,
547
2/4
✓ Branch 1 taken 7382 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7382 times.
✗ Branch 5 not taken.
7382 auto hour = std::stoi(line.substr(13, 2)); // Format: 1X,I2.2,
548
2/4
✓ Branch 1 taken 7382 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7382 times.
✗ Branch 5 not taken.
7382 auto min = std::stoi(line.substr(16, 2)); // Format: 1X,I2.2,
549
2/4
✓ Branch 1 taken 7382 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7382 times.
✗ Branch 5 not taken.
7382 auto sec = std::stold(line.substr(18, 11)); // Format: F11.7,2X,I1,
550
2/4
✓ Branch 1 taken 7381 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7382 times.
✗ Branch 5 not taken.
7381 nSatellites = std::stoul(line.substr(29 + 3, 3)); // Format: I3,6X,F15.12
551
552 7381 [[maybe_unused]] double recClkOffset = 0.0;
553 try
554 {
555
6/10
✓ Branch 1 taken 248 times.
✓ Branch 2 taken 7132 times.
✓ Branch 4 taken 248 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 248 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 248 times.
✓ Branch 10 taken 7132 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
7381 recClkOffset = line.size() >= 41 + 3 ? std::stod(line.substr(41, 15)) : 0.0; // Format: F15.12
556 }
557 catch (const std::exception& /* exception */)
558 {
559 LOG_DATA("{}: 'recClkOffset' not mentioned in file --> recClkOffset = {}", nameId(), recClkOffset);
560 }
561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7380 times.
7380 if (_rcvClockOffsAppl)
562 {
563 sec -= recClkOffset;
564 }
565
566
1/2
✓ Branch 1 taken 7382 times.
✗ Branch 2 not taken.
7380 epochTime = InsTime{ static_cast<uint16_t>(year), static_cast<uint16_t>(month), static_cast<uint16_t>(day),
567 static_cast<uint16_t>(hour), static_cast<uint16_t>(min), sec,
568 _timeSystem };
569
570
2/4
✓ Branch 1 taken 7380 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7381 times.
✗ Branch 5 not taken.
7382 epochFlag = std::stoi(line.substr(31, 1)); // Format: 2X,I1,
571
572 LOG_DATA("{}: {}, epochFlag {}, numSats {}, recClkOffset {}", nameId(),
573 epochTime.toYMDHMS(), epochFlag, nSatellites, recClkOffset);
574 }
575 }
576
2/2
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 7380 times.
7427 if (epochTime.empty())
577 {
578 47 return nullptr;
579 }
580
581
1/2
✓ Branch 1 taken 7381 times.
✗ Branch 2 not taken.
7380 auto gnssObs = std::make_shared<GnssObs>();
582 7381 gnssObs->insTime = epochTime;
583
584 // TODO: while loop till eof() or epochFlag == 0 (in case some other flags in the file)
585
586 7381 size_t satCnt = 0;
587
12/16
✓ Branch 1 taken 250242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 250238 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 250235 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242901 times.
✓ Branch 9 taken 7334 times.
✓ Branch 11 taken 242887 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 242891 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 242849 times.
✓ Branch 17 taken 42 times.
✓ Branch 18 taken 242850 times.
✓ Branch 19 taken 7379 times.
250248 while (!eof() && peek() != '>' && getline(line)) // Read observation records till line with '>'
588 {
589
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 242854 times.
242850 if (line.empty())
590 {
591 continue;
592 }
593
2/4
✓ Branch 1 taken 242862 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 242860 times.
✗ Branch 5 not taken.
242854 auto satSys = SatelliteSystem::fromChar(line.at(0)); // Format: A1,
594
2/4
✓ Branch 1 taken 242851 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 242856 times.
✗ Branch 5 not taken.
242860 auto satNum = static_cast<uint8_t>(std::stoi(line.substr(1, 2))); // Format: I2.2,
595
596 LOG_DATA("{}: [{}] {}{}:", nameId(), gnssObs->insTime.toYMDHMS(GPST), char(satSys), satNum);
597
598 242852 size_t curExtractLoc = 3;
599
3/4
✓ Branch 1 taken 242847 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 2218354 times.
✓ Branch 9 taken 227342 times.
2445678 for (const auto& obsDesc : _obsDescription.at(satSys))
600 {
601
2/2
✓ Branch 1 taken 15396 times.
✓ Branch 2 taken 2202774 times.
2218204 if (line.size() < curExtractLoc + 14) // Remaining elements are all blank
602 {
603 15396 break;
604 }
605
606
2/4
✓ Branch 1 taken 2202415 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2201695 times.
✗ Branch 5 not taken.
2202774 auto strObs = str::trim_copy(line.substr(curExtractLoc, 14)); // Format: F14.3
607 2201864 curExtractLoc += 14;
608
2/2
✓ Branch 1 taken 368424 times.
✓ Branch 2 taken 1833866 times.
2201864 if (strObs.empty())
609 {
610 368424 curExtractLoc += 2;
611 368424 continue;
612 }
613 // Observation value depending on definition type
614 1833866 double observation{};
615 try
616 {
617
1/2
✓ Branch 1 taken 1834570 times.
✗ Branch 2 not taken.
1833866 observation = std::stod(strObs);
618 }
619 catch (const std::exception& e)
620 {
621 if ((*gnssObs)({ obsDesc.code, satNum }).pseudorange)
622 {
623 if (obsDesc.type == NAV::vendor::RINEX::ObsType::L) // Phase
624 {
625 LOG_WARN("{}: observation of satSys = {} contains no carrier phase. This happens if the CN0 is so small that the PLL could not lock, even if the DLL has locked (= pseudorange available). The observation is still valid.", nameId(), char(satSys));
626 }
627 else if (obsDesc.type == NAV::vendor::RINEX::ObsType::D) // Doppler
628 {
629 LOG_WARN("{}: observation of satSys = {} contains no doppler.", nameId(), char(satSys));
630 }
631 }
632 continue;
633 }
634
635 // TODO: Springer Handbook of Global Navigation, p. 1211 prefer attributes over others and let user decide also which ones to take into the calculation
636
637 // Loss of lock indicator
638 // Bit 0 set: Lost lock between previous and current observation: Cycle slip possible.
639 // For phase observations only. Note: Bit 0 is the least significant bit.
640 // Bit 1 set: Half-cycle ambiguity/slip possible. Software not capable of handling half
641 // cycles should skip this observation. Valid for the current epoch only.
642 // Bit 2 set: Galileo BOC-tracking of an MBOC-modulated signal (may suffer from increased noise).
643 1834570 uint8_t LLI = 0;
644
2/2
✓ Branch 1 taken 1786913 times.
✓ Branch 2 taken 47597 times.
1834570 if (line.size() > curExtractLoc)
645 {
646
1/2
✓ Branch 1 taken 1786807 times.
✗ Branch 2 not taken.
1786913 char LLIc = line.at(curExtractLoc);
647
2/2
✓ Branch 0 taken 1719401 times.
✓ Branch 1 taken 67406 times.
1786807 if (LLIc == ' ')
648 {
649 1719401 LLIc = '0';
650 }
651 1786807 LLI = static_cast<uint8_t>(LLIc - '0');
652 }
653 1834404 curExtractLoc++; // Go over Loss of lock indicator (LLI)
654
655 // Signal Strength Indicator (SSI)
656 //
657 // Carrier to Noise ratio(RINEX) | Carrier to Noise ratio(dbHz)
658 // 1 (minimum possible signal strength) | < 12
659 // 2 | 12-17
660 // 3 | 18-23
661 // 4 | 24-29
662 // 5 (average/good S/N ratio) | 30-35
663 // 6 | 36-41
664 // 7 | 42-47
665 // 8 | 48-53
666 // 9 (maximum possible signal strength) | ≥ 54
667 // 0 or blank: not known, don't care | -
668 1834404 uint8_t SSI = 0;
669
2/2
✓ Branch 1 taken 1786775 times.
✓ Branch 2 taken 47542 times.
1834404 if (line.size() > curExtractLoc)
670 {
671
1/2
✓ Branch 1 taken 1786817 times.
✗ Branch 2 not taken.
1786775 char SSIc = line.at(curExtractLoc);
672
2/2
✓ Branch 0 taken 885748 times.
✓ Branch 1 taken 901069 times.
1786817 if (SSIc == ' ')
673 {
674 885748 SSIc = '0';
675 }
676 1786817 SSI = static_cast<uint8_t>(SSIc - '0');
677 }
678 1834359 curExtractLoc++; // Go over Signal Strength Indicator (SSI)
679
680
4/6
✓ Branch 0 taken 490212 times.
✓ Branch 1 taken 471093 times.
✓ Branch 2 taken 383179 times.
✓ Branch 3 taken 490216 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1834359 switch (obsDesc.type)
681 {
682 490212 case NAV::vendor::RINEX::ObsType::C: // Code / Pseudorange
683
1/2
✓ Branch 2 taken 490216 times.
✗ Branch 3 not taken.
490187 (*gnssObs)({ obsDesc.code, satNum }).pseudorange = { .value = observation,
684 980428 .SSI = SSI };
685 490203 break;
686 471093 case NAV::vendor::RINEX::ObsType::L: // Phase
687
1/2
✓ Branch 2 taken 471101 times.
✗ Branch 3 not taken.
471082 (*gnssObs)({ obsDesc.code, satNum }).carrierPhase = { .value = observation,
688 .SSI = SSI,
689 942194 .LLI = LLI };
690 471098 break;
691 383179 case NAV::vendor::RINEX::ObsType::D: // Doppler
692
1/2
✓ Branch 4 taken 383186 times.
✗ Branch 5 not taken.
383179 (*gnssObs)({ obsDesc.code, satNum }).doppler = observation;
693 383186 break;
694 490216 case NAV::vendor::RINEX::ObsType::S: // Raw signal strength(carrier to noise ratio)
695
1/2
✓ Branch 4 taken 490238 times.
✗ Branch 5 not taken.
490216 (*gnssObs)({ obsDesc.code, satNum }).CN0 = observation;
696 490238 break;
697 case NAV::vendor::RINEX::ObsType::I:
698 case NAV::vendor::RINEX::ObsType::X:
699 case NAV::vendor::RINEX::ObsType::Error:
700 LOG_WARN("{}: ObsType {} not supported", nameId(), size_t(obsDesc.type));
701 break;
702 }
703
704
2/4
✓ Branch 1 taken 1834530 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 1834572 times.
✗ Branch 7 not taken.
1834384 gnssObs->satData(SatId{ satSys, satNum }).frequencies |= obsDesc.code.getFrequency();
705
706 LOG_DATA("{}: {}-{}-{}: {}, LLI {}, SSI {}", nameId(),
707 NAV::vendor::RINEX::obsTypeToChar(obsDesc.type), obsDesc.code, satNum,
708 observation, LLI, SSI);
709
710
4/6
✓ Branch 0 taken 1834548 times.
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 1834530 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1834478 times.
✗ Branch 7 not taken.
1834558 if (_eraseLessPreciseCodes) { eraseLessPreciseCodes(gnssObs, obsDesc.code.getFrequency(), satNum); }
711 2202912 }
712
713
2/2
✓ Branch 3 taken 242761 times.
✓ Branch 4 taken 102 times.
242738 if (gnssObs->data.back().pseudorange)
714 {
715 242761 if (!gnssObs->data.back().carrierPhase)
716 {
717 LOG_DATA("{}: A data record at epoch {} (plus leap seconds) contains Pseudorange, but is missing carrier phase.", nameId(), epochTime.toYMDHMS());
718 }
719 242763 if (!gnssObs->data.back().doppler)
720 {
721 LOG_DATA("{}: A data record at epoch {} (plus leap seconds) contains Pseudorange, but is missing doppler.", nameId(), epochTime.toYMDHMS());
722 }
723 242762 if (!gnssObs->data.back().CN0)
724 {
725 LOG_DATA("{}: A data record at epoch {} (plus leap seconds) contains Pseudorange, but is missing raw signal strength(carrier to noise ratio).", nameId(), epochTime.toYMDHMS());
726 }
727 }
728 242867 satCnt++;
729 }
730
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 7286 times.
7379 if (satCnt != nSatellites)
731 {
732
4/8
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 93 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 93 times.
✗ Branch 10 not taken.
✓ Branch 13 taken 93 times.
✗ Branch 14 not taken.
93 LOG_WARN("{}: [{}] {} satellites read, but epoch header specified {} satellites", nameId(), gnssObs->insTime.toYMDHMS(GPST), satCnt, nSatellites);
733 }
734
735 7379 gnssObs->receiverInfo = _receiverInfo;
736
737
1/2
✓ Branch 2 taken 7381 times.
✗ Branch 3 not taken.
7382 invokeCallbacks(OUTPUT_PORT_INDEX_GNSS_OBS, gnssObs);
738 7382 return gnssObs;
739 7429 }
740
741 1834521 void RinexObsFile::eraseLessPreciseCodes(const std::shared_ptr<NAV::GnssObs>& gnssObs, const Frequency& freq, uint16_t satNum) // NOLINT(readability-convert-member-functions-to-static)
742 {
743 7694000 auto eraseLessPrecise = [&](const Code& third, const Code& second, const Code& prime) {
744 2705972 auto eraseSatDataWithCode = [&](const Code& code) {
745 LOG_DATA("{}: Searching for {}-{}", nameId(), code, satNum);
746
1/2
✓ Branch 2 taken 2705889 times.
✗ Branch 3 not taken.
2705972 auto iter = std::ranges::find_if(gnssObs->data, [code, satNum](const GnssObs::ObservationData& idData) {
747
1/2
✓ Branch 2 taken 148946325 times.
✗ Branch 3 not taken.
148927614 return idData.satSigId == SatSigId{ code, satNum };
748 });
749
2/2
✓ Branch 3 taken 8540 times.
✓ Branch 4 taken 2697381 times.
2705889 if (iter != gnssObs->data.end())
750 {
751 LOG_DATA("{}: Erasing {}-{}", nameId(), code, satNum);
752
1/2
✓ Branch 3 taken 8540 times.
✗ Branch 4 not taken.
8540 gnssObs->data.erase(iter);
753 }
754 2705921 };
755
756
3/4
✓ Branch 3 taken 7694870 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1228946 times.
✓ Branch 6 taken 6465924 times.
7694000 if (gnssObs->contains({ prime, satNum }))
757 {
758
1/2
✓ Branch 1 taken 1228956 times.
✗ Branch 2 not taken.
1228946 eraseSatDataWithCode(second);
759
1/2
✓ Branch 1 taken 1228957 times.
✗ Branch 2 not taken.
1228956 eraseSatDataWithCode(third);
760 }
761
3/4
✓ Branch 3 taken 6465865 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 248203 times.
✓ Branch 6 taken 6217662 times.
6465924 else if (gnssObs->contains({ second, satNum }))
762 {
763
1/2
✓ Branch 1 taken 248206 times.
✗ Branch 2 not taken.
248203 eraseSatDataWithCode(third);
764 }
765 7694825 };
766
767
8/11
✓ Branch 1 taken 1834210 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 588726 times.
✓ Branch 5 taken 507371 times.
✓ Branch 6 taken 376129 times.
✓ Branch 7 taken 286548 times.
✓ Branch 8 taken 45204 times.
✓ Branch 9 taken 4712 times.
✓ Branch 10 taken 25916 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
1834521 switch (SatelliteSystem_(freq.getSatSys()))
768 {
769 588726 case GPS:
770
4/8
✓ Branch 1 taken 588728 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 588764 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 588769 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 588812 times.
✗ Branch 11 not taken.
588726 eraseLessPrecise(Code::G1S, Code::G1L, Code::G1X); ///< L1C (data, pilot, combined)
771
4/8
✓ Branch 1 taken 588815 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 588815 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 588823 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 588817 times.
✗ Branch 11 not taken.
588812 eraseLessPrecise(Code::G2S, Code::G2L, Code::G2X); ///< L2C-code (medium, long, combined)
772
4/8
✓ Branch 1 taken 588810 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 588819 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 588822 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 588813 times.
✗ Branch 11 not taken.
588817 eraseLessPrecise(Code::G5I, Code::G5Q, Code::G5X); ///< L5 (data, pilot, combined)
773 588813 break;
774 507371 case GAL:
775
4/8
✓ Branch 1 taken 507359 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 507365 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507372 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507394 times.
✗ Branch 11 not taken.
507371 eraseLessPrecise(Code::E1B, Code::E1C, Code::E1X); ///< OS (data, pilot, combined)
776
4/8
✓ Branch 1 taken 507393 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 507397 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507399 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507379 times.
✗ Branch 11 not taken.
507394 eraseLessPrecise(Code::E5I, Code::E5Q, Code::E5X); ///< E5a (data, pilot, combined)
777
4/8
✓ Branch 1 taken 507380 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 507386 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507391 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507381 times.
✗ Branch 11 not taken.
507379 eraseLessPrecise(Code::E6B, Code::E6C, Code::E6X); ///< E6 (data, pilot, combined)
778
4/8
✓ Branch 1 taken 507380 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 507390 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507389 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507398 times.
✗ Branch 11 not taken.
507381 eraseLessPrecise(Code::E7I, Code::E7Q, Code::E7X); ///< E5b (data, pilot, combined)
779
4/8
✓ Branch 1 taken 507395 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 507401 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507405 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507379 times.
✗ Branch 11 not taken.
507398 eraseLessPrecise(Code::E8I, Code::E8Q, Code::E8X); ///< E5 AltBOC (data, pilot, combined)
780 507379 break;
781 376129 case GLO:
782
4/8
✓ Branch 1 taken 376126 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 376149 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 376171 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 376176 times.
✗ Branch 11 not taken.
376129 eraseLessPrecise(Code::R3I, Code::R3Q, Code::R3X); ///< L3 (data, pilot, combined)
783
4/8
✓ Branch 1 taken 376171 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 376182 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 376177 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 376170 times.
✗ Branch 11 not taken.
376176 eraseLessPrecise(Code::R4A, Code::R4B, Code::R4X); ///< G1a (data, pilot, combined)
784
4/8
✓ Branch 1 taken 376171 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 376179 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 376174 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 376170 times.
✗ Branch 11 not taken.
376170 eraseLessPrecise(Code::R6A, Code::R6B, Code::R6X); ///< G2a (data, pilot, combined)
785 376170 break;
786 286548 case BDS:
787
4/8
✓ Branch 1 taken 286548 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286548 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286548 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286547 times.
✗ Branch 11 not taken.
286548 eraseLessPrecise(Code::B1D, Code::B1P, Code::B1X); ///< B1 (data, pilot, combined)
788
4/8
✓ Branch 1 taken 286549 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286549 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286549 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286550 times.
✗ Branch 11 not taken.
286547 eraseLessPrecise(Code::B2I, Code::B2Q, Code::B2X); ///< B1I(OS), B1Q, combined
789
4/8
✓ Branch 1 taken 286549 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286550 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286550 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286545 times.
✗ Branch 11 not taken.
286550 eraseLessPrecise(Code::B5D, Code::B5P, Code::B5X); ///< B2a (data, pilot, combined)
790
4/8
✓ Branch 1 taken 286542 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286545 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286544 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286547 times.
✗ Branch 11 not taken.
286545 eraseLessPrecise(Code::B6I, Code::B6Q, Code::B6X); ///< B3I, B3Q, combined
791
4/8
✓ Branch 1 taken 286542 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286546 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286544 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286549 times.
✗ Branch 11 not taken.
286547 eraseLessPrecise(Code::B7I, Code::B7Q, Code::B7X); ///< B2I(OS), B2Q, combined
792
4/8
✓ Branch 1 taken 286550 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286551 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286550 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286549 times.
✗ Branch 11 not taken.
286549 eraseLessPrecise(Code::B7D, Code::B7P, Code::B7Z); ///< B2b (data, pilot, combined)
793
4/8
✓ Branch 1 taken 286548 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286549 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286549 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286545 times.
✗ Branch 11 not taken.
286549 eraseLessPrecise(Code::B8D, Code::B8P, Code::B8X); ///< B2 (B2a+B2b) (data, pilot, combined)
794 286545 break;
795 45204 case QZSS:
796
4/8
✓ Branch 1 taken 45204 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 45204 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 45204 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 45204 times.
✗ Branch 11 not taken.
45204 eraseLessPrecise(Code::J1S, Code::J1L, Code::J1X); ///< L1C (data, pilot, combined)
797
4/8
✓ Branch 1 taken 45204 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 45204 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 45204 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 45204 times.
✗ Branch 11 not taken.
45204 eraseLessPrecise(Code::J2S, Code::J2L, Code::J2X); ///< L2C-code (medium, long, combined)
798
4/8
✓ Branch 1 taken 45204 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 45204 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 45204 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 45204 times.
✗ Branch 11 not taken.
45204 eraseLessPrecise(Code::J5I, Code::J5Q, Code::J5X); ///< L5 (data, pilot, combined)
799
4/8
✓ Branch 1 taken 45204 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 45204 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 45204 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 45204 times.
✗ Branch 11 not taken.
45204 eraseLessPrecise(Code::J5D, Code::J5P, Code::J5Z); ///< L5 (data, pilot, combined)
800
4/8
✓ Branch 1 taken 45204 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 45203 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 45204 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 45204 times.
✗ Branch 11 not taken.
45204 eraseLessPrecise(Code::J6S, Code::J6L, Code::J6X); ///< LEX signal (short, long, combined)
801 45204 break;
802 4712 case IRNSS:
803
4/8
✓ Branch 1 taken 4712 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4712 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4712 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4712 times.
✗ Branch 11 not taken.
4712 eraseLessPrecise(Code::I5B, Code::I5C, Code::I5X); ///< RS (data, pilot, combined)
804
4/8
✓ Branch 1 taken 4712 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4712 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4712 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4712 times.
✗ Branch 11 not taken.
4712 eraseLessPrecise(Code::I9B, Code::I9C, Code::I9X); ///< RS (data, pilot, combined)
805 4712 break;
806 25916 case SBAS:
807
4/8
✓ Branch 1 taken 25916 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 25916 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 25916 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 25916 times.
✗ Branch 11 not taken.
25916 eraseLessPrecise(Code::S5I, Code::S5Q, Code::S5X); ///< L5 (data, pilot, combined)
808 25916 break;
809 case SatSys_None:
810 break;
811 }
812 1834336 }
813
814 } // namespace NAV
815