1 #include <marnav/nmea/nmea.hpp>
2 #include <marnav/nmea/ais_helper.hpp>
3 #include <marnav/ais/ais.hpp>
4 #include <marnav/ais/message_05.hpp>
10 using namespace marnav
;
12 // received NMEA sentences
13 const std::vector
<std::string
> received_strings
14 = {"!AIVDM,2,1,3,B,55P5TL01VIaAL@7WKO@mBplU@<PDhh000000001S;AJ::4A80?4i@E53,0*3E",
15 "!AIVDM,2,2,3,B,1@0000000000000,2*55"};
17 // parse NMEA sentences
18 std::vector
<std::unique_ptr
<nmea::sentence
>> sentences
;
19 for (auto const & txt
: received_strings
) {
20 auto sentence
= nmea::make_sentence(txt
);
21 if (sentence
->id() == nmea::sentence_id::VDM
) {
22 sentences
.push_back(std::move(sentence
));
26 // parse and and process AIS messags
27 auto payload
= nmea::collect_payload(sentences
.begin(), sentences
.end());
28 auto message
= ais::make_message(payload
);
29 if (message
->type() == ais::message_id::static_and_voyage_related_data
) {
30 auto report
= ais::message_cast
<ais::message_05
>(message
);
31 std::cout
<< "shipname: " << report
->get_shipname() << "\n";
32 std::cout
<< "callsign: " << report
->get_callsign() << "\n";