1 #include <marnav/nmea/wcv.hpp>
2 #include <marnav/nmea/io.hpp>
9 constexpr sentence_id
wcv::ID
;
10 constexpr const char * wcv::TAG
;
13 : sentence(ID
, TAG
, talker::global_positioning_system
)
17 wcv::wcv(talker talk
, fields::const_iterator first
, fields::const_iterator last
)
18 : sentence(ID
, TAG
, talk
)
20 if (std::distance(first
, last
) != 3)
21 throw std::invalid_argument
{"invalid number of fields in wcv"};
23 utils::optional
<unit::velocity
> speed_unit
;
25 read(*(first
+ 0), speed_
);
26 read(*(first
+ 1), speed_unit
);
27 read(*(first
+ 2), waypoint_id_
);
29 check_value(speed_unit
, {unit::velocity::knot
}, "speed unit");
32 void wcv::set_speed(units::velocity t
) noexcept
34 speed_
= t
.get
<units::knots
>();
37 utils::optional
<units::velocity
> wcv::get_speed() const
44 void wcv::append_data_to(std::string
& s
) const
46 append(s
, format(speed_
, 1));
47 append(s
, to_string_if(unit::velocity::knot
, speed_
));
48 append(s
, to_string(waypoint_id_
));