FGx  1
loadAptDat.h
1 /* ********************************************************
2  * loadAptDat
3  *
4  * Created by Geoff R. Mclane, Paris
5  * (C) Dec 2011 GPL2 (or later)
6  *
7  * Load the flightgear apt.dat.gz file
8  *
9  ******************************************************** */
10 #ifndef LOADAPTDAT_H
11 #define LOADAPTDAT_H
12 #include "app_config.h"
13 #include <QWidget>
14 #include <QString>
15 #include <QTime>
16 #include <QFile>
17 #include <QFileInfo> // to compare to previous loaded file size
18 #include <QDateTime> // and date/time
19 #include "utilities/fgx_gzlib.h"
20 #include "utilities/workThread.h"
21 
22 typedef struct tagAD_WINDSOCK {
23  double lat,lon,elev;
25 typedef QList<AD_WINDSOCK> SOCKLIST;
26 
27 typedef struct tagAD_COMMS {
28  int type; // 50-56 like 53 Identifies this as an airport ATC frequency line.
29  double freq; // 12190 / 100 - Airport ATC frequency, in Megahertz (ie. 121.90 MHz in this example).
30  QString name; // like GND - Name of the ATC frequency. This is often an abbreviation (such as GND for "Ground").
31 }AD_COMMS;
32 typedef QList<AD_COMMS> COMMLIST;
33 
34 typedef struct tagAD_RUNWAY {
35  double lat,lon, hdgt, lenft;
36  QString id;
37 }AD_RUNWAY;
38 typedef QList<AD_RUNWAY> RUNWAYLIST;
39 
40 typedef struct tagAD_AIRPORT {
41  QString icao;
42  QString name;
43  double elev;
44  double clat,clon;
45  double tlat,tlon,televft;
46  bool got_tower;
47  SOCKLIST sock_list;
48  RUNWAYLIST run_list;
49  RUNWAYLIST tax_list;
50  COMMLIST comm_list;
51  int rank;
52  double distance_km;
54 typedef QList<PAD_AIRPORT> AIRPORTLIST;
55 typedef AIRPORTLIST * PAIRPORTLIST;
56 #define INITPAP(a) a->got_tower = false
57 
58 typedef struct tagLOADITEM {
59  WORKITEM work; // *MUST* be first
60  int threadnum;
61  QString zf;
62  AIRPORTLIST * pAirList; // fill this list
63  int loadTime_ms;
64  int optionFlag;
65  bool result;
66  bool in_loading;
67  QString msg;
69 
70 // negative flags, so that 0 is the DEFAULT
71 #define lf_noAddTax 0x00000001
72 #define lf_noSkipOOR 0x00000002 // SKIP out-of-range values, else FIX
73 #define lf_noFixName 0x00000004 // fix case of name
74 #define lf_ForceLoad 0x00000008 // force a load, even if the SAME file
75 
76 class loadAptDat : public QObject
77 {
78  Q_OBJECT
79 public:
80  explicit loadAptDat(QObject *par = 0);
81  ~loadAptDat();
82  QString fgroot;
83  bool loadDirect(QString file, int flag = 0);
84  int loadOnThread(QString file, int flag = 0); // ret 0 = on thread, flag = one or more of above flags - default none
85  PAIRPORTLIST getAirListPtr();
86  PAIRPORTLIST setAirListPtr(PAIRPORTLIST);
87  void clear_list(PAIRPORTLIST pal = 0);
88  int getAirportCount();
89  int getRunwayCount();
90  int loadTime_ms;
91  int getLoadTime() { return loadTime_ms; }
92  PAD_AIRPORT findAirportByICAO(QString);
93  QString findNameByICAO(QString icao, int flag = 0); // note 'flag' presently NOT USED!
94  QString getAiportStg(PAD_AIRPORT pad, int flag = 0);
95  AIRPORTLIST *getNearestAiportList(PAD_AIRPORT pad, int flag = 0);
96  bool isThreadInFunction();
97  LOADITEM loadItem; // structure passed to thread
98  bool isFileLoaded(QString zf); // compare with LAST loaded apt.dat file
99 
100 signals:
101  void load_done();
102 
103 public slots:
104  void thread_done(int,int);
105 
106 private:
107  PAIRPORTLIST pAirList;
108  static void _loadStatic(void *vp);
109  workThread *workthread;
110  QString last_load; // file last loaded
111  qint64 last_size; // its size
112  QDateTime last_date; // and date/time last modified
113 };
114 
115 extern void sortByICAO(AIRPORTLIST *pal);
116 
117 
118 #endif // LOADAPTDAT_H
119 // eof - loadAptdat.h
Definition: workThread.h:66
Definition: loadAptDat.h:58
Definition: workThread.h:58
Definition: loadAptDat.h:27
Definition: loadAptDat.h:40
Definition: loadAptDat.h:22
Definition: loadAptDat.h:76
Definition: loadAptDat.h:34