NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / bod.cpp
blob3da16c64b793b3e0f44bed6c4f1ba9c609ec2d29
1 #include "bod.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(bod)
10 constexpr const char * bod::TAG;
12 bod::bod()
13 : sentence(ID, TAG, talker_id::global_positioning_system)
17 bod::bod(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 6)
21 throw std::invalid_argument{"invalid number of fields in bod"};
23 read(*(first + 0), bearing_true);
24 read(*(first + 1), type_true);
25 read(*(first + 2), bearing_magn);
26 read(*(first + 3), type_magn);
27 read(*(first + 4), waypoint_to);
28 read(*(first + 5), waypoint_from);
31 void bod::set_bearing_true(double t) noexcept
33 bearing_true = t;
34 type_true = reference::TRUE;
37 void bod::set_bearing_magn(double t) noexcept
39 bearing_magn = t;
40 type_magn = reference::MAGNETIC;
43 std::vector<std::string> bod::get_data() const
45 return {to_string(bearing_true), to_string(type_true), to_string(bearing_magn),
46 to_string(type_magn), to_string(waypoint_to), to_string(waypoint_from)};