]> git.mxchange.org Git - flightgear.git/blob - src/Airports/runways.hxx
7bb21b6b4532d688c2817a1ee07232e1fec5f6ea
[flightgear.git] / src / Airports / runways.hxx
1 // runways.hxx -- a simple class to manage airport runway info
2 //
3 // Written by Curtis Olson, started August 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson  - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _FG_RUNWAYS_HXX
25 #define _FG_RUNWAYS_HXX
26
27 #include <simgear/compiler.h>
28
29 #include <simgear/math/sg_geodesy.hxx>
30
31 #include "Navaids/positioned.hxx"
32
33 #include <string>
34
35 // forward decls
36 class FGAirport;
37
38 class FGRunway : public FGPositioned
39 {  
40   FGAirport* _airport; ///< owning airport
41   bool _reciprocal;
42   double _heading;
43   double _length;
44   double _width;
45   double _displ_thresh;
46   double _stopway;
47   int _surface_code;
48   
49 public:
50   
51   FGRunway(FGAirport* aAirport, const std::string& rwy_no,
52             const SGGeod& aGeod,
53             const double heading, const double length,
54             const double width,
55             const double displ_thresh,
56             const double stopway,
57             const int surface_code,
58             const bool reciprocal);
59   
60   /**
61    * given a runway identifier (06, 18L, 31R) compute the identifier for the
62    * reciprocal heading runway (24, 36R, 13L) string.
63    */
64   static std::string reverseIdent(const std::string& aRunayIdent);
65     
66   /**
67    * score this runway according to the specified weights. Used by
68    * FGAirport::findBestRunwayForHeading
69    */
70   double score(double aLengthWt, double aWidthWt, double aSurfaceWt) const;
71
72   /**
73    * Test if this runway is the reciprocal. This allows users who iterate
74    * over runways to avoid counting runways twice, if desired.
75    */
76   bool isReciprocal() const
77   { return _reciprocal; }
78
79   /**
80    * Test if this is a taxiway or not
81    */
82   bool isTaxiway() const;
83   
84   /**
85    * Get the runway threshold point - this is syntatic sugar, equivalent to
86    * calling pointOnCenterline(0.0);
87    */
88   SGGeod threshold() const;
89   
90   /**
91    * Get the (possibly displaced) threshold point.
92    */
93   SGGeod displacedThreshold() const;
94   
95   /**
96    * Get the opposite threshold - this is equivalent to calling
97    * pointOnCenterline(lengthFt());
98    */
99   SGGeod reverseThreshold() const;
100   
101   /**
102    * Retrieve a position on the extended runway centerline. Positive values
103    * are in the direction of the runway heading, negative values are in the
104    * opposited direction. 0.0 corresponds to the (non-displaced) threshold
105    */
106   SGGeod pointOnCenterline(double aOffset) const;
107   
108   /**
109    * Runway length in ft
110    */
111   double lengthFt() const
112   { return _length; }
113   
114   double lengthM() const
115   { return _length * SG_FEET_TO_METER; }
116   
117   double widthFt() const
118   { return _width; }
119   
120   double widthM() const
121   { return _width * SG_FEET_TO_METER; }
122   
123   double displacedThresholdM() const
124   { return _displ_thresh * SG_FEET_TO_METER; }
125   
126   double stopwayM() const
127   { return _stopway * SG_FEET_TO_METER; }
128   
129   /**
130    * Runway heading in degrees.
131    */
132   double headingDeg() const
133   { return _heading; }
134   
135   /**
136    * Airport this runway is located at
137    */
138   FGAirport* airport() const
139   { return _airport; }
140   
141   // FIXME - should die once airport / runway creation is cleaned up
142   void setAirport(FGAirport* aAirport)
143   { _airport = aAirport; }
144   
145   /**
146    * Predicate to test if this runway has a hard surface. For the moment, this
147    * means concrete or asphalt
148    */
149   bool isHardSurface() const;
150   
151   /**
152    * Retrieve runway surface code, as define in Robin Peel's data
153    */
154   int surface() const 
155   { return _surface_code; }
156 };
157
158 #endif // _FG_RUNWAYS_HXX