]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/waypoint.hxx
Launcher GUI for in-air / navaid starts
[flightgear.git] / src / Navaids / waypoint.hxx
1 // waypoint.hxx - waypoints that can occur in routes/procedures
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_WAYPOINT_HXX
21 #define FG_WAYPOINT_HXX
22
23 #include <Airports/airports_fwd.hxx>
24 #include <Navaids/route.hxx>
25 #include <Navaids/positioned.hxx>
26
27 namespace flightgear
28 {
29
30 class BasicWaypt : public Waypt
31 {
32 public:
33   
34   BasicWaypt(const SGGeod& aPos, const std::string& aIdent, RouteBase* aOwner);
35     
36   BasicWaypt(RouteBase* aOwner);
37   
38   virtual SGGeod position() const
39     { return _pos; }
40   
41   virtual std::string ident() const
42     { return _ident; }
43
44 protected:
45   virtual void initFromProperties(SGPropertyNode_ptr aProp);
46   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
47
48   virtual std::string type() const
49     { return "basic"; } 
50
51   SGGeod _pos;
52   std::string _ident;
53   
54 };
55
56 /**
57  * Waypoint based upon a navaid. In practice this means any Positioned
58  * element, excluding runways (see below)
59  */
60 class NavaidWaypoint : public Waypt
61 {
62 public:
63   NavaidWaypoint(FGPositioned* aPos, RouteBase* aOwner);
64   
65   NavaidWaypoint(RouteBase* aOwner);
66   
67   virtual SGGeod position() const;
68   
69   virtual FGPositioned* source() const
70     { return _navaid; }
71     
72   virtual std::string ident() const;
73 protected:      
74   virtual void initFromProperties(SGPropertyNode_ptr aProp);
75   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
76
77   virtual std::string type() const
78     { return "navaid"; }
79     
80   FGPositionedRef _navaid;
81 };
82
83 class OffsetNavaidWaypoint : public NavaidWaypoint
84 {
85 public: 
86   OffsetNavaidWaypoint(FGPositioned* aPos, RouteBase* aOwner, double aRadial, double aDistNm);
87
88   OffsetNavaidWaypoint(RouteBase* aOwner);
89   
90   virtual SGGeod position() const
91     { return _geod; }
92
93 protected:
94   virtual void initFromProperties(SGPropertyNode_ptr aProp);
95   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
96   
97   virtual std::string type() const
98     { return "offset-navaid"; }
99     
100 private:
101   void init();
102   
103   SGGeod _geod;
104   double _radial; // true, degrees
105   double _distanceNm;
106 };
107
108 /**
109  * Waypoint based upon a runway. 
110  * Runways are handled specially in various places, so it's cleaner
111  * to be able to distuinguish them from other navaid waypoints
112  */
113 class RunwayWaypt : public Waypt
114 {
115 public:
116   RunwayWaypt(FGRunway* aPos, RouteBase* aOwner);
117   
118   RunwayWaypt(RouteBase* aOwner);
119   
120   virtual SGGeod position() const;
121   
122   virtual FGPositioned* source() const;
123     
124   virtual std::string ident() const;
125
126   FGRunway* runway() const
127     { return _runway; }
128
129   virtual double headingRadialDeg() const;
130 protected:      
131   virtual std::string type() const
132     { return "runway"; }
133   
134   virtual void initFromProperties(SGPropertyNode_ptr aProp);
135   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
136
137 private:
138   FGRunway* _runway;
139 };
140
141 class Hold : public BasicWaypt
142 {
143 public:
144   Hold(const SGGeod& aPos, const std::string& aIdent, RouteBase* aOwner);
145   
146   Hold(RouteBase* aOwner);
147   
148   void setHoldRadial(double aInboundRadial);
149   void setHoldDistance(double aDistanceNm);
150   void setHoldTime(double aTimeSec);
151   
152   void setRightHanded();
153   void setLeftHanded();
154   
155   double inboundRadial() const
156   { return _bearing; }
157   
158   bool isLeftHanded() const
159   { return !_righthanded; }
160   
161   bool isDistance() const
162   { return _isDistance; }
163   
164   double timeOrDistance() const
165   { return _holdTD;}
166   
167   virtual double headingRadialDeg() const
168   { return inboundRadial(); }
169 protected:
170   virtual void initFromProperties(SGPropertyNode_ptr aProp);
171   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
172   
173   virtual std::string type() const
174     { return "hold"; }
175     
176 private:
177   double _bearing;
178   bool _righthanded;
179   bool _isDistance;
180   double _holdTD;
181 };
182
183 class HeadingToAltitude : public Waypt
184 {
185 public:
186   HeadingToAltitude(RouteBase* aOwner, const std::string& aIdent, double aMagHdg);
187   
188   HeadingToAltitude(RouteBase* aOwner);
189   
190   virtual void initFromProperties(SGPropertyNode_ptr aProp);
191   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
192   
193   virtual std::string type() const
194     { return "hdgToAlt"; }
195
196   virtual SGGeod position() const
197     { return SGGeod(); }
198     
199   virtual std::string ident() const
200     { return _ident; }
201     
202   double headingDegMagnetic() const
203     { return _magHeading; }
204   
205   virtual double magvarDeg() const
206     { return 0.0; }
207   
208   virtual double headingRadialDeg() const
209   { return headingDegMagnetic(); }
210 private:
211   std::string _ident;
212   double _magHeading;
213 };
214
215 class DMEIntercept : public Waypt
216 {
217 public:
218   DMEIntercept(RouteBase* aOwner, const std::string& aIdent, const SGGeod& aPos,
219     double aCourseDeg, double aDistanceNm);
220   
221   DMEIntercept(RouteBase* aOwner);
222   
223   virtual void initFromProperties(SGPropertyNode_ptr aProp);
224   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
225   
226   virtual std::string type() const
227     { return "dmeIntercept"; }
228
229   virtual SGGeod position() const
230     { return _pos; }
231     
232   virtual std::string ident() const
233     { return _ident; }
234   
235   double courseDegMagnetic() const
236     { return _magCourse; }
237     
238   double dmeDistanceNm() const
239     { return _dmeDistanceNm; }
240   
241   virtual double headingRadialDeg() const
242   { return courseDegMagnetic(); }
243 private:
244   std::string _ident;
245   SGGeod _pos;
246   double _magCourse;
247   double _dmeDistanceNm;
248 };
249
250 class RadialIntercept : public Waypt
251 {
252 public:
253   RadialIntercept(RouteBase* aOwner, const std::string& aIdent, const SGGeod& aPos,
254     double aCourseDeg, double aRadialDeg);
255   
256   RadialIntercept(RouteBase* aOwner);
257   
258   virtual void initFromProperties(SGPropertyNode_ptr aProp);
259   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
260   
261   virtual std::string type() const
262     { return "radialIntercept"; }
263
264   virtual SGGeod position() const
265     { return _pos; }
266     
267   virtual std::string ident() const
268     { return _ident; }
269   
270   double courseDegMagnetic() const
271     { return _magCourse; }
272     
273   double radialDegMagnetic() const
274     { return _radial; }
275
276   virtual double headingRadialDeg() const
277   { return courseDegMagnetic(); }
278 private:
279   std::string _ident;
280   SGGeod _pos;
281   double _magCourse;
282   double _radial;
283 };
284
285
286 /** 
287  * Represent ATC radar vectored segment. Common at the end of published
288  * missed approach procedures, and from STAR arrival points to final approach
289  */
290 class ATCVectors : public Waypt
291 {
292 public:
293   ATCVectors(RouteBase* aOwner, FGAirport* aFacility);
294   virtual ~ATCVectors();
295   
296   ATCVectors(RouteBase* aOwner);
297   
298   virtual void initFromProperties(SGPropertyNode_ptr aProp);
299   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
300   
301   virtual std::string type() const
302     { return "vectors"; }
303
304   virtual SGGeod position() const;
305     
306   virtual std::string ident() const;
307   
308 private:
309   /**
310    * ATC facility. Using an airport here is incorrect, since often arrivals
311    * facilities will be shared between several nearby airports, but it
312    * suffices until we have a proper facility representation
313    */
314   FGAirportRef _facility;
315 };  
316   
317 } // of namespace flighgear
318
319 #endif // of FG_WAYPOINT_HXX