NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / tpt.cpp
bloba6387fc01f23f936f27b66746fa54faaa94605c7
1 #include "tpt.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(tpt)
10 constexpr const char * tpt::TAG;
12 tpt::tpt()
13 : sentence(ID, TAG, talker_id::global_positioning_system)
17 tpt::tpt(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 6)
21 throw std::invalid_argument{"invalid number of fields in tpt"};
23 read(*(first + 0), range);
24 read(*(first + 1), range_unit);
25 read(*(first + 2), bearing);
26 // separator omitted intentionally
27 read(*(first + 4), depth);
28 read(*(first + 5), depth_unit);
31 std::vector<std::string> tpt::get_data() const
33 return {to_string(range), to_string(range_unit), to_string(bearing), "P", to_string(depth),
34 to_string(depth_unit)};