1 #include "message_22.hpp"
4 #include <marnav/ais/angle.hpp>
10 message_22::message_22()
15 message_22::message_22(const raw
& bits
)
18 if (bits
.size() != SIZE_BITS
)
19 throw std::invalid_argument
{"invalid number of bits in message_22"};
23 void message_22::read_data(const raw
& bits
)
25 get(bits
, repeat_indicator
);
47 raw
message_22::get_data() const
51 bits
.set(type(), 0, 6);
52 set(bits
, repeat_indicator
);
76 utils::optional
<geo::position
> message_22::get_position_ne() const
78 if ((ne_lat
== latitude_not_available_short
) || (ne_lon
== longitude_not_available_short
))
79 return utils::make_optional
<geo::position
>();
81 return utils::make_optional
<geo::position
>(
82 to_geo_latitude(ne_lat
, ne_lat
.count
, angle_scale::I1
),
83 to_geo_longitude(ne_lon
, ne_lon
.count
, angle_scale::I1
));
86 utils::optional
<geo::position
> message_22::get_position_sw() const
88 if ((sw_lat
== latitude_not_available_short
) || (sw_lon
== longitude_not_available_short
))
89 return utils::make_optional
<geo::position
>();
91 return utils::make_optional
<geo::position
>(
92 to_geo_latitude(sw_lat
, sw_lat
.count
, angle_scale::I1
),
93 to_geo_longitude(sw_lon
, sw_lon
.count
, angle_scale::I1
));
96 void message_22::set_position_ne(const geo::position
& t
) noexcept
98 ne_lat
= to_latitude_minutes(t
.lat(), ne_lat
.count
, angle_scale::I1
);
99 ne_lon
= to_longitude_minutes(t
.lon(), ne_lon
.count
, angle_scale::I1
);
102 void message_22::set_position_sw(const geo::position
& t
) noexcept
104 sw_lat
= to_latitude_minutes(t
.lat(), sw_lat
.count
, angle_scale::I1
);
105 sw_lon
= to_longitude_minutes(t
.lon(), sw_lon
.count
, angle_scale::I1
);