24 #ifndef GOBY_UTIL_AIS_DECODE_H
25 #define GOBY_UTIL_AIS_DECODE_H
34 #include <boost/algorithm/string/classification.hpp>
35 #include <boost/algorithm/string/predicate_facade.hpp>
36 #include <boost/algorithm/string/trim.hpp>
37 #include <boost/units/base_unit.hpp>
38 #include <boost/units/base_units/metric/knot.hpp>
39 #include <boost/units/operators.hpp>
40 #include <boost/units/systems/angle/degrees.hpp>
41 #include <boost/units/systems/si/length.hpp>
65 Decoder(
const std::vector<NMEASentence>& nmeas);
70 bool complete() {
return ais_msg_ !=
nullptr; }
75 return ais_msg_->message_id;
114 std::string trim_ais_string(std::string in)
116 boost::trim_if(in, boost::algorithm::is_space() || boost::algorithm::is_any_of(
"@"));
120 template <
typename LibAisMessage>
126 voy_.set_message_id(ais.message_id);
127 voy_.set_mmsi(ais.mmsi);
131 std::string name = trim_ais_string(ais.name);
135 else if (part_num == 1)
137 std::string callsign = trim_ais_string(ais.callsign);
138 if (!callsign.empty())
139 voy_.set_callsign(callsign);
143 voy_.set_to_bow_with_units(ais.dim_a * si::meters);
144 voy_.set_to_stern_with_units(ais.dim_b * si::meters);
145 voy_.set_to_port_with_units(ais.dim_c * si::meters);
146 voy_.set_to_starboard_with_units(ais.dim_d * si::meters);
150 template <
typename LibAisMessage>
156 metric::knot_base_unit::unit_type knots;
161 if (ais.true_heading >= 0 && ais.true_heading < 360)
167 pos_.set_position_accuracy(
171 void decode_position();
172 void decode_voyage();
175 libais::VdmStream ais_stream_decoder_;
176 std::unique_ptr<libais::AisMsg> ais_msg_;