1 #ifndef _igc_h_ |
1 #ifndef _igc_h_ |
2 #define _igc_h_ |
2 #define _igc_h_ |
3 |
3 |
4 #include "pch.h" |
4 #include "pch.h" |
5 |
5 |
|
6 /*! Fix - describes one GPS fix. |
|
7 * |
|
8 * A GPS fix is represented by a timestamp (no day included?), |
|
9 * a longitude, a latitude, the barometric altitude, the |
|
10 * GPS altitude and a flag, if the GPS altitude is valid. |
|
11 */ |
6 class Fix { |
12 class Fix { |
7 public: |
13 public: |
8 enum Source { baro, gps }; |
14 //! Selector for the source of the altitude. |
|
15 enum Source { |
|
16 baro, //!< source from barometer |
|
17 gps, //!< source from gps |
|
18 }; |
9 |
19 |
10 Fix() { } |
20 Fix() { } |
11 Fix(const QString&); |
21 Fix(const QString&); //!< parse the string for the fix |
12 |
22 |
|
23 //! Get the altitude. |
|
24 //! \param s source of the altitude (gps or baro) |
|
25 //! \return altitude in m |
13 int altitude(Source s = gps) const { return alt_[s]; } |
26 int altitude(Source s = gps) const { return alt_[s]; } |
14 QTime time() const { return time_; } |
|
15 bool is3d() const { return is3d_; } |
|
16 QPair<QTime, int> altitudeFix(Source s) const { return qMakePair(time_, alt_[s]); } |
|
17 |
27 |
18 QString longitude() const { return gps_.lon; } |
28 QTime time() const { return time_; } //!< time of the fix |
19 QString latitude() const { return gps_.lat; }; |
29 bool is3d() const { return is3d_; } //!< is the gps alt valid? |
|
30 |
|
31 //! Get an altitude fix (time+altitude) |
|
32 //! \param s source of the altitude (default: gps) |
|
33 QPair<QTime, int> altitudeFix(Source s = gps) const { return qMakePair(time_, alt_[s]); } |
|
34 |
|
35 QString longitude() const { return gps_.lon; } //!< longitude of the fix |
|
36 QString latitude() const { return gps_.lat; }; //!< latitude of the fix |
20 |
37 |
21 private: |
38 private: |
22 QTime time_; |
39 QTime time_; |
23 bool is3d_; |
40 bool is3d_; |
24 struct { QString lon, lat; } gps_; |
41 struct { QString lon, lat; } gps_; |
25 int alt_[2]; |
42 int alt_[2]; |
26 }; |
43 }; |
27 |
44 |
|
45 //! List of Fixes. |
28 typedef QList<Fix> Fixes; |
46 typedef QList<Fix> Fixes; |
29 |
47 |
|
48 /*! Representation of the IGC file. |
|
49 * |
|
50 * This class represends the contents of an IGC file. |
|
51 * It reads from a text stream an stores the header data as well as the |
|
52 * fixes. The checksum verification is not implemented currently. |
|
53 */ |
30 class IGC { |
54 class IGC { |
31 public: |
55 public: |
32 void read(QTextStream&); |
56 |
33 QString device() const { return device_; } |
57 //! Read the IGC records. |
34 QString pilot() const { return pilot_; } |
58 //! \param s a (file) stream containing the records |
35 QString glider() const { return glider_; } |
59 void read(QTextStream& s); |
36 QDate date() const { return date_; } |
60 QString device() const { return device_; } //!< the generator of the IGC file |
|
61 QString pilot() const { return pilot_; } //!< pilots name |
|
62 QString glider() const { return glider_; } //!< type of glider |
|
63 QDate date() const { return date_; } //!< date of the record (start date?) |
37 |
64 |
38 Fixes fixes() const { return fixes_; } |
65 Fixes fixes() const { return fixes_; } //!< list of fixes |
39 Fixes fixes() { return fixes_; } |
|
40 |
66 |
41 Fix start() const { return start_; } |
67 Fix start() const { return start_; } //!< the very first fix |
42 Fix landing() const { return landing_; } |
68 Fix landing() const { return landing_; } //!< the very last fix |
43 |
69 |
44 private: |
70 private: |
45 QString device_, pilot_, glider_; |
71 QString device_, pilot_, glider_; |
46 QDate date_; |
72 QDate date_; |
47 Fixes fixes_; |
73 Fixes fixes_; |