NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / hdt.cpp
blob372c69a0b1a018989e4b1506ac8fba51c79c3ff9
1 #include "hdt.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(hdt)
10 constexpr const char * hdt::TAG;
12 hdt::hdt()
13 : sentence(ID, TAG, talker_id::integrated_instrumentation)
17 hdt::hdt(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 2)
21 throw std::invalid_argument{"invalid number of fields in hdt"};
23 read(*(first + 0), heading);
24 read(*(first + 1), heading_true);
27 void hdt::set_heading(double t) noexcept
29 heading = t;
30 heading_true = reference::TRUE;
33 std::vector<std::string> hdt::get_data() const
35 return {to_string(heading), to_string(heading_true)};