]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/procedure.hxx
#346 related: missing status message for property server
[flightgear.git] / src / Navaids / procedure.hxx
1 /// procedure.hxx - define route storing an approach, arrival or departure procedure
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 <Navaids/route.hxx>
26 #include <Airports/runways.hxx>
27
28 typedef SGSharedPtr<FGRunway> FGRunwayRef;
29
30 namespace flightgear {
31
32 // forward decls
33 class NavdataVisitor;
34
35 class Procedure : public Route
36 {
37 public:
38
39   virtual std::string ident() const
40   { return _ident; }
41 protected:
42   Procedure(const std::string& aIdent);
43   
44   std::string _ident;
45 };
46
47 /**
48  * Encapsulate a transition segment
49  */
50 class Transition : public Route
51 {
52 public:
53   bool route(Waypt* aEnroute, WayptVec& aPath);
54   
55   Procedure* parent() const
56   { return _parent; }
57   
58   /**
59    * Return the enroute end of the transition
60    */
61   WayptRef enroute() const;
62   
63   /**
64    * Return the procedure end of the transition
65    */
66   WayptRef procedureEnd() const;
67   
68   virtual std::string ident() const
69   { return _ident; }
70 private:
71   friend class NavdataVisitor;
72
73   Transition(const std::string& aIdent, Procedure* aPr, const WayptVec& aWps);
74
75   std::string _ident;
76   Procedure* _parent;
77   WayptVec _primary;
78 };
79
80 /**
81  * Describe an approach procedure, including the missed approach
82  * segment
83  */
84 class Approach : public Procedure
85 {
86 public:
87   FGRunwayRef runway() 
88   { return _runway; }
89
90   /**
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
93    * could be found
94    */
95   bool route(WayptRef aIAF, WayptVec& aWps);
96
97   /**
98    * Build route as above, but ignore transitions, and assume radar
99    * vectoring to the start of main approach
100    */
101   bool routeFromVectors(WayptVec& aWps);
102   
103   const WayptVec& primary() const
104     { return _primary; }
105     
106   const WayptVec& missed() const
107     { return _missed; }
108
109 private:
110   friend class NavdataVisitor;
111   
112   Approach(const std::string& aIdent);
113   
114   void setRunway(FGRunwayRef aRwy);
115   void setPrimaryAndMissed(const WayptVec& aPrimary, const WayptVec& aMissed);
116   void addTransition(Transition* aTrans);
117   
118   FGRunwayRef _runway;
119   
120   typedef std::map<WayptRef, Transition*> WptTransitionMap;
121   WptTransitionMap _transitions;
122   
123   WayptVec _primary; // unify these?
124   WayptVec _missed;
125 };
126
127 class ArrivalDeparture : public Procedure
128 {
129 public:
130   /**
131    * Predicate, test if this procedure applies to the requested runway
132    */
133   virtual bool isForRunway(FGRunwayRef aWay) const;
134
135   /**
136    * Find a path between the runway and enroute structure. Waypoints 
137    * corresponding to the appropriate transitions and segments will be created.
138    */
139   virtual bool route(FGRunwayRef aWay, Waypt* aEnroute, WayptVec& aPath) = 0;
140
141   const WayptVec& common() const
142     { return _common; }
143
144   /**
145    * Given an enroute location, find the best enroute transition point for 
146    * this arrival/departure. Best is currently determined as 'closest to the
147    * enroute location'.
148    */
149   WayptRef findBestTransition(const SGGeod& aPos) const;
150   
151   /**
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).
155    */
156   WayptRef findTransitionByName(const std::string& aIdent) const;
157   
158   Transition* findTransitionByEnroute(Waypt* aEnroute) const;
159 protected:
160     
161   bool commonRoute(Waypt* aEnroute, WayptVec& aPath, FGRunwayRef aRwy);
162   
163   ArrivalDeparture(const std::string& aIdent);
164   
165   
166   void addRunway(FGRunwayRef aRwy);
167
168   typedef std::map<FGRunwayRef, Transition*> RunwayTransitionMap;
169   RunwayTransitionMap _runways;
170   
171 private:
172   friend class NavdataVisitor;
173   
174   void addTransition(Transition* aTrans);
175   
176   void setCommon(const WayptVec& aWps);
177
178   void addRunwayTransition(FGRunwayRef aRwy, Transition* aTrans);
179   
180   WayptVec _common;
181   
182   typedef std::map<WayptRef, Transition*> WptTransitionMap;
183   WptTransitionMap _enrouteTransitions;
184   
185   
186 };
187
188 class SID : public ArrivalDeparture
189 {
190 public:  
191   virtual bool route(FGRunwayRef aWay, Waypt* aEnroute, WayptVec& aPath);
192   
193 private:
194   friend class NavdataVisitor;
195     
196   SID(const std::string& aIdent);
197 };
198
199 class STAR : public ArrivalDeparture
200 {
201 public:  
202   virtual bool route(FGRunwayRef aWay, Waypt* aEnroute, WayptVec& aPath);
203   
204 private:
205   friend class NavdataVisitor;
206   
207   STAR(const std::string& aIdent);
208 };
209
210 } // of namespace
211
212 #endif