nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
gga.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5namespace nmealib {
6namespace nmea0183 {
7
15public:
22 explicit NotGGAException(const std::string& context, const std::string& details = "") :
23 NmeaException(context, "The sentence is not a GGA sentence", details) {}
24};
25
36class GGA : public Message0183 {
37public:
60 GGA(std::string talkerId,
61 double timestamp,
62 double latitude,
63 char latitudeDirection,
64 double longitude,
65 char longitudeDirection,
66 unsigned int gpsQuality,
67 unsigned int satellites,
68 double hdop,
69 double altitude,
70 char altitudeUnits,
71 double geoidalSeparation,
72 char geoidalSeparationUnits,
73 double dgpsAge,
74 std::string dgpsReferenceStationId
75 );
76
77 GGA(const GGA&) = default;
78 GGA& operator=(const GGA&) = default;
79 GGA(GGA&&) noexcept = default;
80 GGA& operator=(GGA&&) noexcept = default;
81
82 ~GGA() override = default;
83
89 std::unique_ptr<nmealib::Message> clone() const override;
90
92 double getUtcTime() const noexcept;
94 double getLatitude() const noexcept;
96 char getLatitudeDirection() const noexcept;
98 double getLongitude() const noexcept;
100 char getLongitudeDirection() const noexcept;
102 unsigned int getGpsQuality() const noexcept;
104 unsigned int getSatellites() const noexcept;
106 double getHdop() const noexcept;
108 double getAltitude() const noexcept;
110 char getAltitudeUnits() const noexcept;
112 double getGeoidalSeparation() const noexcept;
114 char getGeoidalSeparationUnits() const noexcept;
116 double getDgpsAge() const noexcept;
118 std::string getDgpsReferenceStationId() const noexcept;
119
126 std::string getStringContent(bool verbose) const noexcept override;
127
136 bool operator==(const GGA& other) const noexcept;
137
138private:
139 double utcTime_{};
140 double latitude_{};
141 char latitudeDirection_{};
142 double longitude_{};
143 char longitudeDirection_{};
144 unsigned int gpsQuality_{};
145 unsigned int satellites_{};
146 double hdop_{};
147 double altitude_{};
148 char altitudeUnits_{};
149 double geoidalSeparation_{};
150 char geoidalSeparationUnits_{};
151 double dgpsAge_{};
152 std::string dgpsReferenceStationId_{};
153
154 GGA() = delete;
155
156 GGA(Message0183 baseMessage,
157 double timestamp,
158 double latitude,
159 char latitudeDirection,
160 double longitude,
161 char longitudeDirection,
162 unsigned int gpsQuality,
163 unsigned int satellites,
164 double hdop,
165 double altitude,
166 char altitudeUnits,
167 double geoidalSeparation,
168 char geoidalSeparationUnits,
169 double dgpsAge,
170 std::string dgpsReferenceStationId
171 ) noexcept;
172
173 static std::unique_ptr<GGA> create(std::unique_ptr<Message0183> baseMessage);
174 static std::string composeRaw(const std::string& talkerId,
175 double timestamp,
176 double latitude,
177 char latitudeDirection,
178 double longitude,
179 char longitudeDirection,
180 unsigned int gpsQuality,
181 unsigned int satellites,
182 double hdop,
183 double altitude,
184 char altitudeUnits,
185 double geoidalSeparation,
186 char geoidalSeparationUnits,
187 double dgpsAge,
188 const std::string& dgpsReferenceStationId);
189
190 friend class Nmea0183Factory;
191 friend class MessageRegistry;
192};
193
194} // namespace nmea0183
195} // namespace nmealib
Defines a base class for NMEA messages, encapsulating common properties and behaviors.
Definition message.h:14
Base exception class for all NMEA library errors.
Represents a parsed NMEA 0183 GGA (Global Positioning System Fix Data) sentence.
Definition gga.h:36
unsigned int getGpsQuality() const noexcept
Get GPS quality indicator.
Definition gga.cpp:289
double getLatitude() const noexcept
Get latitude in decimal degrees.
Definition gga.cpp:273
unsigned int getSatellites() const noexcept
Get number of satellites used.
Definition gga.cpp:293
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this GGA message.
Definition gga.cpp:170
double getDgpsAge() const noexcept
Get age of DGPS data in seconds.
Definition gga.cpp:317
char getLongitudeDirection() const noexcept
Get longitude hemisphere indicator ('E' or 'W').
Definition gga.cpp:285
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition gga.cpp:174
char getAltitudeUnits() const noexcept
Get altitude units (typically 'M').
Definition gga.cpp:305
GGA(GGA &&) noexcept=default
char getGeoidalSeparationUnits() const noexcept
Get geoidal separation units (typically 'M').
Definition gga.cpp:313
GGA(std::string talkerId, double timestamp, double latitude, char latitudeDirection, double longitude, char longitudeDirection, unsigned int gpsQuality, unsigned int satellites, double hdop, double altitude, char altitudeUnits, double geoidalSeparation, char geoidalSeparationUnits, double dgpsAge, std::string dgpsReferenceStationId)
Construct a GGA message from individual field values.
Definition gga.cpp:125
std::string getDgpsReferenceStationId() const noexcept
Get DGPS reference station identifier.
Definition gga.cpp:321
GGA & operator=(const GGA &)=default
GGA(const GGA &)=default
double getLongitude() const noexcept
Get longitude in decimal degrees.
Definition gga.cpp:281
char getLatitudeDirection() const noexcept
Get latitude hemisphere indicator ('N' or 'S').
Definition gga.cpp:277
double getGeoidalSeparation() const noexcept
Get geoidal separation value.
Definition gga.cpp:309
double getUtcTime() const noexcept
Get UTC fix time in hhmmss.ss numeric form.
Definition gga.cpp:269
double getHdop() const noexcept
Get horizontal dilution of precision.
Definition gga.cpp:297
double getAltitude() const noexcept
Get altitude value.
Definition gga.cpp:301
Represents an NMEA 0183 sentence.
Definition nmea0183.h:98
Registry for message type creators.
Factory for creating typed NMEA 0183 message objects from raw sentence strings.
Exception thrown when a sentence is not a valid GGA sentence.
Definition gga.h:14
NotGGAException(const std::string &context, const std::string &details="")
Construct a NotGGAException with context and optional details.
Definition gga.h:22