-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXFMS_DATA.h
191 lines (150 loc) · 7.63 KB
/
XFMS_DATA.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#ifndef XFMS_DATA_HEADER
#define XFMS_DATA_HEADER
#include <map>
#include <vector>
#include <QString>
#include <NVU.h>
#include <QFile>
#define XNVU_WPS_FILENAME "xnvu_wps.txt"
class RUNWAY;
class NAV_SOURCE_DATA
{
public:
int airacCycle = -1;
int fileVersion = -1;
QString validDate = "";
};
class XFMS_DATA
{
private:
static std::multimap<QString, NVUPOINT*> lWP; //QString is IDENTIFIER of waypoint NVUPOINT
static std::multimap<QString, NVUPOINT*> lWP2; //QString is the NAME of waypoint NVUPOINT
static int _loadXP10(const QString& file, int _type);
static int _loadAirportsXP11(QString& sError);
static int _loadWaypointsXP11(QString& sError);
static int _loadNavDataXP11(QString& sError);
static int _loadAirwaysXP11(QString& sError);
static int validate_header(QFile& infile); //TODO: Currently not used.
static void validate_cycle_info(QFile& infile, NAV_SOURCE_DATA& _navSource); //TODO: Currently not used.
static void validate_airports_XP11(QFile& infile, int wpOrigin);
static void validate_runways(NVUPOINT *ap, const std::vector<RUNWAY*>& lRunways);
static void validate_waypoint_XP11(const QStringList &record, int _origin);
static void validate_earthnav_XP11(const QStringList& record, int _origin);
static void validate_airways_XP11(QFile& infile, int _origin);
static void validate_airport_XP10(const QStringList& record);
static void validate_navaid_XP10(const QStringList& record);
static void validate_waypoint_XP10(const QStringList &record);
static void validate_earthnav_XP10(const QStringList& record);
static void validate_airways_XP10(QFile&);
static void validate_RSBN(const QStringList& record);
static void validate_xnvu(const QStringList& record);
static void validate_fms(std::vector<NVUPOINT*>& lFMS, const QStringList& record);
static void validate_xnvuflightplan(std::vector<NVUPOINT*>& lXNVUFlightplan, const QStringList& record);
//Returns a new allocated waypoint if successful. If waypoint is a bearing/distance waypoint, wpRef needs to be set.
//If error occurs, a description of error is returned.
static QString validate_custom_point(const NVUPOINT* wpRef, NVUPOINT *&rPoint, const QString& record);
static void validate_sidstar_XP11(QFile& _infile, const QString& _airport); //TODO: Under development, only for XP11 currently
public:
static int dat;
//Variables accessable for the initial loading process of data, no practical use otherwise.
static volatile int __DATA_LOADED[8];
static volatile int __CURRENT_LOADING;
static QStringList __SL_FINISHED;
static QString __ERROR_LOADING;
//---------------------------------------
//Loaded from i.e. navigraph (airports.txt, navaids.txt, waypoints.txt, ats.txt)
//static std::vector<NVUPOINT*> lAirports;
//static std::vector<NVUPOINT*> lNDB;
//static std::vector<NVUPOINT*> lVOR;
//static std::vector<NVUPOINT*> lDME;
//static std::vector<NVUPOINT*> lVORDME; //Cannot be used as RSBN, as there is no angle deviation data.
//static std::vector<NVUPOINT*> lILS;
//static std::vector<NVUPOINT*> lFixes;
//static std::vector<AIRWAY*> lAirways;
//Loaded from earth_nav.txt
//static std::vector<NVUPOINT*> lXNDB;
//static std::vector<NVUPOINT*> lXVOR;
//static std::vector<NVUPOINT*> lXDME;
static std::vector<NVUPOINT*> lXVORDME; //Loaded from X-Plane earth earth_nav.dat, as it includes VOR angle deviation data.
//Loaded from rsbn.dat
static std::vector<NVUPOINT*> lRSBN;
//Loaded from XNVU local library from file XNVU_WPS_FILENAME (see top of this file for filename)
static std::vector<NVUPOINT*> lXNVU;
//Get a list of waypoints between two waypoint in an airway, including the waypoints wpA and wpB
//Note that the first and last waypoint in the airway, may differ and should be used instead of wpA and wpB
/*
* airway: Name of airway
* wpA: Waypoint A
* wpB: Waypoint B
* lA: Returned list of waypoints
* allowOpposite: Allow an opposite direction of airway if the correct direction of airway is not found.
* Returns a string of description if error occurs.
*/
static QString getAirwayWaypointsBetween(QString& airway, NVUPOINT* wpA, NVUPOINT* wpB, std::vector<NVUPOINT *> &lA, NVUPOINT *&_wpAirway, bool allowOpposite);
//Create a route defined by a string. Arguments are:
/* _qstr: route string,
* route: returned route,
* wpRef: If set, align first point in route to the nearest of wpRef
*/
static QString getRoute(const QString& _qstr, std::vector<NVUPOINT*>& route, NVUPOINT *wpRef = NULL);
//Returns a list of found waypoints. Searches for ID and NAME of waypoint.
static std::vector<NVUPOINT*> search(const QString& _name, int _type = 0, int _ICAO_name2 = 0, const QString &_country = NULL);
//Returns a list pairs containing waypoint and distance to wp
/*
* wp: waypoint of origo
* n: maximum number of waypoints to return
* d: maximum distance allowed
* includeVOR: Set to TRUE if you want to include VOR:s aswell.
*/
static std::vector< std::pair<NVUPOINT*, double> > getClosestRSBN(const NVUPOINT* wp, int n, double d, bool includeVOR);
//Returns closest waypoint with same type and name and its distance. If not found, returns NULL.
static std::vector< std::pair<NVUPOINT*, double> > getClosestWaypointType(const CPoint& _latlon, const QString &_name, int _type);//, double &distance);
static void addXNVUWaypoint(NVUPOINT* lP);
//static void addXNVUWaypointTempory(NVUPOINT* lP);
static void addXNVUData(std::vector<NVUPOINT*> lP);
static void removeXNVUWaypoint(NVUPOINT* lP);
static void load(int dat);
static int saveXNVUData();
static std::vector<NVUPOINT*> loadFMS(const QString& file);
static int saveFMS(const QString& file, const std::vector<NVUPOINT *> lN);
static void removeFMS();
static int FMSToXNVUType(int _type);
static int XNVUToFMSType(int _type);
static std::vector<NVUPOINT*> loadXNVUFlightplan(const QString& file);
static int saveXNVUFlightplan(const QString& file, std::vector<NVUPOINT*> lN);
static void removeXNVUFlightplan();
static void setDate(int dat);
static void clear();
XFMS_DATA();
~XFMS_DATA();
};
class AIRWAY_SEGMENT_X11
{
public:
NVUPOINT* start;
NVUPOINT* end;
int direction;
int hilo; //High or low
int base;
int top;
QString airway;
static bool isSameIgnoreHILO(const AIRWAY_SEGMENT_X11* a, const AIRWAY_SEGMENT_X11* b)
{
if(a->start != b->start) return false;
if(a->end != b->end) return false;
if(a->airway.compare(b->airway)!=0) return false;
return true;
}
static bool sort(const AIRWAY_SEGMENT_X11* a, const AIRWAY_SEGMENT_X11* b)
{
//Returning true -> place a on left side of b
//AIRWAY_SEGMENT_X11* a = _a.second;
//AIRWAY_SEGMENT_X11* b = _b.second;
int cmp = a->airway.compare(b->airway);
if(cmp<0) return true;
else if(cmp>0) return false;
return false;
}
AIRWAY_SEGMENT_X11(){}
};
#endif