1 /// procedure.hxx - define route storing an approach, arrival or departure procedure
2 // Written by James Turner, started 2009.
4 // Copyright (C) 2009 Curtis L. Olson
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.
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.
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.
20 #ifndef FG_NAVAID_PROCEDURE_HXX
21 #define FG_NAVAID_PROCEDURE_HXX
25 #include <simgear/math/sg_types.hxx> // for string_list
26 #include <Airports/airports_fwd.hxx>
27 #include <Navaids/route.hxx>
29 typedef SGSharedPtr<FGRunway> FGRunwayRef;
31 namespace flightgear {
36 typedef std::vector<FGRunwayRef> RunwayVec;
40 PROCEDURE_APPROACH_ILS,
41 PROCEDURE_APPROACH_VOR,
42 PROCEDURE_APPROACH_NDB,
43 PROCEDURE_APPROACH_RNAV,
47 PROCEDURE_RUNWAY_TRANSITION
50 class Procedure : public RouteBase
53 virtual ProcedureType type() const = 0;
55 virtual std::string ident() const
58 virtual FGAirport* airport() const = 0;
60 virtual RunwayVec runways() const
61 { return RunwayVec(); }
63 Procedure(const std::string& aIdent);
69 * Encapsulate a transition segment
71 class Transition : public Procedure
74 virtual ~Transition() { ; }
76 bool route(WayptVec& aPath);
78 Procedure* parent() const
81 virtual FGAirport* airport() const;
84 * Return the enroute end of the transition
86 WayptRef enroute() const;
89 * Return the procedure end of the transition
91 WayptRef procedureEnd() const;
94 virtual ProcedureType type() const
97 void mark(WayptFlag f);
99 friend class NavdataVisitor;
101 Transition(const std::string& aIdent, ProcedureType ty, Procedure* aPr);
103 void setPrimary(const WayptVec& aWps);
110 typedef SGSharedPtr<Transition> TransitionRef;
113 * Describe an approach procedure, including the missed approach
116 class Approach : public Procedure
119 virtual ~Approach() { ; }
124 static bool isApproach(ProcedureType ty);
126 virtual FGAirport* airport() const;
128 virtual RunwayVec runways() const;
131 * Build a route from a valid IAF to the runway, including the missed
132 * segment. Return false if no valid transition from the specified IAF
135 bool route(WayptRef aIAF, WayptVec& aWps);
138 * Build route as above, but ignore transitions, and assume radar
139 * vectoring to the start of main approach
141 bool routeFromVectors(WayptVec& aWps);
143 const WayptVec& primary() const
146 const WayptVec& missed() const
149 virtual ProcedureType type() const
152 static Approach* createTempApproach(const std::string& aIdent, FGRunway* aRunway, const WayptVec& aPath);
154 friend class NavdataVisitor;
156 Approach(const std::string& aIdent, ProcedureType ty);
158 void setRunway(FGRunwayRef aRwy);
159 void setPrimaryAndMissed(const WayptVec& aPrimary, const WayptVec& aMissed);
160 void addTransition(Transition* aTrans);
165 typedef std::map<WayptRef, TransitionRef> WptTransitionMap;
166 WptTransitionMap _transitions;
168 WayptVec _primary; // unify these?
172 class ArrivalDeparture : public Procedure
175 virtual FGAirport* airport() const
179 * Predicate, test if this procedure applies to the requested runway
181 virtual bool isForRunway(const FGRunway* aWay) const;
183 virtual RunwayVec runways() const;
186 * Find a path between the runway and enroute structure. Waypoints
187 * corresponding to the appropriate transitions and segments will be created.
189 virtual bool route(FGRunwayRef aWay, Transition* trans, WayptVec& aPath) = 0;
191 const WayptVec& common() const
194 string_list transitionIdents() const;
197 * Given an enroute location, find the best enroute transition point for
198 * this arrival/departure. Best is currently determined as 'closest to the
201 WayptRef findBestTransition(const SGGeod& aPos) const;
204 * Find an enroute transition waypoint by identifier. This is necessary
205 * for the route-manager and similar code that that needs to talk about
206 * transitions in a human-meaningful way (including persistence).
208 Transition* findTransitionByName(const std::string& aIdent) const;
210 Transition* findTransitionByEnroute(Waypt* aEnroute) const;
213 bool commonRoute(Transition* t, WayptVec& aPath, FGRunwayRef aRwy);
215 ArrivalDeparture(const std::string& aIdent, FGAirport* apt);
217 void addRunway(FGRunwayRef aRwy);
219 typedef std::map<FGRunwayRef, TransitionRef> RunwayTransitionMap;
220 RunwayTransitionMap _runways;
222 virtual WayptFlag flagType() const = 0;
224 void setCommon(const WayptVec& aWps);
227 friend class NavdataVisitor;
229 void addTransition(Transition* aTrans);
231 void addRunwayTransition(FGRunwayRef aRwy, Transition* aTrans);
236 typedef std::map<WayptRef, TransitionRef> WptTransitionMap;
237 WptTransitionMap _enrouteTransitions;
242 class SID : public ArrivalDeparture
247 virtual bool route(FGRunwayRef aWay, Transition* aTrans, WayptVec& aPath);
249 virtual ProcedureType type() const
250 { return PROCEDURE_SID; }
252 static SID* createTempSID(const std::string& aIdent, FGRunway* aRunway, const WayptVec& aPath);
254 virtual WayptFlag flagType() const
255 { return WPT_DEPARTURE; }
258 friend class NavdataVisitor;
260 SID(const std::string& aIdent, FGAirport* apt);
263 class STAR : public ArrivalDeparture
266 virtual ~STAR() { ; }
268 virtual bool route(FGRunwayRef aWay, Transition* aTrans, WayptVec& aPath);
270 virtual ProcedureType type() const
271 { return PROCEDURE_STAR; }
274 virtual WayptFlag flagType() const
275 { return WPT_ARRIVAL; }
278 friend class NavdataVisitor;
280 STAR(const std::string& aIdent, FGAirport* apt);