0.2.0
Loading...
Searching...
No Matches
SatelliteSystem.hpp
Go to the documentation of this file.
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
13
14#pragma once
15
16#include <string>
17#include <vector>
18#include <fmt/format.h>
19
20#include <nlohmann/json.hpp>
21using json = nlohmann::json;
22
24
25namespace NAV
26{
27
29enum SatelliteSystem_ : uint64_t
30{ // clang-format off
31 SatSys_None = 0x0000'0000'0000'0000,
32 GPS = 0x0000'0000'0000'00FF,
33 GAL = 0x0000'0000'0000'FF00,
34 GLO = 0x0000'0000'00FF'0000,
35 BDS = 0x0000'0000'FF00'0000,
36 QZSS = 0x0000'00FF'0000'0000,
37 IRNSS = 0x0000'FF00'0000'0000,
38 SBAS = 0x00FF'0000'0000'0000,
39}; // clang-format on
40
43{
57
59 constexpr SatelliteSystem() = default;
60
63 constexpr SatelliteSystem(SatelliteSystem_ type) // NOLINT(hicpp-explicit-conversions, google-explicit-constructor)
64 : value(type)
65 {}
66
69 SatelliteSystem(Enum enumeration) // NOLINT(hicpp-explicit-conversions, google-explicit-constructor)
70 : value(SatelliteSystem::fromEnum(enumeration))
71 {}
72
75 static SatelliteSystem fromString(const std::string& typeString);
76
79 static SatelliteSystem fromChar(char typeChar);
80
83 static SatelliteSystem fromEnum(Enum enumeration);
84
89 {
90 value = v;
91 return *this;
92 }
93
94 friend constexpr bool operator==(const SatelliteSystem& lhs, const SatelliteSystem& rhs);
95
99 constexpr bool operator<(const SatelliteSystem& rhs) const { return value < rhs.value; }
100
102 constexpr explicit operator SatelliteSystem_() const { return value; }
104 constexpr explicit operator bool() = delete;
105
108 constexpr explicit operator uint64_t() const { return uint64_t(value); }
109
112 explicit operator std::string() const;
113
116 explicit operator char() const;
117
121
123 [[nodiscard]] TimeSystem getTimeSystem() const;
124
127 static std::vector<uint16_t> GetSatellitesForSatelliteSystem(SatelliteSystem satSys);
128
130 [[nodiscard]] std::vector<uint16_t> getSatellites() const;
131
135
137 [[nodiscard]] Enum toEnumeration() const;
138
141 static char ToChar(SatelliteSystem satSys);
142
144 [[nodiscard]] char toChar() const;
145
148 static std::vector<SatelliteSystem> ToVector(SatelliteSystem satSys);
149
151 [[nodiscard]] std::vector<SatelliteSystem> toVector() const;
152
154 static std::vector<SatelliteSystem> GetAll();
155
156 private:
158 SatelliteSystem_ value = SatelliteSystem_::SatSys_None;
159};
160
161// #########################################################################################################################################
162
166void to_json(json& j, const SatelliteSystem& data);
170void from_json(const json& j, SatelliteSystem& data);
171
172// #########################################################################################################################################
173
179{
180 return SatelliteSystem_(uint64_t(lhs) | uint64_t(rhs));
181}
195{
196 return lhs | SatelliteSystem_(rhs);
197}
203{
204 return SatelliteSystem_(lhs) | rhs;
205}
206
212{
213 lhs = lhs | rhs;
214 return lhs;
215}
221{
222 lhs = lhs | rhs;
223 return lhs;
224}
230{
231 lhs = lhs | SatelliteSystem_(rhs);
232 return lhs;
233}
239{
240 lhs = lhs | rhs;
241 return lhs;
242}
243
249{
250 return SatelliteSystem_(uint64_t(lhs) & uint64_t(rhs));
251}
257{
258 return SatelliteSystem_(lhs) & SatelliteSystem_(rhs);
259}
265{
266 return SatelliteSystem_(lhs) & rhs;
267}
273{
274 return lhs & SatelliteSystem_(rhs);
275}
276
282{
283 lhs = lhs & rhs;
284 return lhs;
285}
291{
292 lhs = lhs & rhs;
293 return lhs;
294}
300{
301 lhs = lhs & SatelliteSystem_(rhs);
302 return lhs;
303}
309{
310 lhs = lhs & rhs;
311 return lhs;
312}
313
318{
319 return SatelliteSystem_(~uint64_t(rhs));
320}
325{
326 return SatelliteSystem_(~uint64_t(rhs));
327}
328
329// #########################################################################################################################################
330
335constexpr bool operator==(const SatelliteSystem& lhs, const SatelliteSystem& rhs) { return lhs.value == rhs.value; }
340constexpr bool operator==(const SatelliteSystem& lhs, const SatelliteSystem_& rhs) { return lhs == SatelliteSystem(rhs); }
345constexpr bool operator==(const SatelliteSystem_& lhs, const SatelliteSystem& rhs) { return SatelliteSystem(lhs) == rhs; }
346
351constexpr bool operator!=(const SatelliteSystem& lhs, const SatelliteSystem& rhs) { return !(lhs == rhs); }
356constexpr bool operator!=(const SatelliteSystem& lhs, const SatelliteSystem_& rhs) { return !(lhs == rhs); }
361constexpr bool operator!=(const SatelliteSystem_& lhs, const SatelliteSystem& rhs) { return !(lhs == rhs); }
362
367std::ostream& operator<<(std::ostream& os, const SatelliteSystem& satSys);
368
371
372} // namespace NAV
373
374namespace std
375{
377template<>
378struct hash<NAV::SatelliteSystem_>
379{
382 std::size_t operator()(const NAV::SatelliteSystem_& satSys) const
383 {
384 using namespace NAV; // NOLINT(google-build-using-namespace)
385 switch (satSys)
386 {
387 case SatSys_None:
388 return 1;
389 case GPS:
390 return 100;
391 case GAL:
392 return 200;
393 case GLO:
394 return 300;
395 case BDS:
396 return 400;
397 case QZSS:
398 return 500;
399 case IRNSS:
400 return 600;
401 case SBAS:
402 return 700;
403 }
404 return 0;
405 }
406};
408template<>
409struct hash<NAV::SatelliteSystem>
410{
413 std::size_t operator()(const NAV::SatelliteSystem& satSys) const
414 {
415 return std::hash<NAV::SatelliteSystem_>()(NAV::SatelliteSystem_(satSys));
416 }
417};
418} // namespace std
419
420#ifndef DOXYGEN_IGNORE
421
423template<>
424struct fmt::formatter<NAV::SatelliteSystem> : fmt::formatter<std::string>
425{
430 template<typename FormatContext>
431 auto format(const NAV::SatelliteSystem& satSys, FormatContext& ctx)
432 {
433 return fmt::formatter<std::string>::format(std::string(satSys), ctx);
434 }
435};
436
437#endif
Code operator|(const Code::Enum &lhs, const Code::Enum &rhs)
Allows combining flags of the Code enum.
Code operator&(const Code::Enum &lhs, const Code::Enum &rhs)
Allows combining flags of the Code enum.
std::ostream & operator<<(std::ostream &os, const NAV::CycleSlipDetector::Result &obj)
Stream insertion operator overload.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
constexpr Frequency_ operator~(Frequency_ rhs)
Allows negating flags of the Frequency enum.
Definition Frequency.hpp:362
constexpr Frequency_ & operator&=(Frequency_ &lhs, const Frequency_ &rhs)
Allows combining flags of the Frequency enum.
Definition Frequency.hpp:326
constexpr Frequency_ & operator|=(Frequency_ &lhs, const Frequency_ &rhs)
Allows combining flags of the Frequency enum.
Definition Frequency.hpp:256
SatelliteSystem_
Satellite System enumeration.
Definition SatelliteSystem.hpp:30
@ GPS
Global Positioning System.
Definition SatelliteSystem.hpp:32
@ QZSS
Quasi-Zenith Satellite System.
Definition SatelliteSystem.hpp:36
@ GLO
Globalnaja nawigazionnaja sputnikowaja sistema (GLONASS)
Definition SatelliteSystem.hpp:34
@ GAL
Galileo.
Definition SatelliteSystem.hpp:33
@ SBAS
Satellite Based Augmentation System.
Definition SatelliteSystem.hpp:38
@ BDS
Beidou.
Definition SatelliteSystem.hpp:35
@ SatSys_None
No Satellite system.
Definition SatelliteSystem.hpp:31
@ IRNSS
Indian Regional Navigation Satellite System.
Definition SatelliteSystem.hpp:37
constexpr SatelliteSystem_ SatSys_All
All Systems.
Definition SatelliteSystem.hpp:370
Time System defintions.
Time System defintions.
Definition TimeSystem.hpp:39
bool operator==(const ImVec4 &lhs, const ImVec4 &rhs)
Equal comparison operator.
bool operator!=(const ImVec4 &lhs, const ImVec4 &rhs)
Unequal comparison operator.
Satellite System type.
Definition SatelliteSystem.hpp:43
static char ToChar(SatelliteSystem satSys)
Get char representation of the specified Satellite System.
TimeSystem getTimeSystem() const
Get the Time System of this Satellite System.
char toChar() const
Returns the char representation of the object.
Enum toEnumeration() const
Returns a continuous enumeration of the object.
constexpr bool operator<(const SatelliteSystem &rhs) const
Less than comparison (needed for map)
Definition SatelliteSystem.hpp:99
static SatelliteSystem fromChar(char typeChar)
Construct new object from char.
static std::vector< SatelliteSystem > ToVector(SatelliteSystem satSys)
Get a vector representation of the specified Satellite Systems.
constexpr SatelliteSystem & operator=(SatelliteSystem_ v)
Assignment operator from Value type.
Definition SatelliteSystem.hpp:88
constexpr SatelliteSystem()=default
Default Constructor.
static std::vector< uint16_t > GetSatellitesForSatelliteSystem(SatelliteSystem satSys)
Get a list of satellites in the constellation.
SatelliteSystem(Enum enumeration)
Implicit Constructor from Enum type.
Definition SatelliteSystem.hpp:69
static std::vector< SatelliteSystem > GetAll()
Returns a list with all possible satellite systems.
static Enum ToEnumeration(SatelliteSystem satSys)
Get the continuous enumeration of the specified Satellite System.
static TimeSystem GetTimeSystemForSatelliteSystem(SatelliteSystem satSys)
Get the Time System of the specified Satellite System.
friend constexpr bool operator==(const SatelliteSystem &lhs, const SatelliteSystem &rhs)
Equal compares values.
Definition SatelliteSystem.hpp:335
static SatelliteSystem fromEnum(Enum enumeration)
Constructs a new object from continuous enumeration.
static SatelliteSystem fromString(const std::string &typeString)
Construct new object from std::string.
Enum
Satellite System enumeration with continuous range. Not usable as a mask.
Definition SatelliteSystem.hpp:46
@ Enum_GPS
Global Positioning System.
Definition SatelliteSystem.hpp:47
@ Enum_None
No Satellite system.
Definition SatelliteSystem.hpp:55
@ Enum_GLO
Globalnaja nawigazionnaja sputnikowaja sistema (GLONASS)
Definition SatelliteSystem.hpp:49
@ Enum_GAL
Galileo.
Definition SatelliteSystem.hpp:48
@ Enum_IRNSS
Indian Regional Navigation Satellite System.
Definition SatelliteSystem.hpp:52
@ Enum_BDS
Beidou.
Definition SatelliteSystem.hpp:50
@ Enum_QZSS
Quasi-Zenith Satellite System.
Definition SatelliteSystem.hpp:51
@ Enum_SBAS
Satellite Based Augmentation System.
Definition SatelliteSystem.hpp:53
@ Enum_COUNT
Count variable.
Definition SatelliteSystem.hpp:54
constexpr SatelliteSystem(SatelliteSystem_ type)
Implicit Constructor from Value type.
Definition SatelliteSystem.hpp:63
std::vector< SatelliteSystem > toVector() const
Get a vector representation of the specified Satellite Systems.
std::vector< uint16_t > getSatellites() const
Get a list of satellites in the constellation.
std::size_t operator()(const NAV::SatelliteSystem &satSys) const
Hash function for SatelliteSystem.
Definition SatelliteSystem.hpp:413
std::size_t operator()(const NAV::SatelliteSystem_ &satSys) const
Hash function for SatelliteSystem.
Definition SatelliteSystem.hpp:382