]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/waypoint.hxx
ece8cadf58b9b30cc7febc762d78a6501bda286e
[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   virtual double headingRadialDeg() const;
137 protected:      
138   virtual std::string type() const
139     { return "runway"; }
140   
141   virtual void initFromProperties(SGPropertyNode_ptr aProp);
142   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
143
144 private:
145   FGRunway* _runway;
146 };
147
148 class Hold : public BasicWaypt
149 {
150 public:
151   Hold(const SGGeod& aPos, const std::string& aIdent, Route* aOwner);
152   
153   Hold(Route* aOwner);
154   
155   void setHoldRadial(double aInboundRadial);
156   void setHoldDistance(double aDistanceNm);
157   void setHoldTime(double aTimeSec);
158   
159   void setRightHanded();
160   void setLeftHanded();
161   
162   double inboundRadial() const
163   { return _bearing; }
164   
165   bool isLeftHanded() const
166   { return !_righthanded; }
167   
168   bool isDistance() const
169   { return _isDistance; }
170   
171   double timeOrDistance() const
172   { return _holdTD;}
173   
174   virtual double headingRadialDeg() const
175   { return inboundRadial(); }
176 protected:
177   virtual void initFromProperties(SGPropertyNode_ptr aProp);
178   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
179   
180   virtual std::string type() const
181     { return "hold"; }
182     
183 private:
184   double _bearing;
185   bool _righthanded;
186   bool _isDistance;
187   double _holdTD;
188 };
189
190 class HeadingToAltitude : public Waypt
191 {
192 public:
193   HeadingToAltitude(Route* aOwner, const std::string& aIdent, double aMagHdg);
194   
195   HeadingToAltitude(Route* aOwner);
196   
197   virtual void initFromProperties(SGPropertyNode_ptr aProp);
198   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
199   
200   virtual std::string type() const
201     { return "hdgToAlt"; }
202
203   virtual SGGeod position() const
204     { return SGGeod(); }
205     
206   virtual std::string ident() const
207     { return _ident; }
208     
209   double headingDegMagnetic() const
210     { return _magHeading; }
211   
212   virtual double magvarDeg() const
213     { return 0.0; }
214   
215   virtual double headingRadialDeg() const
216   { return headingDegMagnetic(); }
217 private:
218   std::string _ident;
219   double _magHeading;
220 };
221
222 class DMEIntercept : public Waypt
223 {
224 public:
225   DMEIntercept(Route* aOwner, const std::string& aIdent, const SGGeod& aPos,
226     double aCourseDeg, double aDistanceNm);
227   
228   DMEIntercept(Route* aOwner);
229   
230   virtual void initFromProperties(SGPropertyNode_ptr aProp);
231   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
232   
233   virtual std::string type() const
234     { return "dmeIntercept"; }
235
236   virtual SGGeod position() const
237     { return _pos; }
238     
239   virtual std::string ident() const
240     { return _ident; }
241   
242   double courseDegMagnetic() const
243     { return _magCourse; }
244     
245   double dmeDistanceNm() const
246     { return _dmeDistanceNm; }
247   
248   virtual double headingRadialDeg() const
249   { return courseDegMagnetic(); }
250 private:
251   std::string _ident;
252   SGGeod _pos;
253   double _magCourse;
254   double _dmeDistanceNm;
255 };
256
257 class RadialIntercept : public Waypt
258 {
259 public:
260   RadialIntercept(Route* aOwner, const std::string& aIdent, const SGGeod& aPos,
261     double aCourseDeg, double aRadialDeg);
262   
263   RadialIntercept(Route* aOwner);
264   
265   virtual void initFromProperties(SGPropertyNode_ptr aProp);
266   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
267   
268   virtual std::string type() const
269     { return "radialIntercept"; }
270
271   virtual SGGeod position() const
272     { return _pos; }
273     
274   virtual std::string ident() const
275     { return _ident; }
276   
277   double courseDegMagnetic() const
278     { return _magCourse; }
279     
280   double radialDegMagnetic() const
281     { return _radial; }
282     
283 private:
284   std::string _ident;
285   SGGeod _pos;
286   double _magCourse;
287   double _radial;
288 };
289
290
291 /** 
292  * Represent ATC radar vectored segment. Common at the end of published
293  * missed approach procedures, and from STAR arrival points to final approach
294  */
295 class ATCVectors : public Waypt
296 {
297 public:
298   ATCVectors(Route* aOwner, FGAirport* aFacility);
299   virtual ~ATCVectors();
300   
301   ATCVectors(Route* aOwner);
302   
303   virtual void initFromProperties(SGPropertyNode_ptr aProp);
304   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
305   
306   virtual std::string type() const
307     { return "vectors"; }
308
309   virtual SGGeod position() const;
310     
311   virtual std::string ident() const;
312   
313 private:
314   /**
315    * ATC facility. Using an airport here is incorrect, since often arrivals
316    * facilities will be shared between several nearby airports, but it
317    * suffices until we have a proper facility representation
318    */
319   FGAirportRef _facility;
320 };  
321   
322 } // of namespace flighgear
323
324 #endif // of FG_WAYPOINT_HXX