1 #include <marnav/nmea/wcv.hpp>
2 #include <marnav/nmea/io.hpp>
7 constexpr sentence_id
wcv::ID
;
8 constexpr const char * wcv::TAG
;
11 : sentence(ID
, TAG
, talker::global_positioning_system
)
15 wcv::wcv(talker talk
, fields::const_iterator first
, fields::const_iterator last
)
16 : sentence(ID
, TAG
, talk
)
18 if (std::distance(first
, last
) != 3)
19 throw std::invalid_argument
{"invalid number of fields in wcv"};
21 std::optional
<unit::velocity
> speed_unit
;
23 read(*(first
+ 0), speed_
);
24 read(*(first
+ 1), speed_unit
);
25 read(*(first
+ 2), waypoint_id_
);
27 check_value(speed_unit
, {unit::velocity::knot
}, "speed unit");
30 void wcv::set_speed(units::velocity t
) noexcept
32 speed_
= t
.get
<units::knots
>();
35 std::optional
<units::velocity
> wcv::get_speed() const
42 void wcv::append_data_to(std::string
& s
, const version
&) const
44 append(s
, format(speed_
, 1));
45 append(s
, to_string_if(unit::velocity::knot
, speed_
));
46 append(s
, to_string(waypoint_id_
));