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