1 #include <marnav/ais/message_23.hpp>
2 #include <marnav/ais/angle.hpp>
10 constexpr message_id
message_23::ID
;
11 constexpr std::size_t message_23::SIZE_BITS
;
13 message_23::message_23()
18 message_23::message_23(const raw
& bits
)
21 if (bits
.size() != SIZE_BITS
)
22 throw std::invalid_argument
{"invalid number of bits in message_23"};
26 void message_23::read_data(const raw
& bits
)
28 get(bits
, repeat_indicator
);
34 get(bits
, station_type
);
38 get(bits
, quiet_time
);
41 raw
message_23::get_data() const
45 bits
.set(type(), 0, 6);
46 set(bits
, repeat_indicator
);
52 set(bits
, station_type
);
56 set(bits
, quiet_time
);
61 std::optional
<geo::position
> message_23::get_position_ne() const
63 if ((ne_lat
== latitude_not_available_short
) || (ne_lon
== longitude_not_available_short
))
64 return std::make_optional
<geo::position
>();
66 return std::make_optional
<geo::position
>(
67 to_geo_latitude(ne_lat
, ne_lat
.count
, angle_scale::I1
),
68 to_geo_longitude(ne_lon
, ne_lon
.count
, angle_scale::I1
));
71 std::optional
<geo::position
> message_23::get_position_sw() const
73 if ((sw_lat
== latitude_not_available_short
) || (sw_lon
== longitude_not_available_short
))
74 return std::make_optional
<geo::position
>();
76 return std::make_optional
<geo::position
>(
77 to_geo_latitude(sw_lat
, sw_lat
.count
, angle_scale::I1
),
78 to_geo_longitude(sw_lon
, sw_lon
.count
, angle_scale::I1
));
81 void message_23::set_position_ne(const geo::position
& t
) noexcept
83 ne_lat
= to_latitude_minutes(t
.lat(), ne_lat
.count
, angle_scale::I1
);
84 ne_lon
= to_longitude_minutes(t
.lon(), ne_lon
.count
, angle_scale::I1
);
87 void message_23::set_position_sw(const geo::position
& t
) noexcept
89 sw_lat
= to_latitude_minutes(t
.lat(), sw_lat
.count
, angle_scale::I1
);
90 sw_lon
= to_longitude_minutes(t
.lon(), sw_lon
.count
, angle_scale::I1
);