1 #include "message_23.hpp"
4 #include <marnav/ais/angle.hpp>
10 message_23::message_23()
15 message_23::message_23(const raw
& bits
)
18 if (bits
.size() != SIZE_BITS
)
19 throw std::invalid_argument
{"invalid number of bits in message_23"};
23 void message_23::read_data(const raw
& bits
)
25 get(bits
, repeat_indicator
);
31 get(bits
, station_type
);
35 get(bits
, quiet_time
);
38 raw
message_23::get_data() const
42 bits
.set(type(), 0, 6);
43 set(bits
, repeat_indicator
);
49 set(bits
, station_type
);
53 set(bits
, quiet_time
);
58 utils::optional
<geo::position
> message_23::get_position_ne() const
60 if ((ne_lat
== latitude_not_available_short
) || (ne_lon
== longitude_not_available_short
))
61 return utils::make_optional
<geo::position
>();
63 return utils::make_optional
<geo::position
>(
64 to_geo_latitude(ne_lat
, ne_lat
.count
, angle_scale::I1
),
65 to_geo_longitude(ne_lon
, ne_lon
.count
, angle_scale::I1
));
68 utils::optional
<geo::position
> message_23::get_position_sw() const
70 if ((sw_lat
== latitude_not_available_short
) || (sw_lon
== longitude_not_available_short
))
71 return utils::make_optional
<geo::position
>();
73 return utils::make_optional
<geo::position
>(
74 to_geo_latitude(sw_lat
, sw_lat
.count
, angle_scale::I1
),
75 to_geo_longitude(sw_lon
, sw_lon
.count
, angle_scale::I1
));
78 void message_23::set_position_ne(const geo::position
& t
) noexcept
80 ne_lat
= to_latitude_minutes(t
.lat(), ne_lat
.count
, angle_scale::I1
);
81 ne_lon
= to_longitude_minutes(t
.lon(), ne_lon
.count
, angle_scale::I1
);
84 void message_23::set_position_sw(const geo::position
& t
) noexcept
86 sw_lat
= to_latitude_minutes(t
.lat(), sw_lat
.count
, angle_scale::I1
);
87 sw_lon
= to_longitude_minutes(t
.lon(), sw_lon
.count
, angle_scale::I1
);