1 #include "message_22.hpp"
4 #include <marnav/ais/angle.hpp>
10 MARNAV_AIS_DEFINE_MESSAGE_PARSE_FUNC(message_22
)
12 message_22::message_22()
17 message_22::message_22(const raw
& bits
)
20 if (bits
.size() != SIZE_BITS
)
21 throw std::invalid_argument
{"invalid number of bits in message_22"};
25 void message_22::read_data(const raw
& bits
)
27 get(bits
, repeat_indicator
);
49 raw
message_22::get_data() const
53 bits
.set(type(), 0, 6);
54 set(bits
, repeat_indicator
);
78 utils::optional
<geo::position
> message_22::get_position_ne() const
80 if ((ne_lat
== latitude_not_available_short
) || (ne_lon
== longitude_not_available_short
))
81 return utils::make_optional
<geo::position
>();
83 // TODO: investigate lat/lon range (lon values of 385.xxx discovered in the wild)
85 return utils::make_optional
<geo::position
>(
86 geo::latitude
{ne_lat
/ (60.0 * 10.0)}, geo::longitude
{ne_lon
/ (60.0 * 10.0)});
89 utils::optional
<geo::position
> message_22::get_position_sw() const
91 if ((sw_lat
== latitude_not_available_short
) || (sw_lon
== longitude_not_available_short
))
92 return utils::make_optional
<geo::position
>();
94 // TODO: investigate lat/lon range
96 return utils::make_optional
<geo::position
>(
97 geo::latitude
{sw_lat
/ (60.0 * 10.0)}, geo::longitude
{sw_lon
/ (60.0 * 10.0)});
100 void message_22::set_position_ne(const geo::position
& t
) noexcept
102 ne_lat
= std::floor(60.0 * 10.0 * t
.lat());
103 ne_lon
= std::floor(60.0 * 10.0 * t
.lon());
106 void message_22::set_position_sw(const geo::position
& t
) noexcept
108 sw_lat
= std::floor(60.0 * 10.0 * t
.lat());
109 sw_lon
= std::floor(60.0 * 10.0 * t
.lon());