1 #include <marnav/seatalk/message_50.hpp>
8 message_50::message_50()
13 std::unique_ptr
<message
> message_50::parse(const raw
& data
)
15 check_size(data
, SIZE
);
17 std::unique_ptr
<message
> result
= utils::make_unique
<message_50
>();
18 message_50
& msg
= static_cast<message_50
&>(*result
);
23 const uint32_t degrees
= data
[2];
29 const uint32_t minutes
= (m
& 0x7fff) / 100;
30 const uint32_t seconds
= (((m
& 0x7fff) % 100) * 60) / 100;
31 const geo::latitude::hemisphere hemisphere
32 = (m
& 0x8000) ? geo::latitude::hemisphere::south
: geo::latitude::hemisphere::north
;
34 msg
.lat_
= geo::latitude
{degrees
, minutes
, seconds
, hemisphere
};
36 // deliberately ignored 'Z'
41 raw
message_50::get_data() const
44 m
+= lat_
.minutes() * 100;
45 m
+= (lat_
.seconds() * 100) / 60;
46 if (lat_
.hem() == geo::latitude::hemisphere::south
)
49 return raw
{static_cast<uint8_t>(ID
), 0x02, static_cast<uint8_t>(lat_
.degrees() & 0xff),
50 static_cast<uint8_t>((m
>> 8) & 0xff), static_cast<uint8_t>((m
>> 0) & 0xff)};