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 <Navaids/route.hxx>
26 #include <Airports/runways.hxx>
28 typedef SGSharedPtr<FGRunway> FGRunwayRef;
30 namespace flightgear {
35 class Procedure : public Route
39 virtual std::string ident() const
42 Procedure(const std::string& aIdent);
48 * Encapsulate a transition segment
50 class Transition : public Route
53 bool route(Waypt* aEnroute, WayptVec& aPath);
55 Procedure* parent() const
59 * Return the enroute end of the transition
61 WayptRef enroute() const;
64 * Return the procedure end of the transition
66 WayptRef procedureEnd() const;
68 virtual std::string ident() const
71 friend class NavdataVisitor;
73 Transition(const std::string& aIdent, Procedure* aPr, const WayptVec& aWps);
81 * Describe an approach procedure, including the missed approach
84 class Approach : public Procedure
91 * Build a route from a valid IAF to the runway, including the missed
92 * segment. Return false if no valid transition from the specified IAF
95 bool route(WayptRef aIAF, WayptVec& aWps);
98 * Build route as above, but ignore transitions, and assume radar
99 * vectoring to the start of main approach
101 bool routeFromVectors(WayptVec& aWps);
103 const WayptVec& primary() const
106 const WayptVec& missed() const
110 friend class NavdataVisitor;
112 Approach(const std::string& aIdent);
114 void setRunway(FGRunwayRef aRwy);
115 void setPrimaryAndMissed(const WayptVec& aPrimary, const WayptVec& aMissed);
116 void addTransition(Transition* aTrans);
120 typedef std::map<WayptRef, Transition*> WptTransitionMap;
121 WptTransitionMap _transitions;
123 WayptVec _primary; // unify these?
127 class ArrivalDeparture : public Procedure
131 * Predicate, test if this procedure applies to the requested runway
133 virtual bool isForRunway(FGRunwayRef aWay) const;
136 * Find a path between the runway and enroute structure. Waypoints
137 * corresponding to the appropriate transitions and segments will be created.
139 virtual bool route(FGRunwayRef aWay, Waypt* aEnroute, WayptVec& aPath) = 0;
141 const WayptVec& common() const
145 * Given an enroute location, find the best enroute transition point for
146 * this arrival/departure. Best is currently determined as 'closest to the
149 WayptRef findBestTransition(const SGGeod& aPos) const;
152 * Find an enroute transition waypoint by identifier. This is necessary
153 * for the route-manager and similar code that that needs to talk about
154 * transitions in a human-meaningful way (including persistence).
156 WayptRef findTransitionByName(const std::string& aIdent) const;
158 Transition* findTransitionByEnroute(Waypt* aEnroute) const;
161 bool commonRoute(Waypt* aEnroute, WayptVec& aPath, FGRunwayRef aRwy);
163 ArrivalDeparture(const std::string& aIdent);
166 void addRunway(FGRunwayRef aRwy);
168 typedef std::map<FGRunwayRef, Transition*> RunwayTransitionMap;
169 RunwayTransitionMap _runways;
172 friend class NavdataVisitor;
174 void addTransition(Transition* aTrans);
176 void setCommon(const WayptVec& aWps);
178 void addRunwayTransition(FGRunwayRef aRwy, Transition* aTrans);
182 typedef std::map<WayptRef, Transition*> WptTransitionMap;
183 WptTransitionMap _enrouteTransitions;
188 class SID : public ArrivalDeparture
191 virtual bool route(FGRunwayRef aWay, Waypt* aEnroute, WayptVec& aPath);
194 friend class NavdataVisitor;
196 SID(const std::string& aIdent);
199 class STAR : public ArrivalDeparture
202 virtual bool route(FGRunwayRef aWay, Waypt* aEnroute, WayptVec& aPath);
205 friend class NavdataVisitor;
207 STAR(const std::string& aIdent);