FlightGear next
runwaybase.cxx
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
3 * SPDX_FileComment: represent a runway or taxiway
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#include <config.h>
8
9#include <simgear/compiler.h>
10#include <simgear/props/props.hxx>
11
12#include "runwaybase.hxx"
13
14#include <Airports/airport.hxx>
15
16using std::string;
17
18/*
19 * surface codes, defined here (as of Jan 2024) https://developer.x-plane.com/article/airport-data-apt-dat-12-00-file-format-specification/
20 * 1,20-38 - asphalt
21 * 2,50-57 - concrete
22 * 3 - turf
23 * 4 - dirt
24 * 5 - gravel
25 * 12 - lakebed
26 * 13 - water runway
27 * 14 - snow or ice
28 * 15 - Transparent
29 */
30const char * FGRunwayBase::surfaceName( int surface_code )
31{
32 switch( surface_code ) {
33 case 1:
34 case 20: // Light colored asphalt
35 case 21:
36 case 22:
37 case 23:
38 case 24: // Asphalt
39 case 25:
40 case 26:
41 case 27: // Darker colored asphalt
42 case 28:
43 case 29:
44 case 30:
45 case 31: // Very dark colored asphalt
46 case 32:
47 case 33:
48 case 34:
49 case 35: // Near black, ‘new’ looking asphalt
50 case 36:
51 case 37:
52 case 38:
53 return "asphalt";
54 case 2:
55 case 50: // Light “new” looking concrete
56 case 51:
57 case 52:
58 case 53: // Concrete
59 case 54:
60 case 55: // Dark concrete
61 case 56:
62 case 57:
63 return "concrete";
64 case 3: return "turf";
65 case 4: return "dirt";
66 case 5: return "gravel";
67 case 12: return "lakebed";
68 case 13: return "water";
69 case 14: return "ice";
70 case 15: return "transparent";
71 default: return "unknown";
72 }
73}
74
75FGRunwayBase::FGRunwayBase(PositionedID aGuid, Type aTy, const string& aIdent,
76 const SGGeod& aGeod,
77 const double heading, const double length,
78 const double width,
79 const int surface_code,
80 const PositionedID airportId) : FGPositioned(aGuid, aTy, aIdent, aGeod)
81{
82 _heading = heading;
83 _length = length;
84 _width = width;
85 _surface_code = surface_code;
86 mAirport = airportId;
87}
88
93
94SGGeod FGRunwayBase::pointOnCenterline(double aOffset) const
95{
96 SGGeod result = SGGeodesy::direct(geod(), _heading, aOffset);
97 result.setElevationM(geod().getElevationM());
98
99 return result;
100}
101
102SGGeod FGRunwayBase::pointOffCenterline(double aOffset, double lateralOffset) const
103{
104 SGGeod result = pointOnCenterline(aOffset);
105 return SGGeodesy::direct(result, SGMiscd::normalizePeriodic(0, 360,_heading+90.0), lateralOffset);
106}
107
108
110{
111 return ((_surface_code == 1 || (_surface_code >= 20 && _surface_code <= 38)) || (_surface_code == 2 || (_surface_code >= 50 && _surface_code <= 57)));
112}
113
115 const string& aIdent,
116 const SGGeod& aGeod,
117 const double heading, const double length,
118 const double width,
119 const int surface_code,
120 const PositionedID airportId) : FGRunwayBase(aGuid, TAXIWAY, aIdent, aGeod, heading, length, width, surface_code, airportId)
121{
122}
SGSharedPtr< FGAirport > FGAirportRef
FGPositioned(PositionedID aGuid, Type ty, const std::string &aIdent, const SGGeod &aPos)
virtual const SGGeod & geod() const
static SGSharedPtr< T > loadById(PositionedID id)
bool isHardSurface() const
Predicate to test if this runway has a hard surface.
PositionedID mAirport
SGGeod pointOnCenterline(double aOffset) const
Retrieve a position on the extended centerline.
FGRunwayBase(PositionedID aGuid, Type aTy, const std::string &aIdent, const SGGeod &aGeod, const double heading, const double length, const double width, const int surface_code, const PositionedID airportId)
SGGeod pointOffCenterline(double aOffset, double lateralOffset) const
int _surface_code
surface, as defined by: http://www.x-plane.org/home/robinp/Apt810.htm#RwySfcCodes
double _heading
FGAirportRef airport() const
const char * surfaceName()
FGTaxiway(PositionedID aGuid, const std::string &aIdent, const SGGeod &aGeod, const double heading, const double length, const double width, const int surface_code, const PositionedID airportId)
int64_t PositionedID