INSTINCT Code Coverage Report


Directory: src/
File: Navigation/Atmosphere/Ionosphere/IonosphericCorrections.hpp
Date: 2025-07-19 10:51:51
Exec Total Coverage
Lines: 22 23 95.7%
Functions: 9 9 100.0%
Branches: 18 24 75.0%

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 /// @file IonosphericCorrections.hpp
10 /// @brief Ionospheric Correction data
11 /// @author T. Topp (topp@ins.uni-stuttgart.de)
12 /// @date 2022-05-07
13
14 #pragma once
15
16 #include <cstdint>
17 #include <vector>
18 #include <optional>
19 #include <functional>
20
21 #include "Navigation/GNSS/Core/SatelliteSystem.hpp"
22
23 namespace NAV
24 {
25
26 /// GNSS Navigation message information
27 class GnssNavInfo;
28
29 /// @brief Ionospheric Corrections
30 class IonosphericCorrections
31 {
32 public:
33 /// @brief Alpha or beta values
34 enum AlphaBeta : uint8_t
35 {
36 Alpha, ///< Coefficients of a cubic equation representing the amplitude of the vertical delay
37 Beta, ///< Coefficients of a cubic equation representing the period of the model
38 };
39
40 /// @brief Ionospheric Corrections Data Storage
41 struct Corrections
42 {
43 SatelliteSystem satSys = SatSys_None; ///< Satellite System (e.g. GPS, GAL, GLO, ...)
44 AlphaBeta alphaBeta = Alpha; ///< Alpha or beta value
45 std::array<double, 4> data{}; ///< Data storage (3 values for GAL, otherwise 4) [s, s/semi-circle, s/semi-circle^2, s/semi-circle^3]
46 };
47
48 /// @brief Default constructor
49 278 IonosphericCorrections() = default;
50
51 /// @brief Constructor which collects the ionospheric parameters from the Navigation infos
52 /// @param[in] gnssNavInfos List of GNSS navigation infos
53 explicit IonosphericCorrections(const std::vector<const GnssNavInfo*>& gnssNavInfos);
54
55 /// @brief Constructor from raw corrections
56 /// @param corrections Corrections vector
57 IonosphericCorrections(std::vector<Corrections> corrections); // NOLINT(hicpp-explicit-conversions, google-explicit-constructor)
58
59 /// @brief Get the Ionospheric Correction values
60 /// @param[in] satSys Satellite System to search the value for
61 /// @param[in] alphaBeta Alpha or beta values (Galileo only alpha)
62 /// @return List with the correction values (3 for GAL, otherwise 4)
63 281640 [[nodiscard]] const std::array<double, 4>* get(SatelliteSystem satSys, AlphaBeta alphaBeta) const
64 {
65
1/2
✓ Branch 1 taken 281637 times.
✗ Branch 2 not taken.
281640 auto iter = std::ranges::find_if(m_ionosphericCorrections, [satSys, alphaBeta](const Corrections& c) {
66
3/4
✓ Branch 1 taken 422454 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 281638 times.
✓ Branch 4 taken 140816 times.
422453 return c.satSys == satSys && c.alphaBeta == alphaBeta;
67 });
68
1/2
✓ Branch 2 taken 281641 times.
✗ Branch 3 not taken.
281637 if (iter != m_ionosphericCorrections.end())
69 {
70 281641 return &iter->data;
71 }
72 return nullptr;
73 }
74
75 /// @brief Checks whether the data is in the internal storage
76 /// @param[in] satSys Satellite System to search the value for
77 /// @param[in] alphaBeta Alpha or beta values (Galileo only alpha)
78 4977 [[nodiscard]] bool contains(SatelliteSystem satSys, AlphaBeta alphaBeta) const
79 {
80
1/2
✓ Branch 1 taken 4977 times.
✗ Branch 2 not taken.
4977 auto iter = std::ranges::find_if(m_ionosphericCorrections, [satSys, alphaBeta](const Corrections& c) {
81
4/4
✓ Branch 1 taken 1981 times.
✓ Branch 2 taken 2512 times.
✓ Branch 3 taken 239 times.
✓ Branch 4 taken 1742 times.
4493 return c.satSys == satSys && c.alphaBeta == alphaBeta;
82 });
83 4977 return iter != m_ionosphericCorrections.end();
84 }
85
86 /// @brief Returns the internal data storage
87 3287 [[nodiscard]] const std::vector<Corrections>& data() const
88 {
89 3287 return m_ionosphericCorrections;
90 }
91
92 /// @brief Inserts new data into the m_ionosphericCorrections variable
93 /// @param[in] satSys Satellite System to search the value for
94 /// @param[in] alphaBeta Alpha or beta values (Galileo only alpha)
95 /// @param[in] values Values to add [s, s/semi-circle, s/semi-circle^2, s/semi-circle^3]
96 5100 void insert(SatelliteSystem satSys, AlphaBeta alphaBeta, const std::array<double, 4>& values)
97 {
98
1/2
✓ Branch 1 taken 5100 times.
✗ Branch 2 not taken.
5100 auto iter = std::ranges::find_if(m_ionosphericCorrections, [satSys, alphaBeta](const Corrections& c) {
99
4/4
✓ Branch 1 taken 2091 times.
✓ Branch 2 taken 2666 times.
✓ Branch 3 taken 290 times.
✓ Branch 4 taken 1801 times.
4757 return c.satSys == satSys && c.alphaBeta == alphaBeta;
100 });
101
2/2
✓ Branch 2 taken 4810 times.
✓ Branch 3 taken 290 times.
5100 if (iter == m_ionosphericCorrections.end())
102 {
103
1/2
✓ Branch 1 taken 4810 times.
✗ Branch 2 not taken.
4810 m_ionosphericCorrections.push_back({ satSys, alphaBeta, values });
104 }
105 else
106 {
107 290 iter->data = values;
108 }
109 5100 }
110
111 /// @brief Empties the data
112 58 void clear()
113 {
114 58 m_ionosphericCorrections.clear();
115 58 }
116
117 private:
118 /// @brief Ionospheric correction values
119 std::vector<Corrections> m_ionosphericCorrections;
120 };
121
122 } // namespace NAV
123