1 // runwaybase.cxx -- a base class for runways and taxiways
2 //
3 // Written by James Turner, 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 */
surfaceName(int surface_code)48 const char * FGRunwayBase::surfaceName( int surface_code )
49 {
50 switch( surface_code ) {
51 case 1: return "asphalt";
52 case 2: return "concrete";
53 case 3: return "turf";
54 case 4: return "dirt";
55 case 5: return "gravel";
56 case 6: return "asphalt helipad";
57 case 7: return "concrete helipad";
58 case 8: return "turf helipad";
59 case 9: return "dirt helipad";
60 case 12: return "lakebed";
61 default: return "unknown";
62 }
63 }
64
FGRunwayBase(PositionedID aGuid,Type aTy,const string & aIdent,const SGGeod & aGeod,const double heading,const double length,const double width,const int surface_code)65 FGRunwayBase::FGRunwayBase(PositionedID aGuid, Type aTy, const string& aIdent,
66 const SGGeod& aGeod,
67 const double heading, const double length,
68 const double width,
69 const int surface_code) :
70 FGPositioned(aGuid, aTy, aIdent, aGeod)
71 {
72 _heading = heading;
73 _length = length;
74 _width = width;
75 _surface_code = surface_code;
76 }
77
pointOnCenterline(double aOffset) const78 SGGeod FGRunwayBase::pointOnCenterline(double aOffset) const
79 {
80 SGGeod result = SGGeodesy::direct(geod(), _heading, aOffset);
81 result.setElevationM(geod().getElevationM());
82
83 return result;
84 }
85
pointOffCenterline(double aOffset,double lateralOffset) const86 SGGeod FGRunwayBase::pointOffCenterline(double aOffset, double lateralOffset) const
87 {
88 SGGeod result = pointOnCenterline(aOffset);
89 return SGGeodesy::direct(result, SGMiscd::normalizePeriodic(0, 360,_heading+90.0), lateralOffset);
90 }
91
92
isHardSurface() const93 bool FGRunwayBase::isHardSurface() const
94 {
95 return ((_surface_code == 1) || (_surface_code == 2));
96 }
97
FGTaxiway(PositionedID aGuid,const string & aIdent,const SGGeod & aGeod,const double heading,const double length,const double width,const int surface_code)98 FGTaxiway::FGTaxiway(PositionedID aGuid,
99 const string& aIdent,
100 const SGGeod& aGeod,
101 const double heading, const double length,
102 const double width,
103 const int surface_code) :
104 FGRunwayBase(aGuid, TAXIWAY, aIdent, aGeod, heading, length, width, surface_code)
105 {
106 }
107