]> git.mxchange.org Git - flightgear.git/blob - src/Airports/runways.hxx
Another clean-up iteration: FGAirportList::search is gone, replaced by two
[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   
48   /** surface, as defined by:
49    * http://www.x-plane.org/home/robinp/Apt810.htm#RwySfcCodes
50    */
51   int _surface_code;
52   
53 public:
54   
55   FGRunway(FGAirport* aAirport, const std::string& rwy_no,
56             const SGGeod& aGeod,
57             const double heading, const double length,
58             const double width,
59             const double displ_thresh,
60             const double stopway,
61             const int surface_code,
62             const bool reciprocal);
63   
64   /**
65    * given a runway identifier (06, 18L, 31R) compute the identifier for the
66    * reciprocal heading runway (24, 36R, 13L) string.
67    */
68   static std::string reverseIdent(const std::string& aRunayIdent);
69     
70   /**
71    * score this runway according to the specified weights. Used by
72    * FGAirport::findBestRunwayForHeading
73    */
74   double score(double aLengthWt, double aWidthWt, double aSurfaceWt) const;
75
76   /**
77    * Test if this runway is the reciprocal. This allows users who iterate
78    * over runways to avoid counting runways twice, if desired.
79    */
80   bool isReciprocal() const
81   { return _reciprocal; }
82
83   /**
84    * Test if this is a taxiway or not
85    */
86   bool isTaxiway() const;
87   
88   /**
89    * Get the runway threshold point - this is syntatic sugar, equivalent to
90    * calling pointOnCenterline(0.0);
91    */
92   SGGeod threshold() const;
93   
94   /**
95    * Get the (possibly displaced) threshold point.
96    */
97   SGGeod displacedThreshold() const;
98   
99   /**
100    * Get the opposite threshold - this is equivalent to calling
101    * pointOnCenterline(lengthFt());
102    */
103   SGGeod reverseThreshold() const;
104   
105   /**
106    * Retrieve a position on the extended runway centerline. Positive values
107    * are in the direction of the runway heading, negative values are in the
108    * opposited direction. 0.0 corresponds to the (non-displaced) threshold
109    */
110   SGGeod pointOnCenterline(double aOffset) const;
111   
112   /**
113    * Runway length in ft
114    */
115   double lengthFt() const
116   { return _length; }
117   
118   double lengthM() const
119   { return _length * SG_FEET_TO_METER; }
120   
121   double widthFt() const
122   { return _width; }
123   
124   double widthM() const
125   { return _width * SG_FEET_TO_METER; }
126   
127   double displacedThresholdM() const
128   { return _displ_thresh * SG_FEET_TO_METER; }
129   
130   double stopwayM() const
131   { return _stopway * SG_FEET_TO_METER; }
132   
133   /**
134    * Runway heading in degrees.
135    */
136   double headingDeg() const
137   { return _heading; }
138   
139   /**
140    * Airport this runway is located at
141    */
142   FGAirport* airport() const
143   { return _airport; }
144   
145   // FIXME - should die once airport / runway creation is cleaned up
146   void setAirport(FGAirport* aAirport)
147   { _airport = aAirport; }
148   
149   /**
150    * Predicate to test if this runway has a hard surface. For the moment, this
151    * means concrete or asphalt
152    */
153   bool isHardSurface() const;
154   
155   /**
156    * Retrieve runway surface code, as define in Robin Peel's data
157    */
158   int surface() const 
159   { return _surface_code; }
160 };
161
162 #endif // _FG_RUNWAYS_HXX