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