NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / wpl.hpp
blob37f4897b3fef21ee0cc680dc7ec43c3de432fb60
1 #ifndef __MARNAV__NMEA__WPL__HPP__
2 #define __MARNAV__NMEA__WPL__HPP__
4 #include <marnav/nmea/sentence.hpp>
5 #include <marnav/nmea/angle.hpp>
6 #include <marnav/nmea/waypoint.hpp>
7 #include <marnav/utils/optional.hpp>
9 namespace marnav
11 namespace nmea
13 MARNAV_NMEA_DECLARE_SENTENCE_PARSE_FUNC(wpl)
15 /// @brief WPL - Waypoint Location
16 ///
17 /// @code
18 /// 1 2 3 4 5
19 /// | | | | |
20 /// $--WPL,llll.ll,a,yyyyy.yy,a,c--c*hh<CR><LF>
21 /// @endcode
22 ///
23 /// Field Number:
24 /// 1. Latitude
25 /// 2. Latitude hemisphere
26 /// - N = North
27 /// - S = South
28 /// 3. Longitude
29 /// 4. Longitude hemisphere
30 /// - E = East
31 /// - W = West
32 /// 5. Waypoint ID
33 ///
34 class wpl : public sentence
36 MARNAV_NMEA_SENTENCE_FRIENDS(wpl)
38 public:
39 constexpr static const sentence_id ID = sentence_id::WPL;
40 constexpr static const char * TAG = "WPL";
42 wpl();
43 wpl(const wpl &) = default;
44 wpl & operator=(const wpl &) = default;
45 wpl(wpl &&) = default;
46 wpl & operator=(wpl &&) = default;
48 protected:
49 wpl(talker talk, fields::const_iterator first, fields::const_iterator last);
50 virtual std::vector<std::string> get_data() const override;
52 private:
53 utils::optional<geo::latitude> lat;
54 utils::optional<direction> lat_hem; // latitude hemisphere (N or S)
55 utils::optional<geo::longitude> lon;
56 utils::optional<direction> lon_hem; // longitude hemisphere (E or W)
57 utils::optional<waypoint> waypoint_id;
59 public:
60 decltype(waypoint_id) get_waypoint_id() const { return waypoint_id; }
62 utils::optional<geo::longitude> get_longitude() const;
63 utils::optional<geo::latitude> get_latitude() const;
65 void set_lat(const geo::latitude & t);
66 void set_lon(const geo::longitude & t);
67 void set_waypoint(const waypoint & id) { waypoint_id = id; }
72 #endif