NMEA: Qt example extended.
[marnav.git] / src / marnav / nmea / wcv.cpp
blob9258372d0296c183a6ec9484367b06c7d0beb5fb
1 #include "wcv.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(wcv)
10 constexpr const char * wcv::TAG;
12 wcv::wcv()
13 : sentence(ID, TAG, talker_id::global_positioning_system)
17 wcv::wcv(const std::string & talker, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talker)
20 if (std::distance(first, last) != 3)
21 throw std::invalid_argument{"invalid number of fields in wcv"};
23 read(*(first + 0), speed);
24 read(*(first + 1), speed_unit);
25 read(*(first + 2), waypoint_id);
28 void wcv::set_speed(double t) noexcept
30 speed = t;
31 speed_unit = unit::velocity::knot;
34 std::vector<std::string> wcv::get_data() const
36 return {format(speed, 1), to_string(speed_unit), to_string(waypoint_id)};