FlightGear next
procedure.hxx
Go to the documentation of this file.
1
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_NAVAID_PROCEDURE_HXX
21#define FG_NAVAID_PROCEDURE_HXX
22
23#include <set>
24
25#include <simgear/math/sg_types.hxx> // for string_list
27#include <Navaids/route.hxx>
28
29namespace flightgear {
30
31// forward decls
32class NavdataVisitor;
33
34typedef std::vector<FGRunwayRef> RunwayVec;
35
47
48class Procedure : public RouteBase
49{
50public:
51 virtual ProcedureType type() const = 0;
52
53 virtual std::string ident() const
54 { return _ident; }
55
56 virtual FGAirport* airport() const = 0;
57
58 virtual RunwayVec runways() const
59 { return RunwayVec(); }
60protected:
61 Procedure(const std::string& aIdent);
62
63 std::string _ident;
64};
65
69class Transition : public Procedure
70{
71public:
72 virtual ~Transition() { ; }
73
74 bool route(WayptVec& aPath);
75
77 { return _parent; }
78
79 virtual FGAirport* airport() const;
80
84 WayptRef enroute() const;
85
89 WayptRef procedureEnd() const;
90
91
92 virtual ProcedureType type() const
93 { return _type; }
94
95 void mark(WayptFlag f);
96private:
97 friend class NavdataVisitor;
98
99 Transition(const std::string& aIdent, ProcedureType ty, Procedure* aPr);
100
101 void setPrimary(const WayptVec& aWps);
102
103 ProcedureType _type;
104 Procedure* _parent;
105 WayptVec _primary;
106};
107
108typedef SGSharedPtr<Transition> TransitionRef;
109
114class Approach : public Procedure
115{
116public:
117 virtual ~Approach();
118
120 {
121 return _runway; }
122
123 static bool isApproach(ProcedureType ty);
124
125 virtual FGAirport* airport() const;
126
127 virtual RunwayVec runways() const;
128
134 bool route(FGRunwayRef runway, WayptRef aIAF, WayptVec& aWps);
135
137
142 bool routeFromVectors(WayptVec& aWps);
143
144 const WayptVec& primary() const
145 { return _primary; }
146
147 const WayptVec& missed() const
148 { return _missed; }
149
150 virtual ProcedureType type() const
151 { return _type; }
152
153 static Approach* createTempApproach(const std::string& aIdent, FGRunway* aRunway, const WayptVec& aPath);
154
156
157 Transition* findTransitionByName(const std::string& aIdent) const;
158
159 private:
160 friend class NavdataVisitor;
161
162 Approach(const std::string& aIdent, ProcedureType ty);
163
164 void setRunway(FGRunwayRef aRwy);
165 void setPrimaryAndMissed(const WayptVec& aPrimary, const WayptVec& aMissed);
166 void addTransition(Transition* aTrans);
167
168 FGRunwayRef _runway;
169 ProcedureType _type;
170
171 typedef std::map<WayptRef, TransitionRef> WptTransitionMap;
172 WptTransitionMap _transitions;
173
174 WayptVec _primary; // unify these?
175 WayptVec _missed;
176};
177
179{
180public:
181 virtual FGAirport* airport() const
182 { return _airport; }
183
187 virtual bool isForRunway(const FGRunway* aWay) const;
188
189 virtual RunwayVec runways() const;
190
195 virtual bool route(FGRunwayRef aWay, Transition* trans, WayptVec& aPath) = 0;
196
197 const WayptVec& common() const
198 { return _common; }
199
201
207 WayptRef findBestTransition(const SGGeod& aPos) const;
208
214 Transition* findTransitionByName(const std::string& aIdent) const;
215
217
218 Transition* findTransitionByEnroute(Waypt* aEnroute) const;
219protected:
220
221 bool commonRoute(Transition* t, WayptVec& aPath, FGRunwayRef aRwy);
222
223 ArrivalDeparture(const std::string& aIdent, FGAirport* apt);
224
225 void addRunway(FGRunwayRef aRwy);
226
227 typedef std::map<FGRunwayRef, TransitionRef> RunwayTransitionMap;
229
230 virtual WayptFlag flagType() const = 0;
231
232 void setCommon(const WayptVec& aWps);
233
234private:
235 friend class NavdataVisitor;
236
237 void addTransition(Transition* aTrans);
238
239 void addRunwayTransition(FGRunwayRef aRwy, Transition* aTrans);
240
241 FGAirport* _airport;
242 WayptVec _common;
243
244 typedef std::map<WayptRef, TransitionRef> WptTransitionMap;
245 WptTransitionMap _enrouteTransitions;
246
247
248};
249
250class SID : public ArrivalDeparture
251{
252public:
253 virtual ~SID() { ; }
254
255 virtual bool route(FGRunwayRef aWay, Transition* aTrans, WayptVec& aPath);
256
257 virtual ProcedureType type() const
258 { return PROCEDURE_SID; }
259
260 static SID* createTempSID(const std::string& aIdent, FGRunway* aRunway, const WayptVec& aPath);
261protected:
262 virtual WayptFlag flagType() const
263 { return WPT_DEPARTURE; }
264
265private:
266 friend class NavdataVisitor;
267
268 SID(const std::string& aIdent, FGAirport* apt);
269};
270
271class STAR : public ArrivalDeparture
272{
273public:
274 virtual ~STAR() { ; }
275
276 virtual bool route(FGRunwayRef aWay, Transition* aTrans, WayptVec& aPath);
277
278 virtual ProcedureType type() const
279 { return PROCEDURE_STAR; }
280
281protected:
282 virtual WayptFlag flagType() const
283 { return WPT_ARRIVAL; }
284
285private:
286 friend class NavdataVisitor;
287
288 STAR(const std::string& aIdent, FGAirport* apt);
289};
290
291} // of namespace
292
293#endif
SGSharedPtr< FGRunway > FGRunwayRef
Describe an approach procedure, including the missed approach segment.
Transition * findTransitionByName(const std::string &aIdent) const
FGRunwayRef runway()
friend class NavdataVisitor
virtual FGAirport * airport() const
Definition procedure.cxx:71
static Approach * createTempApproach(const std::string &aIdent, FGRunway *aRunway, const WayptVec &aPath)
Definition procedure.cxx:58
const WayptVec & missed() const
const WayptVec & primary() const
static bool isApproach(ProcedureType ty)
bool routeFromVectors(WayptVec &aWps)
Build route as above, but ignore transitions, and assume radar vectoring to the start of main approac...
string_list transitionIdents() const
virtual RunwayVec runways() const
Definition procedure.cxx:76
virtual ProcedureType type() const
bool routeWithTransition(FGRunwayRef runway, Transition *trans, WayptVec &aWps)
bool route(FGRunwayRef runway, WayptRef aIAF, WayptVec &aWps)
Build a route from a valid IAF to the runway, including the missed segment.
virtual bool isForRunway(const FGRunway *aWay) const
Predicate, test if this procedure applies to the requested runway.
virtual bool route(FGRunwayRef aWay, Transition *trans, WayptVec &aPath)=0
Find a path between the runway and enroute structure.
virtual WayptFlag flagType() const =0
std::map< FGRunwayRef, TransitionRef > RunwayTransitionMap
ArrivalDeparture(const std::string &aIdent, FGAirport *apt)
RunwayTransitionMap _runways
virtual FGAirport * airport() const
void addRunway(FGRunwayRef aRwy)
string_list transitionIdents() const
bool commonRoute(Transition *t, WayptVec &aPath, FGRunwayRef aRwy)
void setCommon(const WayptVec &aWps)
const WayptVec & common() const
Transition * findTransitionByEnroute(FGPositioned *aEnroute) const
WayptRef findBestTransition(const SGGeod &aPos) const
Given an enroute location, find the best enroute transition point for this arrival/departure.
virtual RunwayVec runways() const
Transition * findTransitionByName(const std::string &aIdent) const
Find an enroute transition waypoint by identifier.
virtual ProcedureType type() const =0
virtual RunwayVec runways() const
Definition procedure.hxx:58
virtual std::string ident() const
Definition procedure.hxx:53
virtual FGAirport * airport() const =0
Procedure(const std::string &aIdent)
Definition procedure.cxx:44
friend class NavdataVisitor
virtual bool route(FGRunwayRef aWay, Transition *aTrans, WayptVec &aPath)
Find a path between the runway and enroute structure.
virtual ProcedureType type() const
static SID * createTempSID(const std::string &aIdent, FGRunway *aRunway, const WayptVec &aPath)
virtual WayptFlag flagType() const
friend class NavdataVisitor
virtual bool route(FGRunwayRef aWay, Transition *aTrans, WayptVec &aPath)
Find a path between the runway and enroute structure.
virtual WayptFlag flagType() const
virtual ProcedureType type() const
Encapsulate a transition segment.
Definition procedure.hxx:70
friend class NavdataVisitor
Definition procedure.hxx:97
bool route(WayptVec &aPath)
void mark(WayptFlag f)
virtual ProcedureType type() const
Definition procedure.hxx:92
WayptRef procedureEnd() const
Return the procedure end of the transition.
virtual FGAirport * airport() const
WayptRef enroute() const
Return the enroute end of the transition.
Procedure * parent() const
Definition procedure.hxx:76
Abstract base class for waypoints (and things that are treated similarly by navigation systems).
Definition route.hxx:105
std::vector< std::string > string_list
Definition globals.hxx:36
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
SGSharedPtr< Transition > TransitionRef
SGSharedPtr< Waypt > WayptRef
@ WPT_DEPARTURE
Definition route.hxx:54
@ WPT_ARRIVAL
Definition route.hxx:55
std::vector< WayptRef > WayptVec
@ PROCEDURE_INVALID
Definition procedure.hxx:37
@ PROCEDURE_TRANSITION
Definition procedure.hxx:44
@ PROCEDURE_APPROACH_NDB
Definition procedure.hxx:40
@ PROCEDURE_APPROACH_VOR
Definition procedure.hxx:39
@ PROCEDURE_RUNWAY_TRANSITION
Definition procedure.hxx:45
@ PROCEDURE_APPROACH_RNAV
Definition procedure.hxx:41
@ PROCEDURE_APPROACH_ILS
Definition procedure.hxx:38
std::vector< FGRunwayRef > RunwayVec
Definition procedure.hxx:34