FlightGear next
airways.hxx
Go to the documentation of this file.
1// airways.hxx - storage of airways network, and routing between nodes
2// Written by James Turner, started 2009.
3//
4// Copyright (C) 2009 Curtis L. Olson
5//
6// This program is free software; you can redistribute it and/or
7// modify it under the terms of the GNU General Public License as
8// published by the Free Software Foundation; either version 2 of the
9// License, or (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful, but
12// WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20#ifndef FG_AIRWAYS_HXX
21#define FG_AIRWAYS_HXX
22
23#include <map>
24#include <vector>
25
26#include <Navaids/route.hxx>
28
29class SGPath;
30typedef SGSharedPtr<FGPositioned> FGPositionedRef;
31
32namespace flightgear {
33
34// forward declare some helpers
35struct SearchContext;
36class AdjacentWaypoint;
37class InAirwayFilter;
38class Airway;
39
40using AirwayRef = SGSharedPtr<Airway>;
41
42class Airway : public RouteBase
43{
44public:
45 enum Level {
49 Both = 3
50 };
51
52 std::string ident() const override
53 { return _ident; }
54
55 int cacheId() const
56 { return _cacheId; }
57
58 Level level() const
59 { return _level; }
60
61 static void loadAWYDat(const SGPath& path);
62
63 double topAltitudeFt() const
64 { return _topAltitudeFt; }
65
66 double bottomAltitudeFt() const
67 { return _bottomAltitudeFt; }
68
70
71 static AirwayRef findByIdent(const std::string& aIdent, Level level);
72
78 static AirwayRef findByIdentAndVia(const std::string& aIdent, const WayptRef& from, const WayptRef& to);
79
83 static AirwayRef findByIdentAndNavaid(const std::string& aIdent, const FGPositionedRef nav);
84
85 WayptRef findEnroute(const std::string& aIdent) const;
86
87 bool canVia(const WayptRef& from, const WayptRef& to) const;
88
89 WayptVec via(const WayptRef& from, const WayptRef& to) const;
90
91 bool containsNavaid(const FGPositionedRef& navaid) const;
92
93 WayptRef findEnroute(const FGPositionedRef& navaid) const;
94
95
101 {
102 public:
103 friend class Airway;
104 friend class InAirwayFilter;
105
106
115 bool route(WayptRef aFrom, WayptRef aTo, WayptVec& aPath);
116
120
121 std::pair<FGPositionedRef, bool> findClosestNode(const SGGeod& aGeod);
122
123 FGPositionedRef findNodeByIdent(const std::string& ident, const SGGeod& near) const;
124 private:
125 void addEdge(int aWay, const SGGeod& aStartPos,
126 const std::string& aStartIdent,
127 const SGGeod& aEndPos, const std::string& aEndIdent);
128
129 int findAirway(const std::string& aName);
130
131 bool cleanGeneratedPath(WayptRef aFrom, WayptRef aTo, WayptVec& aPath,
132 bool exactTo, bool exactFrom);
133
134 bool search2(FGPositionedRef aStart, FGPositionedRef aDest, WayptVec& aRoute);
135
139 bool inNetwork(PositionedID pos) const;
140
153 std::pair<FGPositionedRef, bool> findClosestNode(WayptRef aRef);
154
158 typedef std::map<PositionedID, bool> NetworkMembershipDict;
159 mutable NetworkMembershipDict _inNetworkCache;
160
161 Level _networkID;
162 };
163
164
165 static Network* highLevel();
166 static Network* lowLevel();
167
168private:
169 Airway(const std::string& aIdent, const Level level, int dbId, int aTop, int aBottom);
170
171 void loadWaypoints() const;
172
173 WayptVec::const_iterator find(WayptRef wpt) const;
174
175 friend class Network;
176 friend class NavDataCache;
177
178 const std::string _ident;
179 const Level _level;
180 const int _cacheId;
181
182 int _topAltitudeFt;
183 int _bottomAltitudeFt;
184
185 mutable WayptVec _elements;
186};
187
188} // of namespace flightgear
189
190
191#endif //of FG_AIRWAYS_HXX
SGSharedPtr< FGPositioned > FGPositionedRef
Definition airways.hxx:30
Track a network of airways.
Definition airways.hxx:101
std::pair< FGPositionedRef, bool > findClosestNode(const SGGeod &aGeod)
Overloaded version working with a raw SGGeod.
Definition airways.cxx:562
FGPositionedRef findNodeByIdent(const std::string &ident, const SGGeod &near) const
Definition airways.cxx:576
bool route(WayptRef aFrom, WayptRef aTo, WayptVec &aPath)
Principal routing algorithm.
Definition airways.cxx:457
static Network * lowLevel()
Definition airways.cxx:93
WayptVec via(const WayptRef &from, const WayptRef &to) const
Definition airways.cxx:229
@ HighLevel
Victor airways.
Definition airways.hxx:48
@ Both
Jet airways.
Definition airways.hxx:49
bool containsNavaid(const FGPositionedRef &navaid) const
Definition airways.cxx:266
WayptRef findEnroute(const std::string &aIdent) const
Definition airways.cxx:386
double topAltitudeFt() const
Definition airways.hxx:63
bool canVia(const WayptRef &from, const WayptRef &to) const
Definition airways.cxx:197
static void loadAWYDat(const SGPath &path)
Definition airways.cxx:130
static AirwayRef findByIdentAndNavaid(const std::string &aIdent, const FGPositionedRef nav)
Find an airway by ident, and containing a particula rnavaid/fix.
Definition airways.cxx:371
static Network * highLevel()
Definition airways.cxx:105
std::string ident() const override
Definition airways.hxx:52
double bottomAltitudeFt() const
Definition airways.hxx:66
static AirwayRef findByIdent(const std::string &aIdent, Level level)
Definition airways.cxx:294
int cacheId() const
Definition airways.hxx:55
friend class NavDataCache
Definition airways.hxx:176
static AirwayRef loadByCacheId(int cacheId)
Definition airways.cxx:327
Level level() const
Definition airways.hxx:58
static AirwayRef findByIdentAndVia(const std::string &aIdent, const WayptRef &from, const WayptRef &to)
Find the airway based on its ident.
Definition airways.cxx:356
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
SGSharedPtr< FGPositioned > FGPositionedRef
Definition airways.cxx:49
SGSharedPtr< Waypt > WayptRef
SGSharedPtr< Airway > AirwayRef
Definition airways.hxx:40
std::vector< WayptRef > WayptVec
int64_t PositionedID