0.4.1
Loading...
Searching...
No Matches
RINEXUtilities.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
9/// @file RINEXUtilities.hpp
10/// @brief Functions to work with RINEX.
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @author N. Stahl (HiWi: Moved from RinexObsFile.hpp)
13/// @date 18.12.2023
14
15#pragma once
16
17#include <map>
18#include <unordered_set>
19
24#include "util/Eigen.hpp"
25#include "util//Json.hpp"
26
27namespace NAV
28{
29namespace vendor::RINEX
30{
31
32/// @brief Observation types of the 'SYS / # / OBS TYPES' header
33enum class ObsType : uint8_t
34{
35 Error, ///< Error Type
36 C, ///< Code / Pseudorange
37 L, ///< Phase
38 D, ///< Doppler
39 S, ///< Raw signal strength(carrier to noise ratio)
40 I, ///< Ionosphere phase delay
41 X, ///< Receiver channel numbers
42};
43
44/// @brief Description of the observations from the 'SYS / # / OBS TYPES' header
46{
47 /// RINEX observation type
48 ///
49 /// C = Code / Pseudorange [m]
50 /// L = Phase [full cycles]
51 /// D = Doppler [Hz]
52 /// S = Raw signal strength (carrier to noise ratio) [unit receiver dependent]
53 /// I = Ionosphere phase delay [full cycles]
54 /// X = Receiver channel numbers
56
57 /// GNSS Code
59};
60
61/// Rinex Observation File Header information
63{
64 double version = 3.04; ///< Format version
65 std::string runBy; ///< Name of agency creating current file [A20]
66 std::vector<std::string> comments; ///< Comment line(s) [A60] (Optional)
67 std::string markerName; ///< Name of antenna marker [A60]
68 std::string markerNumber; ///< Number of antenna marker [A20] (Optional)
69
70 /// Available marker types
71 enum class MarkerTypes : uint8_t
72 {
73 GEODETIC, ///< Earth-fixed, high-precision monument
74 NON_GEODETIC, ///< Earth-fixed, low-precision monument
75 NON_PHYSICAL, ///< Generated from network processing
76 SPACEBORNE, ///< Orbiting space vehicle
77 GROUND_CRAFT, ///< Mobile terrestrial vehicle
78 WATER_CRAFT, ///< Mobile water craft
79 AIRBORNE, ///< Aircraft, balloon, etc.
80 FIXED_BUOY, ///< "Fixed" on water surface
81 FLOATING_BUOY, ///< Floating on water surface
82 FLOATING_ICE, ///< Floating ice sheet, etc.
83 GLACIER, ///< "Fixed" on a glacier
84 BALLISTIC, ///< Rockets, shells, etc
85 ANIMAL, ///< Animal carrying a receiver
86 HUMAN, ///< Human being
87 USER_DEFINED, ///< Users may define other project-dependent keywords
88 COUNT, ///< Amount of items in the enum
89 };
90 MarkerTypes markerType = MarkerTypes::GEODETIC; ///< Type of the marker
91 std::string markerTypeUser; ///< User-defined Marker Type [A20]
92 std::string observer; ///< Name of observer [A20]
93 std::string agency; ///< Name of agency [A40]
94 std::string receiverNumber; ///< Receiver number [A20]
95 std::string receiverType; ///< Receiver type [A20]
96 std::string receiverVersion; ///< Receiver version (e.g. Internal Software Version) [A20]
97 std::string antennaNumber; ///< Antenna number [A20]
98 std::string antennaType; ///< Antenna type [A20]
99 bool approxPositionEnabled = true; ///< Whether the approx position should be written
100 Eigen::Vector3d approxPositionXYZ = Eigen::Vector3d::Zero(); ///< Geocentric approximate marker position (Units: Meters, System: ITRS recommended) Optional for moving platforms [F14.4]
101 std::array<double, 3> antennaDeltaHeightEastNorth{}; ///< Antenna height and horizontal eccentricity of ARP relative to the marker (east/north) in (meters) [F14.4]
102
103 // ------------------------------- Dynamic data to clear and not to save ---------------------------------
104
105 SatelliteSystem satSys = SatSys_None; ///< Satellite System
106 std::map<SatelliteSystem, std::vector<ObservationDescription>> systemObsTypes; ///< Observation types for each satellite system
107 double interval = 1e9; ///< Observation interval in seconds
108 InsTime timeFirstObs; ///< Time of first observation record
109 InsTime timeLastObs; ///< Time of last observation record
110 std::unordered_set<SatId> satellites; ///< Satellites observed
111 TimeSystem timeSys = TimeSys_None; ///< Time system used
112
113 /// @brief Reset all dynamic data
114 void reset();
115
116 /// @brief Adds the obs type if not existing already
117 /// @param code Signal Code
118 /// @param type RINEX obs type
119 /// @return True if the type was not present yet
120 bool addObsType(const Code& code, ObsType type);
121
122 /// @brief Generates the RINEX observation header
123 [[nodiscard]] std::string generateHeader() const;
124 /// @brief Generates the Header line 'RINEX VERSION / TYPE'
125 [[nodiscard]] std::string headerLineRinexVersionType() const;
126 /// @brief Generates the Header line 'PGM / RUN BY / DATE'
127 [[nodiscard]] std::string headerLinePgmRunByDate() const;
128 /// @brief Generates the Header line 'COMMENT'
129 [[nodiscard]] std::string headerLineComments() const;
130 /// @brief Generates the Header line 'MARKER NAME'
131 [[nodiscard]] std::string headerLineMarkerName() const;
132 /// @brief Generates the Header line 'MARKER NUMBER'
133 [[nodiscard]] std::string headerLineMarkerNumber() const;
134 /// @brief Generates the Header line 'MARKER TYPE'
135 [[nodiscard]] std::string headerLineMarkerType() const;
136 /// @brief Generates the Header line 'OBSERVER / AGENCY'
137 [[nodiscard]] std::string headerLineObserverAgency() const;
138 /// @brief Generates the Header line 'REC # / TYPE / VERS'
139 [[nodiscard]] std::string headerLineRecNumTypeVers() const;
140 /// @brief Generates the Header line 'ANT # / TYPE'
141 [[nodiscard]] std::string headerLineAntNumType() const;
142 /// @brief Generates the Header line 'APPROX POSITION XYZ'
143 [[nodiscard]] std::string headerLineApproxPositionXYZ() const;
144 /// @brief Generates the Header line 'ANTENNA: DELTA H/E/N'
145 [[nodiscard]] std::string headerLineAntennaDeltaHEN() const;
146 /// @brief Generates the Header line 'SYS / # / OBS TYPES'
147 [[nodiscard]] std::string headerLineSysNumObsType() const;
148 /// @brief Generates the Header line 'SIGNAL STRENGTH UNIT'
149 [[nodiscard]] static std::string headerLineSignalStrengthUnit();
150 /// @brief Generates the Header line 'INTERVAL'
151 [[nodiscard]] std::string headerLineInterval() const;
152 /// @brief Generates the Header line 'TIME OF FIRST OBS'
153 [[nodiscard]] std::string headerLineTimeOfFirstObs() const;
154 /// @brief Generates the Header line 'TIME OF LAST OBS'
155 [[nodiscard]] std::string headerLineTimeOfLastObs() const;
156 /// @brief Generates the Header line 'SYS / PHASE SHIFT'
157 [[nodiscard]] static std::string headerLineSysPhaseShift();
158 /// @brief Generates the Header line 'GLONASS COD/PHS/BIS'
159 [[nodiscard]] static std::string headerLineGlonassCodPhsBis();
160 /// @brief Generates the Header line 'LEAP SECONDS'
161 [[nodiscard]] std::string headerLineLeapSeconds() const;
162 /// @brief Generates the Header line '# OF SATELLITES'
163 [[nodiscard]] std::string headerLineNumSatellites() const;
164 /// @brief Generates the Header line 'END OF HEADER'
165 [[nodiscard]] static std::string headerLineEndOfHeader();
166
167 /// @brief Generates the epoch line
168 /// @param[in] epochTime Time of the GNSS epoch
169 /// @param[in] nSatellites Number of satellites
170 [[nodiscard]] std::string epochRecordLine(const InsTime& epochTime, size_t nSatellites) const;
171};
172
173/// @brief Converts the provided struct into a json object
174/// @param[out] j Return Json object
175/// @param[in] obj Object to convert
176void to_json(json& j, const ObsHeader& obj);
177/// @brief Converts the provided json object into a struct
178/// @param[in] j Json object with the color values
179/// @param[out] obj Object to return
180void from_json(const json& j, ObsHeader& obj);
181
182/// @brief Converts a character to an ObsType
183/// @param[in] c Character for the ObsType
185
186/// @brief Converts an ObsType to char
187/// @param[in] type ObsType to convert
188char obsTypeToChar(ObsType type);
189
190/// @brief Converts the satellite system(s) to 3 characters representation of the time system
191/// @param[in] timeSys Time system
192std::string timeSystemString(TimeSystem timeSys);
193
194/// @brief Converts the satellite system(s) to the time system
195/// @param[in] satSys Satellite System
197
198/// @brief Get the Frequency from the provided satellite system and band in the 'SYS / # / OBS TYPES' header
199/// @param[in] satSys Satellite System
200/// @param[in] band Band (1...9, 0)
201[[nodiscard]] Frequency getFrequencyFromBand(SatelliteSystem satSys, int band);
202
203} // namespace vendor::RINEX
204
205/// @brief Converts the enum to a string
206/// @param[in] markerType Enum value to convert into text
207/// @return String representation of the enum
209/// @brief Converts the enum to a string tooltip
210/// @param[in] markerType Enum value to convert into text
211/// @return Tooltip for the enum
212const char* tooltip(vendor::RINEX::ObsHeader::MarkerTypes markerType);
213
214} // namespace NAV
Code definitions.
Vector space operations.
nlohmann::json json
json namespace
GNSS Observation messages.
Defines how to save certain datatypes to json.
Structs identifying a unique satellite.
Time System defintions.
Enumerate for GNSS Codes.
Definition Code.hpp:89
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
The class is responsible for all time-related tasks.
Definition InsTime.hpp:710
Time System defintions.
void from_json(const json &j, ObsHeader &obj)
Converts the provided json object into a struct.
ObsType
Observation types of the 'SYS / # / OBS TYPES' header.
@ X
Receiver channel numbers.
@ S
Raw signal strength(carrier to noise ratio)
@ I
Ionosphere phase delay.
std::string timeSystemString(TimeSystem timeSys)
Converts the satellite system(s) to 3 characters representation of the time system.
char obsTypeToChar(ObsType type)
Converts an ObsType to char.
void to_json(json &j, const ObsHeader &obj)
Converts the provided struct into a json object.
TimeSystem timeSystem(SatelliteSystem satSys)
Converts the satellite system(s) to the time system.
Frequency getFrequencyFromBand(SatelliteSystem satSys, int band)
Get the Frequency from the provided satellite system and band in the 'SYS / # / OBS TYPES' header.
ObsType obsTypeFromChar(char c)
Converts a character to an ObsType.
@ TimeSys_None
No Time system.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
const char * tooltip(vendor::RINEX::ObsHeader::MarkerTypes markerType)
Converts the enum to a string tooltip.
@ SatSys_None
No Satellite system.
Satellite System type.
Rinex Observation File Header information.
std::string headerLineApproxPositionXYZ() const
Generates the Header line 'APPROX POSITION XYZ'.
Eigen::Vector3d approxPositionXYZ
Geocentric approximate marker position (Units: Meters, System: ITRS recommended) Optional for moving ...
MarkerTypes markerType
Type of the marker.
std::map< SatelliteSystem, std::vector< ObservationDescription > > systemObsTypes
Observation types for each satellite system.
InsTime timeFirstObs
Time of first observation record.
std::string headerLineComments() const
Generates the Header line 'COMMENT'.
std::string headerLineRinexVersionType() const
Generates the Header line 'RINEX VERSION / TYPE'.
std::string headerLineTimeOfFirstObs() const
Generates the Header line 'TIME OF FIRST OBS'.
std::string markerTypeUser
User-defined Marker Type [A20].
std::string headerLineMarkerNumber() const
Generates the Header line 'MARKER NUMBER'.
double version
Format version.
std::string headerLineNumSatellites() const
Generates the Header line '# OF SATELLITES'.
std::string observer
Name of observer [A20].
std::string runBy
Name of agency creating current file [A20].
SatelliteSystem satSys
Satellite System.
std::vector< std::string > comments
Comment line(s) [A60] (Optional)
std::string headerLineMarkerType() const
Generates the Header line 'MARKER TYPE'.
std::string markerNumber
Number of antenna marker [A20] (Optional)
std::string headerLineLeapSeconds() const
Generates the Header line 'LEAP SECONDS'.
std::string agency
Name of agency [A40].
std::string headerLineTimeOfLastObs() const
Generates the Header line 'TIME OF LAST OBS'.
std::string markerName
Name of antenna marker [A60].
std::string antennaNumber
Antenna number [A20].
std::string headerLineAntNumType() const
Generates the Header line 'ANT # / TYPE'.
MarkerTypes
Available marker types.
@ GROUND_CRAFT
Mobile terrestrial vehicle.
@ FLOATING_BUOY
Floating on water surface.
@ NON_PHYSICAL
Generated from network processing.
@ USER_DEFINED
Users may define other project-dependent keywords.
@ GEODETIC
Earth-fixed, high-precision monument.
@ NON_GEODETIC
Earth-fixed, low-precision monument.
std::string receiverVersion
Receiver version (e.g. Internal Software Version) [A20].
bool approxPositionEnabled
Whether the approx position should be written.
static std::string headerLineGlonassCodPhsBis()
Generates the Header line 'GLONASS COD/PHS/BIS'.
std::string headerLineInterval() const
Generates the Header line 'INTERVAL'.
std::string headerLineSysNumObsType() const
Generates the Header line 'SYS / # / OBS TYPES'.
void reset()
Reset all dynamic data.
std::string headerLineRecNumTypeVers() const
Generates the Header line 'REC # / TYPE / VERS'.
std::array< double, 3 > antennaDeltaHeightEastNorth
Antenna height and horizontal eccentricity of ARP relative to the marker (east/north) in (meters) [F1...
std::unordered_set< SatId > satellites
Satellites observed.
std::string headerLineAntennaDeltaHEN() const
Generates the Header line 'ANTENNA: DELTA H/E/N'.
TimeSystem timeSys
Time system used.
std::string epochRecordLine(const InsTime &epochTime, size_t nSatellites) const
Generates the epoch line.
std::string headerLineObserverAgency() const
Generates the Header line 'OBSERVER / AGENCY'.
double interval
Observation interval in seconds.
std::string generateHeader() const
Generates the RINEX observation header.
std::string headerLinePgmRunByDate() const
Generates the Header line 'PGM / RUN BY / DATE'.
std::string receiverNumber
Receiver number [A20].
std::string receiverType
Receiver type [A20].
static std::string headerLineSysPhaseShift()
Generates the Header line 'SYS / PHASE SHIFT'.
static std::string headerLineEndOfHeader()
Generates the Header line 'END OF HEADER'.
InsTime timeLastObs
Time of last observation record.
std::string antennaType
Antenna type [A20].
static std::string headerLineSignalStrengthUnit()
Generates the Header line 'SIGNAL STRENGTH UNIT'.
bool addObsType(const Code &code, ObsType type)
Adds the obs type if not existing already.
std::string headerLineMarkerName() const
Generates the Header line 'MARKER NAME'.
Description of the observations from the 'SYS / # / OBS TYPES' header.