Updraft
1.0
Open source glider flight visualisation tool.
|
00001 #ifndef UPDRAFT_SRC_LIBRARIES_IGC_IGC_H_ 00002 #define UPDRAFT_SRC_LIBRARIES_IGC_IGC_H_ 00003 00004 #include <QByteArray> 00005 #include <QDate> 00006 #include <QIODevice> 00007 #include <QList> 00008 #include <QString> 00009 #include <QTextCodec> 00010 #include <QTime> 00011 00012 #include "../util/util.h" 00013 00014 #ifdef UPDRAFT_IGC_INTERNAL 00015 #define IGC_EXPORT Q_DECL_EXPORT 00016 #else 00017 #define IGC_EXPORT Q_DECL_IMPORT 00018 #endif 00019 00020 namespace Updraft { 00021 namespace Igc { 00022 00026 struct Event { 00027 enum EventType { 00028 FIX = 1, 00029 PILOT_EVENT = 2 00030 }; 00031 00032 EventType type; 00033 00034 QTime timestamp; 00035 }; 00036 00038 struct Fix : public Event { 00039 Util::Location gpsLoc; 00040 bool valid; 00041 qreal pressureAlt; 00042 }; 00043 00045 struct PilotEvent : public Event {}; 00046 00048 class IGC_EXPORT IgcFile { 00049 public: 00050 typedef QList<Event const*> EventList; 00051 typedef QListIterator<Event const*> EventListIterator; 00052 00053 ~IgcFile() { clear(); } 00054 00055 bool load(const QString &path, QTextCodec *codec = 0); 00056 bool load(QIODevice *file, QTextCodec *codec = 0); 00057 00058 void clear(); 00059 00064 qreal altimeterSetting() const { return altimeterSetting_; } 00065 00067 QString competitionClass() const { return competitionClass_; } 00068 00070 QString competitionId() const { return competitionId_; } 00071 00073 QDate date() const { return date_; } 00074 00076 QString manufacturer() const { return manufacturer_; } 00077 00079 QString frType() const { return frType_; } 00080 00082 QString gliderId() const { return gliderId_; } 00083 00085 QString gps() const { return gps_; } 00086 00088 QString gliderType() const { return gliderType_; } 00089 00091 QString pilot() const { return pilot_; } 00092 00094 const EventList& events() const { return eventList; } 00095 00096 private: 00099 bool loadOneRecord(); 00100 00102 bool parseOneRecord(); 00103 00107 QTime parseTimestamp(QByteArray bytes, bool* ok); 00108 00115 qreal parseLatLon(QByteArray bytes, bool* ok); 00116 00120 qreal parseDecimal(QByteArray bytes, bool* ok); 00121 00125 QDate parseDate(QByteArray bytes, bool* ok); 00126 00128 bool processRecordB(); 00129 00131 bool processRecordH(); 00132 00134 bool processRecordL(); 00135 00136 static bool eventLessThan(Event const* e1, Event const* e2); 00137 00138 EventList eventList; 00139 00140 QByteArray buffer; 00141 00142 char previousRecord; 00143 QIODevice* file; 00144 QTextCodec *activeCodec; 00145 00148 qreal altimeterSetting_; 00149 QString competitionClass_; 00150 QString competitionId_; 00151 QDate date_; 00152 QString manufacturer_; 00153 QString frType_; 00154 QString gliderId_; 00155 QString gps_; 00156 QString gliderType_; 00157 QString pilot_; 00159 }; 00160 00161 } // End namespace Igc 00162 } // End namespace Updraft 00163 00164 #endif // UPDRAFT_SRC_LIBRARIES_IGC_IGC_H_ 00165