INSTINCT Code Coverage Report


Directory: src/
File: Nodes/DataProvider/GNSS/FileReader/RinexObsFile.cpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 299 391 76.5%
Functions: 17 21 81.0%
Branches: 487 1040 46.8%

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 160 RinexObsFile::RinexObsFile()
31
4/8
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 160 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 160 times.
✗ Branch 9 not taken.
✓ Branch 13 taken 160 times.
✗ Branch 14 not taken.
160 : Node(typeStatic())
32 {
33 LOG_TRACE("{}: called", name);
34
35 160 _hasConfig = true;
36 160 _guiConfigDefaultWindowSize = { 517, 118 };
37
38
4/8
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 160 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 160 times.
✓ Branch 9 taken 160 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
480 nm::CreateOutputPin(this, "GnssObs", Pin::Type::Flow, { NAV::GnssObs::type() }, &RinexObsFile::pollData);
39 320 }
40
41 416 RinexObsFile::~RinexObsFile()
42 {
43 LOG_TRACE("{}: called", nameId());
44 416 }
45
46 272 std::string RinexObsFile::typeStatic()
47 {
48
1/2
✓ Branch 1 taken 272 times.
✗ Branch 2 not taken.
544 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 48 void RinexObsFile::restore(json const& j)
101 {
102 LOG_TRACE("{}: called", nameId());
103
104
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 if (j.contains("FileReader"))
105 {
106 48 FileReader::restore(j.at("FileReader"));
107 }
108
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 if (j.contains("eraseLessPreciseCodes"))
109 {
110 48 j.at("eraseLessPreciseCodes").get_to(_eraseLessPreciseCodes);
111 }
112 48 }
113
114 48 bool RinexObsFile::initialize()
115 {
116 LOG_TRACE("{}: called", nameId());
117
118 48 return FileReader::initialize();
119 }
120
121 48 void RinexObsFile::deinitialize()
122 {
123 LOG_TRACE("{}: called", nameId());
124
125 48 FileReader::deinitialize();
126
127 48 _version = 0.0;
128 48 _timeSystem = TimeSys_None;
129 48 _obsDescription.clear();
130 48 _rcvClockOffsAppl = false;
131 48 _receiverInfo = {};
132 96 }
133
134 96 bool RinexObsFile::resetNode()
135 {
136 LOG_TRACE("{}: called", nameId());
137
138 96 FileReader::resetReader();
139
140 96 return true;
141 }
142
143 48 FileReader::FileType RinexObsFile::determineFileType()
144 {
145 1600 auto extHeaderLabel = [](std::string line) {
146 // Remove any trailing non text characters
147
2/4
✓ Branch 3 taken 1600 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1600 times.
✗ Branch 8 not taken.
119966 line.erase(std::ranges::find_if(line, [](int ch) { return std::iscntrl(ch); }), line.end());
148
149
1/2
✓ Branch 2 taken 1600 times.
✗ Branch 3 not taken.
1600 return str::trim_copy(std::string_view(line).substr(60, 20));
150 };
151
152
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 std::filesystem::path filepath = getFilepath();
153
154
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 auto filestreamHeader = std::ifstream(filepath);
155
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 if (filestreamHeader.good())
156 {
157 48 std::string line;
158 // --------------------------------------- RINEX VERSION / TYPE ------------------------------------------
159
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
46 std::getline(filestreamHeader, line);
160
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 str::rtrim(line);
161
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
48 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 48 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 48 times.
48 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 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 46 times.
✗ Branch 8 not taken.
48 double version = std::stod(str::trim_copy(line.substr(0, 20))); // FORMAT: F9.2,11X
174
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
47 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 47 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 std::string fileType = str::trim_copy(line.substr(20, 20)); // FORMAT: A1,19X
182
2/4
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
48 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 46 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
47 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 47 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 43 times.
✓ Branch 8 taken 4 times.
✓ Branch 10 taken 44 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 44 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 48 times.
47 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 46 times.
✗ Branch 2 not taken.
48 std::getline(filestreamHeader, line);
197
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
46 str::rtrim(line);
198
3/6
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 47 times.
48 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 1504 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1504 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1503 times.
✓ Branch 7 taken 1 times.
1504 while (std::getline(filestreamHeader, line))
206 {
207
1/2
✓ Branch 1 taken 1505 times.
✗ Branch 2 not taken.
1503 str::rtrim(line);
208
4/6
✓ Branch 2 taken 1504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1505 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 48 times.
✓ Branch 10 taken 1457 times.
1505 if (extHeaderLabel(line) == "END OF HEADER")
209 {
210 48 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 48 }
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 48 }
220
221 48 void RinexObsFile::readHeader()
222 {
223 LOG_TRACE("{}: called", nameId());
224
225 48 std::string line;
226
227 // --------------------------------------- RINEX VERSION / TYPE ------------------------------------------
228
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 getline(line);
229
3/6
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
48 _version = std::stod(str::trim_copy(line.substr(0, 20)));
230
3/6
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 48 times.
✗ Branch 9 not taken.
48 LOG_DEBUG("{}: Version: {:3.2f}", nameId(), _version); // FORMAT: F9.2,11X
231
5/10
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 48 times.
✗ Branch 11 not taken.
✓ Branch 14 taken 48 times.
✗ Branch 15 not taken.
48 LOG_DEBUG("{}: SatSys : {}", nameId(), str::trim_copy(line.substr(40, 20))); // FORMAT: A1,19X
232
233 // #######################################################################################################
234
8/12
✓ Branch 1 taken 1454 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1453 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1453 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1453 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1452 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1451 times.
✓ Branch 14 taken 2 times.
1453 while (getline(line) && !eof())
235 {
236
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1452 times.
1451 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 1452 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1454 times.
✗ Branch 5 not taken.
1452 auto headerLabel = str::trim_copy(line.substr(60, 20));
242
3/4
✓ Branch 1 taken 1453 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1405 times.
✓ Branch 4 taken 48 times.
1454 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 1406 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1313 times.
✓ Branch 4 taken 93 times.
1405 else if (headerLabel == "COMMENT")
252 {
253 LOG_DATA("{}: Comment: {}", nameId(), line.substr(0, 60)); // FORMAT: A60
254 }
255
3/4
✓ Branch 1 taken 1313 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 1265 times.
1313 else if (headerLabel == "MARKER NAME")
256 {
257
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 auto markerName = str::trim_copy(line.substr(0, 60)); // FORMAT: A60
258 48 if (!markerName.empty())
259 {
260 LOG_DATA("{}: Marker name: {}", nameId(), markerName);
261 }
262 48 }
263
3/4
✓ Branch 1 taken 1264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 1227 times.
1265 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 1229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 1186 times.
1227 else if (headerLabel == "MARKER TYPE")
272 {
273
2/4
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
43 auto markerType = str::trim_copy(line.substr(0, 60)); // FORMAT: A20,40X
274 43 if (!markerType.empty())
275 {
276 LOG_DATA("{}: Marker type: {}", nameId(), markerType);
277 }
278 43 }
279
3/4
✓ Branch 1 taken 1183 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 1135 times.
1186 else if (headerLabel == "OBSERVER / AGENCY")
280 {
281
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 auto observer = str::trim_copy(line.substr(0, 20)); // FORMAT: A20,A40
282
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 auto agency = str::trim_copy(line.substr(20, 40));
283
3/4
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 35 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
48 if (!observer.empty() || !agency.empty())
284 {
285 LOG_DATA("{}: Observer '{}', Agency '{}'", nameId(), observer, agency);
286 }
287 48 }
288
3/4
✓ Branch 1 taken 1137 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 1089 times.
1135 else if (headerLabel == "REC # / TYPE / VERS")
289 {
290
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 auto receiverNumber = str::trim_copy(line.substr(0, 20)); // FORMAT: 3A20
291
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 auto receiverType = str::trim_copy(line.substr(20, 20));
292
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 auto receiverVersion = str::trim_copy(line.substr(40, 20));
293
5/6
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 34 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
48 if (!receiverNumber.empty() || !receiverType.empty() || !receiverVersion.empty())
294 {
295 LOG_DATA("{}: RecNum '{}', recType '{}', recVersion '{}'", nameId(),
296 receiverNumber, receiverType, receiverVersion);
297 }
298 48 }
299
3/4
✓ Branch 1 taken 1088 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 1040 times.
1089 else if (headerLabel == "ANT # / TYPE")
300 {
301
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 auto antennaNumber = str::trim_copy(line.substr(0, 20)); // FORMAT: 2A20
302
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 auto antennaType = str::trim_copy(line.substr(20, 20));
303
4/4
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 31 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 14 times.
48 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 34 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 48 times.
✗ Branch 9 not taken.
48 if (!antennaType.empty() || antennaType != "Unknown")
308 {
309
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 _receiverInfo.antennaType = antennaType;
310 }
311 48 }
312
3/4
✓ Branch 1 taken 1041 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 998 times.
1040 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 43 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 43 times.
✗ Branch 8 not taken.
86 Eigen::Vector3d position_xyz{ std::stod(str::trim_copy(line.substr(0, 14))),
317
3/6
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 43 times.
✗ Branch 8 not taken.
86 std::stod(str::trim_copy(line.substr(14, 14))),
318
4/8
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 43 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
43 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 43 times.
✗ Branch 2 not taken.
43 _receiverInfo.e_approxPos = position_xyz;
323 }
324
3/4
✓ Branch 1 taken 997 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 949 times.
998 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 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
48 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 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
48 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 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
48 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 48 times.
✗ Branch 2 not taken.
48 _receiverInfo.antennaDeltaNEU = Eigen::Vector3d(antennaEccentricityNorth, antennaEccentricityEast, antennaHeight);
337 }
338
2/4
✓ Branch 1 taken 950 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 950 times.
949 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 947 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 947 times.
✗ Branch 4 not taken.
950 else if (headerLabel == "ANTENNA: PHASECENTER")
348 {
349 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "ANTENNA: PHASECENTER");
350 }
351
2/4
✓ Branch 1 taken 949 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 949 times.
✗ Branch 4 not taken.
947 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 946 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 947 times.
✗ Branch 4 not taken.
949 else if (headerLabel == "ANTENNA: ZERODIR AZI")
356 {
357 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "ANTENNA: ZERODIR AZI");
358 }
359
2/4
✓ Branch 1 taken 948 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 948 times.
✗ Branch 4 not taken.
947 else if (headerLabel == "ANTENNA: ZERODIR XYZ")
360 {
361 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "ANTENNA: ZERODIR XYZ");
362 }
363
2/4
✓ Branch 1 taken 951 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 951 times.
✗ Branch 4 not taken.
948 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 948 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 220 times.
✓ Branch 4 taken 728 times.
951 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 221 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 223 times.
✗ Branch 5 not taken.
220 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 223 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 221 times.
✗ Branch 5 not taken.
223 size_t numSpecifications = std::stoul(line.substr(3, 3));
374
375 218 std::string debugOutput;
376
2/2
✓ Branch 0 taken 2785 times.
✓ Branch 1 taken 221 times.
3006 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 2784 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
2785 NAV::vendor::RINEX::ObsType type = NAV::vendor::RINEX::obsTypeFromChar(line.at(i));
381
2/4
✓ Branch 1 taken 2781 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2776 times.
✗ Branch 5 not taken.
2787 Frequency freq = NAV::vendor::RINEX::getFrequencyFromBand(satSys, line.at(i + 1) - '0');
382
1/2
✓ Branch 1 taken 2771 times.
✗ Branch 2 not taken.
2776 auto attribute = line.at(i + 2);
383
4/6
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 2738 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2786 times.
2771 if (freq == B01 && attribute == 'I') { freq = B02; }
384
1/2
✓ Branch 1 taken 2779 times.
✗ Branch 2 not taken.
2786 Code code = Code::fromFreqAttr(freq, attribute);
385
386
2/4
✓ Branch 1 taken 2774 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2757 times.
✗ Branch 5 not taken.
2779 _obsDescription[satSys].push_back(NAV::vendor::RINEX::ObservationDescription{ .type = type, .code = code });
387
388
2/4
✓ Branch 1 taken 2763 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2777 times.
✗ Branch 6 not taken.
5545 debugOutput += fmt::format("({},{},{})", NAV::vendor::RINEX::obsTypeToChar(type), freq, code);
389
390
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 2689 times.
2783 if (nLine == 13)
391 {
392
1/2
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
94 getline(line);
393 98 nLine = 0;
394 98 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 728 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 703 times.
✓ Branch 4 taken 25 times.
728 else if (headerLabel == "SIGNAL STRENGTH UNIT")
402 {
403 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SIGNAL STRENGTH UNIT");
404 }
405
3/4
✓ Branch 1 taken 703 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 669 times.
✓ Branch 4 taken 34 times.
703 else if (headerLabel == "INTERVAL")
406 {
407 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "INTERVAL");
408 }
409
3/4
✓ Branch 1 taken 669 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 621 times.
669 else if (headerLabel == "TIME OF FIRST OBS")
410 {
411
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 [[maybe_unused]] auto year = std::stoi(line.substr(0, 6));
412
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 [[maybe_unused]] auto month = std::stoi(line.substr(6, 6));
413
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 [[maybe_unused]] auto day = std::stoi(line.substr(12, 6));
414
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 [[maybe_unused]] auto hour = std::stoi(line.substr(18, 6));
415
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 [[maybe_unused]] auto min = std::stoi(line.substr(24, 6));
416
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 [[maybe_unused]] auto sec = std::stold(line.substr(30, 13));
417
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 _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 621 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 582 times.
✓ Branch 4 taken 39 times.
621 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 582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 582 times.
582 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 582 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 582 times.
✗ Branch 4 not taken.
582 else if (headerLabel == "SYS / DCBS APPLIED")
443 {
444 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SYS / DCBS APPLIED");
445 }
446
2/4
✓ Branch 1 taken 582 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 582 times.
✗ Branch 4 not taken.
582 else if (headerLabel == "SYS / PCVS APPLIED")
447 {
448 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SYS / PCVS APPLIED");
449 }
450
2/4
✓ Branch 1 taken 582 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 582 times.
✗ Branch 4 not taken.
582 else if (headerLabel == "SYS / SCALE FACTOR")
451 {
452 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SYS / SCALE FACTOR");
453 }
454
3/4
✓ Branch 1 taken 582 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
✓ Branch 4 taken 402 times.
582 else if (headerLabel == "SYS / PHASE SHIFT")
455 {
456 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "SYS / PHASE SHIFT");
457 }
458
3/4
✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 52 times.
180 else if (headerLabel == "GLONASS SLOT / FRQ #")
459 {
460 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "GLONASS SLOT / FRQ #");
461 }
462
3/4
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 40 times.
128 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 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
✓ Branch 4 taken 20 times.
88 else if (headerLabel == "LEAP SECONDS")
467 {
468 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "LEAP SECONDS");
469 }
470
3/4
✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 20 times.
68 else if (headerLabel == "# OF SATELLITES")
471 {
472 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "# OF SATELLITES");
473 }
474
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
48 else if (headerLabel == "PRN / # OF OBS")
475 {
476 LOG_TRACE("{}: '{}' not implemented yet", nameId(), "PRN / # OF OBS");
477 }
478
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
48 else if (headerLabel == "END OF HEADER")
479 {
480 48 break;
481 }
482 else
483 {
484 LOG_WARN("{}: Unknown header label '{}' in line '{}'", nameId(), headerLabel, line);
485 }
486 1452 }
487
488
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
50 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 48 }
524
525 7494 std::shared_ptr<const NodeData> RinexObsFile::pollData()
526 {
527 7494 std::string line;
528
529 7493 InsTime epochTime;
530
531 // 0: OK | 1: power failure between previous and current epoch | > 1 : Special event
532 7493 int epochFlag = -1;
533 7493 size_t nSatellites = 0;
534
10/14
✓ Branch 0 taken 7494 times.
✓ Branch 1 taken 7445 times.
✓ Branch 3 taken 7494 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7446 times.
✓ Branch 6 taken 48 times.
✓ Branch 8 taken 7446 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7446 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7446 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 7446 times.
✓ Branch 16 taken 7493 times.
14939 while (epochFlag != 0 && !eof() && getline(line)) // Read lines till epoch record with valid epoch flag
535 {
536
1/2
✓ Branch 1 taken 7446 times.
✗ Branch 2 not taken.
7446 str::trim(line);
537
538
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7446 times.
7446 if (line.empty())
539 {
540 continue;
541 }
542
2/4
✓ Branch 1 taken 7446 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7446 times.
✗ Branch 4 not taken.
7446 if (line.at(0) == '>') // EPOCH record - Record identifier: > - Format: A1,
543 {
544
2/4
✓ Branch 1 taken 7446 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7446 times.
✗ Branch 5 not taken.
7446 auto year = std::stoi(line.substr(2, 4)); // Format: 1X,I4,
545
2/4
✓ Branch 1 taken 7446 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7446 times.
✗ Branch 5 not taken.
7446 auto month = std::stoi(line.substr(7, 2)); // Format: 1X,I2.2,
546
2/4
✓ Branch 1 taken 7446 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7446 times.
✗ Branch 5 not taken.
7446 auto day = std::stoi(line.substr(10, 2)); // Format: 1X,I2.2,
547
2/4
✓ Branch 1 taken 7446 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7446 times.
✗ Branch 5 not taken.
7446 auto hour = std::stoi(line.substr(13, 2)); // Format: 1X,I2.2,
548
2/4
✓ Branch 1 taken 7446 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7446 times.
✗ Branch 5 not taken.
7446 auto min = std::stoi(line.substr(16, 2)); // Format: 1X,I2.2,
549
2/4
✓ Branch 1 taken 7446 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7446 times.
✗ Branch 5 not taken.
7446 auto sec = std::stold(line.substr(18, 11)); // Format: F11.7,2X,I1,
550
2/4
✓ Branch 1 taken 7445 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7446 times.
✗ Branch 5 not taken.
7446 nSatellites = std::stoul(line.substr(29 + 3, 3)); // Format: I3,6X,F15.12
551
552 7446 [[maybe_unused]] double recClkOffset = 0.0;
553 try
554 {
555
6/10
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 7134 times.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 312 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 312 times.
✓ Branch 10 taken 7134 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
7446 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 7446 times.
7446 if (_rcvClockOffsAppl)
562 {
563 sec -= recClkOffset;
564 }
565
566
1/2
✓ Branch 1 taken 7445 times.
✗ Branch 2 not taken.
7446 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 7445 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7446 times.
✗ Branch 5 not taken.
7445 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 48 times.
✓ Branch 2 taken 7446 times.
7493 if (epochTime.empty())
577 {
578 48 return nullptr;
579 }
580
581
1/2
✓ Branch 1 taken 7445 times.
✗ Branch 2 not taken.
7446 auto gnssObs = std::make_shared<GnssObs>();
582 7445 gnssObs->insTime = epochTime;
583
584 // TODO: while loop till eof() or epochFlag == 0 (in case some other flags in the file)
585
586 7445 size_t satCnt = 0;
587
12/16
✓ Branch 1 taken 250946 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 250942 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 250939 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 243542 times.
✓ Branch 9 taken 7397 times.
✓ Branch 11 taken 243541 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 243543 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 243500 times.
✓ Branch 17 taken 43 times.
✓ Branch 18 taken 243499 times.
✓ Branch 19 taken 7445 times.
250947 while (!eof() && peek() != '>' && getline(line)) // Read observation records till line with '>'
588 {
589
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 243493 times.
243499 if (line.empty())
590 {
591 continue;
592 }
593
2/4
✓ Branch 1 taken 243494 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 243490 times.
✗ Branch 5 not taken.
243493 auto satSys = SatelliteSystem::fromChar(line.at(0)); // Format: A1,
594
2/4
✓ Branch 1 taken 243480 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 243491 times.
✗ Branch 5 not taken.
243490 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 243487 size_t curExtractLoc = 3;
599
3/4
✓ Branch 1 taken 243488 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 2236067 times.
✓ Branch 9 taken 227955 times.
2464182 for (const auto& obsDesc : _obsDescription.at(satSys))
600 {
601
2/2
✓ Branch 1 taken 15396 times.
✓ Branch 2 taken 2220541 times.
2235935 if (line.size() < curExtractLoc + 14) // Remaining elements are all blank
602 {
603 15396 break;
604 }
605
606
2/4
✓ Branch 1 taken 2220101 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2219904 times.
✗ Branch 5 not taken.
2220541 auto strObs = str::trim_copy(line.substr(curExtractLoc, 14)); // Format: F14.3
607 2219818 curExtractLoc += 14;
608
2/2
✓ Branch 1 taken 373514 times.
✓ Branch 2 taken 1846588 times.
2219818 if (strObs.empty())
609 {
610 373514 curExtractLoc += 2;
611 373514 continue;
612 }
613 // Observation value depending on definition type
614 1846588 double observation{};
615 try
616 {
617
1/2
✓ Branch 1 taken 1847344 times.
✗ Branch 2 not taken.
1846588 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 1847344 uint8_t LLI = 0;
644
2/2
✓ Branch 1 taken 1799675 times.
✓ Branch 2 taken 47584 times.
1847344 if (line.size() > curExtractLoc)
645 {
646
1/2
✓ Branch 1 taken 1799542 times.
✗ Branch 2 not taken.
1799675 char LLIc = line.at(curExtractLoc);
647
2/2
✓ Branch 0 taken 1729010 times.
✓ Branch 1 taken 70532 times.
1799542 if (LLIc == ' ')
648 {
649 1729010 LLIc = '0';
650 }
651 1799542 LLI = static_cast<uint8_t>(LLIc - '0');
652 }
653 1847126 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 1847126 uint8_t SSI = 0;
669
2/2
✓ Branch 1 taken 1799502 times.
✓ Branch 2 taken 47577 times.
1847126 if (line.size() > curExtractLoc)
670 {
671
1/2
✓ Branch 1 taken 1799563 times.
✗ Branch 2 not taken.
1799502 char SSIc = line.at(curExtractLoc);
672
2/2
✓ Branch 0 taken 898477 times.
✓ Branch 1 taken 901086 times.
1799563 if (SSIc == ' ')
673 {
674 898477 SSIc = '0';
675 }
676 1799563 SSI = static_cast<uint8_t>(SSIc - '0');
677 }
678 1847140 curExtractLoc++; // Go over Signal Strength Indicator (SSI)
679
680
4/6
✓ Branch 0 taken 493394 times.
✓ Branch 1 taken 474270 times.
✓ Branch 2 taken 386365 times.
✓ Branch 3 taken 493405 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1847140 switch (obsDesc.type)
681 {
682 493394 case NAV::vendor::RINEX::ObsType::C: // Code / Pseudorange
683
1/2
✓ Branch 2 taken 493395 times.
✗ Branch 3 not taken.
493392 (*gnssObs)({ obsDesc.code, satNum }).pseudorange = { .value = observation,
684 986789 .SSI = SSI };
685 493393 break;
686 474270 case NAV::vendor::RINEX::ObsType::L: // Phase
687
1/2
✓ Branch 2 taken 474292 times.
✗ Branch 3 not taken.
474268 (*gnssObs)({ obsDesc.code, satNum }).carrierPhase = { .value = observation,
688 .SSI = SSI,
689 948562 .LLI = LLI };
690 474276 break;
691 386365 case NAV::vendor::RINEX::ObsType::D: // Doppler
692
1/2
✓ Branch 4 taken 386363 times.
✗ Branch 5 not taken.
386365 (*gnssObs)({ obsDesc.code, satNum }).doppler = observation;
693 386363 break;
694 493405 case NAV::vendor::RINEX::ObsType::S: // Raw signal strength(carrier to noise ratio)
695
1/2
✓ Branch 4 taken 493418 times.
✗ Branch 5 not taken.
493405 (*gnssObs)({ obsDesc.code, satNum }).CN0 = observation;
696 493418 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 1847218 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 1847280 times.
✗ Branch 7 not taken.
1847156 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 1847245 times.
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 1847219 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1847308 times.
✗ Branch 7 not taken.
1847255 if (_eraseLessPreciseCodes) { eraseLessPreciseCodes(gnssObs, obsDesc.code.getFrequency(), satNum); }
711 2220832 }
712
713
2/2
✓ Branch 3 taken 243401 times.
✓ Branch 4 taken 101 times.
243351 if (gnssObs->data.back().pseudorange)
714 {
715 243401 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 243404 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 243400 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 243502 satCnt++;
729 }
730
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 7351 times.
7445 if (satCnt != nSatellites)
731 {
732
4/8
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 94 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 94 times.
✗ Branch 10 not taken.
✓ Branch 13 taken 94 times.
✗ Branch 14 not taken.
94 LOG_WARN("{}: [{}] {} satellites read, but epoch header specified {} satellites", nameId(), gnssObs->insTime.toYMDHMS(GPST), satCnt, nSatellites);
733 }
734
735 7445 gnssObs->receiverInfo = _receiverInfo;
736
737
1/2
✓ Branch 2 taken 7446 times.
✗ Branch 3 not taken.
7446 invokeCallbacks(OUTPUT_PORT_INDEX_GNSS_OBS, gnssObs);
738 7446 return gnssObs;
739 7494 }
740
741 1847195 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 7732029 auto eraseLessPrecise = [&](const Code& third, const Code& second, const Code& prime) {
744 2721165 auto eraseSatDataWithCode = [&](const Code& code) {
745 LOG_DATA("{}: Searching for {}-{}", nameId(), code, satNum);
746
1/2
✓ Branch 2 taken 2721080 times.
✗ Branch 3 not taken.
2721165 auto iter = std::ranges::find_if(gnssObs->data, [code, satNum](const GnssObs::ObservationData& idData) {
747
1/2
✓ Branch 2 taken 149148784 times.
✗ Branch 3 not taken.
148887229 return idData.satSigId == SatSigId{ code, satNum };
748 });
749
2/2
✓ Branch 3 taken 8540 times.
✓ Branch 4 taken 2712622 times.
2721080 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 2721162 };
755
756
3/4
✓ Branch 3 taken 7734383 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1236596 times.
✓ Branch 6 taken 6497787 times.
7732029 if (gnssObs->contains({ prime, satNum }))
757 {
758
1/2
✓ Branch 1 taken 1236582 times.
✗ Branch 2 not taken.
1236596 eraseSatDataWithCode(second);
759
1/2
✓ Branch 1 taken 1236590 times.
✗ Branch 2 not taken.
1236582 eraseSatDataWithCode(third);
760 }
761
3/4
✓ Branch 3 taken 6497663 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 248201 times.
✓ Branch 6 taken 6249462 times.
6497787 else if (gnssObs->contains({ second, satNum }))
762 {
763
1/2
✓ Branch 1 taken 248200 times.
✗ Branch 2 not taken.
248201 eraseSatDataWithCode(third);
764 }
765 7734252 };
766
767
8/11
✓ Branch 1 taken 1846876 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 601456 times.
✓ Branch 5 taken 507364 times.
✓ Branch 6 taken 376139 times.
✓ Branch 7 taken 286547 times.
✓ Branch 8 taken 45204 times.
✓ Branch 9 taken 4712 times.
✓ Branch 10 taken 25916 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
1847195 switch (SatelliteSystem_(freq.getSatSys()))
768 {
769 601456 case GPS:
770
4/8
✓ Branch 1 taken 601442 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 601484 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 601508 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 601549 times.
✗ Branch 11 not taken.
601456 eraseLessPrecise(Code::G1S, Code::G1L, Code::G1X); ///< L1C (data, pilot, combined)
771
4/8
✓ Branch 1 taken 601546 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 601555 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 601552 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 601537 times.
✗ Branch 11 not taken.
601549 eraseLessPrecise(Code::G2S, Code::G2L, Code::G2X); ///< L2C-code (medium, long, combined)
772
4/8
✓ Branch 1 taken 601532 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 601541 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 601549 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 601529 times.
✗ Branch 11 not taken.
601537 eraseLessPrecise(Code::G5I, Code::G5Q, Code::G5X); ///< L5 (data, pilot, combined)
773 601529 break;
774 507364 case GAL:
775
4/8
✓ Branch 1 taken 507368 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 507379 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507386 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507392 times.
✗ Branch 11 not taken.
507364 eraseLessPrecise(Code::E1B, Code::E1C, Code::E1X); ///< OS (data, pilot, combined)
776
4/8
✓ Branch 1 taken 507384 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 507392 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507403 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507393 times.
✗ Branch 11 not taken.
507392 eraseLessPrecise(Code::E5I, Code::E5Q, Code::E5X); ///< E5a (data, pilot, combined)
777
4/8
✓ Branch 1 taken 507391 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 507397 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507401 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507386 times.
✗ Branch 11 not taken.
507393 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 507389 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507390 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507392 times.
✗ Branch 11 not taken.
507386 eraseLessPrecise(Code::E7I, Code::E7Q, Code::E7X); ///< E5b (data, pilot, combined)
779
4/8
✓ Branch 1 taken 507390 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 507393 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 507394 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 507394 times.
✗ Branch 11 not taken.
507392 eraseLessPrecise(Code::E8I, Code::E8Q, Code::E8X); ///< E5 AltBOC (data, pilot, combined)
780 507394 break;
781 376139 case GLO:
782
4/8
✓ Branch 1 taken 376143 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 376143 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 376157 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 376181 times.
✗ Branch 11 not taken.
376139 eraseLessPrecise(Code::R3I, Code::R3Q, Code::R3X); ///< L3 (data, pilot, combined)
783
4/8
✓ Branch 1 taken 376181 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 376180 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 376184 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 376175 times.
✗ Branch 11 not taken.
376181 eraseLessPrecise(Code::R4A, Code::R4B, Code::R4X); ///< G1a (data, pilot, combined)
784
4/8
✓ Branch 1 taken 376179 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 376185 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 376185 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 376178 times.
✗ Branch 11 not taken.
376175 eraseLessPrecise(Code::R6A, Code::R6B, Code::R6X); ///< G2a (data, pilot, combined)
785 376178 break;
786 286547 case BDS:
787
4/8
✓ Branch 1 taken 286548 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286550 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286549 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286549 times.
✗ Branch 11 not taken.
286547 eraseLessPrecise(Code::B1D, Code::B1P, Code::B1X); ///< B1 (data, pilot, combined)
788
4/8
✓ Branch 1 taken 286550 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 286547 times.
✗ Branch 11 not taken.
286549 eraseLessPrecise(Code::B2I, Code::B2Q, Code::B2X); ///< B1I(OS), B1Q, combined
789
4/8
✓ Branch 1 taken 286547 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 286548 times.
✗ Branch 11 not taken.
286547 eraseLessPrecise(Code::B5D, Code::B5P, Code::B5X); ///< B2a (data, pilot, combined)
790
4/8
✓ Branch 1 taken 286547 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286549 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286551 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286547 times.
✗ Branch 11 not taken.
286548 eraseLessPrecise(Code::B6I, Code::B6Q, Code::B6X); ///< B3I, B3Q, combined
791
4/8
✓ Branch 1 taken 286546 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 286548 times.
✗ Branch 11 not taken.
286547 eraseLessPrecise(Code::B7I, Code::B7Q, Code::B7X); ///< B2I(OS), B2Q, combined
792
4/8
✓ Branch 1 taken 286549 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 286549 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 286550 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 286550 times.
✗ Branch 11 not taken.
286548 eraseLessPrecise(Code::B7D, Code::B7P, Code::B7Z); ///< B2b (data, pilot, combined)
793
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 286548 times.
✗ Branch 11 not taken.
286550 eraseLessPrecise(Code::B8D, Code::B8P, Code::B8X); ///< B2 (B2a+B2b) (data, pilot, combined)
794 286548 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 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::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 1847011 }
813
814 } // namespace NAV
815