]> git.mxchange.org Git - flightgear.git/blob - src/Airports/runwaybase.cxx
Some cleanup in the ATC/AI code before merging with the next branch:
[flightgear.git] / src / Airports / runwaybase.cxx
1 // runwaybase.cxx -- a base class for runways and taxiways
2 //
3 // Written by James Turber, started December 2008.
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 #ifdef HAVE_CONFIG_H
25 #  include <config.h>
26 #endif
27
28 #include <simgear/compiler.h>
29 #include <simgear/props/props.hxx>
30
31 #include "runwaybase.hxx"
32
33 using std::string;
34
35 /*
36  * surface codes
37  * 1 - asphalt
38  * 2 - concrete
39  * 3 - turf
40  * 4 - dirt
41  * 5 - gravel
42  * 6 - asphalt helipad
43  * 7 - concrete helipad
44  * 8 - turf helipad
45  * 9 - dirt helipad
46  * 12 -  lakebed
47  */
48
49 FGRunwayBase::FGRunwayBase(Type aTy, const string& aIdent,
50                         const SGGeod& aGeod,
51                         const double heading, const double length,
52                         const double width,
53                         const int surface_code,
54                         bool index) :
55   FGPositioned(aTy, aIdent, aGeod)
56 {
57   _heading = heading;
58   _length = length;
59   _width = width;
60   _surface_code = surface_code;
61   
62   init(index);
63 }
64
65 SGGeod FGRunwayBase::pointOnCenterline(double aOffset) const
66 {
67   SGGeod result;
68   double dummyAz2;
69   double halfLengthMetres = lengthM() * 0.5;
70   
71   SGGeodesy::direct(mPosition, _heading, 
72     aOffset - halfLengthMetres,
73     result, dummyAz2);
74   return result;
75 }
76
77
78
79 SGGeod FGRunwayBase::pointOffCenterline(double aOffset, double lateralOffset) const
80 {
81   SGGeod result;
82   SGGeod temp;
83   double dummyAz2;
84   double halfLengthMetres = lengthM() * 0.5;
85
86   SGGeodesy::direct(mPosition, _heading, 
87     aOffset - halfLengthMetres,
88     temp, dummyAz2);
89
90   SGGeodesy::direct(temp, (_heading+90.0), 
91     lateralOffset,
92     result, dummyAz2);
93
94   return result;
95 }
96
97
98 bool FGRunwayBase::isHardSurface() const
99 {
100   return ((_surface_code == 1) || (_surface_code == 2));
101 }
102
103 FGTaxiway::FGTaxiway(const string& aIdent,
104                         const SGGeod& aGeod,
105                         const double heading, const double length,
106                         const double width,
107                         const int surface_code) :
108   FGRunwayBase(TAXIWAY, aIdent, aGeod, heading, length, width, surface_code, false)
109 {
110 }