]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/waypoint.hxx
PLIB net removed from FlightGear
[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 private:
210   std::string _ident;
211   double _magHeading;
212 };
213
214 class DMEIntercept : public Waypt
215 {
216 public:
217   DMEIntercept(Route* aOwner, const std::string& aIdent, const SGGeod& aPos,
218     double aCourseDeg, double aDistanceNm);
219   
220   DMEIntercept(Route* aOwner);
221   
222   virtual void initFromProperties(SGPropertyNode_ptr aProp);
223   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
224   
225   virtual std::string type() const
226     { return "dmeIntercept"; }
227
228   virtual SGGeod position() const
229     { return _pos; }
230     
231   virtual std::string ident() const
232     { return _ident; }
233   
234   double courseDegMagnetic() const
235     { return _magCourse; }
236     
237   double dmeDistanceNm() const
238     { return _dmeDistanceNm; }
239     
240 private:
241   std::string _ident;
242   SGGeod _pos;
243   double _magCourse;
244   double _dmeDistanceNm;
245 };
246
247 class RadialIntercept : public Waypt
248 {
249 public:
250   RadialIntercept(Route* aOwner, const std::string& aIdent, const SGGeod& aPos,
251     double aCourseDeg, double aRadialDeg);
252   
253   RadialIntercept(Route* aOwner);
254   
255   virtual void initFromProperties(SGPropertyNode_ptr aProp);
256   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
257   
258   virtual std::string type() const
259     { return "radialIntercept"; }
260
261   virtual SGGeod position() const
262     { return _pos; }
263     
264   virtual std::string ident() const
265     { return _ident; }
266   
267   double courseDegMagnetic() const
268     { return _magCourse; }
269     
270   double radialDegMagnetic() const
271     { return _radial; }
272     
273 private:
274   std::string _ident;
275   SGGeod _pos;
276   double _magCourse;
277   double _radial;
278 };
279
280
281 /** 
282  * Represent ATC radar vectored segment. Common at the end of published
283  * missed approach procedures, and from STAR arrival points to final approach
284  */
285 class ATCVectors : public Waypt
286 {
287 public:
288   ATCVectors(Route* aOwner, FGAirport* aFacility);
289   virtual ~ATCVectors();
290   
291   ATCVectors(Route* aOwner);
292   
293   virtual void initFromProperties(SGPropertyNode_ptr aProp);
294   virtual void writeToProperties(SGPropertyNode_ptr aProp) const;
295   
296   virtual std::string type() const
297     { return "vectors"; }
298
299   virtual SGGeod position() const;
300     
301   virtual std::string ident() const;
302   
303 private:
304   /**
305    * ATC facility. Using an airport here is incorrect, since often arrivals
306    * facilities will be shared between several nearby airports, but it
307    * suffices until we have a proper facility representation
308    */
309   FGAirportRef _facility;
310 };  
311   
312 } // of namespace flighgear
313
314 #endif // of FG_WAYPOINT_HXX