INSTINCT Code Coverage Report


Directory: src/
File: Navigation/Atmosphere/Ionosphere/IonosphericCorrections.hpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 22 23 95.7%
Functions: 9 9 100.0%
Branches: 17 24 70.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 /// @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 273 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 44474 [[nodiscard]] const std::array<double, 4>* get(SatelliteSystem satSys, AlphaBeta alphaBeta) const
64 {
65
1/2
✓ Branch 1 taken 44474 times.
✗ Branch 2 not taken.
44474 auto iter = std::ranges::find_if(m_ionosphericCorrections, [satSys, alphaBeta](const Corrections& c) {
66
3/4
✓ Branch 1 taken 66711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44474 times.
✓ Branch 4 taken 22237 times.
66711 return c.satSys == satSys && c.alphaBeta == alphaBeta;
67 });
68
1/2
✓ Branch 2 taken 44474 times.
✗ Branch 3 not taken.
44474 if (iter != m_ionosphericCorrections.end())
69 {
70 44474 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 1255 [[nodiscard]] bool contains(SatelliteSystem satSys, AlphaBeta alphaBeta) const
79 {
80
1/2
✓ Branch 1 taken 1255 times.
✗ Branch 2 not taken.
1255 auto iter = std::ranges::find_if(m_ionosphericCorrections, [satSys, alphaBeta](const Corrections& c) {
81
3/4
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 603 times.
701 return c.satSys == satSys && c.alphaBeta == alphaBeta;
82 });
83 1255 return iter != m_ionosphericCorrections.end();
84 }
85
86 /// @brief Returns the internal data storage
87 945 [[nodiscard]] const std::vector<Corrections>& data() const
88 {
89 945 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 1618 void insert(SatelliteSystem satSys, AlphaBeta alphaBeta, const std::array<double, 4>& values)
97 {
98
1/2
✓ Branch 1 taken 1618 times.
✗ Branch 2 not taken.
1618 auto iter = std::ranges::find_if(m_ionosphericCorrections, [satSys, alphaBeta](const Corrections& c) {
99
4/4
✓ Branch 1 taken 952 times.
✓ Branch 2 taken 260 times.
✓ Branch 3 taken 290 times.
✓ Branch 4 taken 662 times.
1212 return c.satSys == satSys && c.alphaBeta == alphaBeta;
100 });
101
2/2
✓ Branch 2 taken 1328 times.
✓ Branch 3 taken 290 times.
1618 if (iter == m_ionosphericCorrections.end())
102 {
103
1/2
✓ Branch 1 taken 1328 times.
✗ Branch 2 not taken.
1328 m_ionosphericCorrections.push_back({ satSys, alphaBeta, values });
104 }
105 else
106 {
107 290 iter->data = values;
108 }
109 1618 }
110
111 /// @brief Empties the data
112 57 void clear()
113 {
114 57 m_ionosphericCorrections.clear();
115 57 }
116
117 private:
118 /// @brief Ionospheric correction values
119 std::vector<Corrections> m_ionosphericCorrections;
120 };
121
122 } // namespace NAV
123