2003-03-05 18:02:24 +00:00
|
|
|
// runways.cxx -- a simple class to manage airport runway info
|
2000-08-16 01:28:33 +00:00
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started August 2000.
|
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
2000-08-16 01:28:33 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2000-08-16 01:28:33 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2008-04-13 21:12:36 +00:00
|
|
|
#include <cmath> // fabs()
|
|
|
|
#include <cstdio> // sprintf()
|
|
|
|
#include <cstdlib> // atoi()
|
2000-08-16 01:28:33 +00:00
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
#include <simgear/debug/logstream.hxx>
|
2007-10-12 20:53:46 +00:00
|
|
|
#include <Main/fg_props.hxx>
|
2000-08-16 01:28:33 +00:00
|
|
|
|
2008-07-25 18:38:29 +00:00
|
|
|
#include <string>
|
2003-08-29 04:11:23 +00:00
|
|
|
#include <map>
|
2000-08-16 01:28:33 +00:00
|
|
|
|
|
|
|
#include "runways.hxx"
|
|
|
|
|
2008-07-27 16:25:13 +00:00
|
|
|
using std::istream;
|
|
|
|
using std::multimap;
|
2008-08-14 18:13:39 +00:00
|
|
|
using std::string;
|
2000-08-16 01:28:33 +00:00
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
FGRunway::FGRunway()
|
|
|
|
{
|
|
|
|
}
|
2000-08-16 01:28:33 +00:00
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
FGRunway::FGRunway( const string& id, const string& rwy_no,
|
2004-12-22 23:57:07 +00:00
|
|
|
const double longitude, const double latitude,
|
|
|
|
const double heading, const double length,
|
|
|
|
const double width,
|
|
|
|
const double displ_thresh1, const double displ_thresh2,
|
|
|
|
const double stopway1, const double stopway2,
|
2005-10-25 13:49:55 +00:00
|
|
|
const string& lighting_flags, const int surface_code,
|
|
|
|
const string& shoulder_code, const int marking_code,
|
2004-12-22 23:57:07 +00:00
|
|
|
const double smoothness, const bool dist_remaining )
|
|
|
|
{
|
2008-08-14 18:13:39 +00:00
|
|
|
_rwy_no = rwy_no;
|
|
|
|
if (rwy_no[0] == 'x') {
|
|
|
|
_type = "taxiway";
|
|
|
|
} else {
|
|
|
|
_type = "runway";
|
|
|
|
|
|
|
|
// canonicalise runway ident
|
|
|
|
if ((rwy_no.size() == 1) || !isdigit(rwy_no[1])) {
|
|
|
|
_rwy_no = "0" + rwy_no;
|
2000-08-16 01:28:33 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
if ((_rwy_no.size() > 2) && (_rwy_no[2] == 'x')) {
|
|
|
|
_rwy_no = _rwy_no.substr(0, 2);
|
2003-08-29 04:11:23 +00:00
|
|
|
}
|
2008-08-14 18:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_id = id;
|
|
|
|
_lon = longitude;
|
|
|
|
_lat = latitude;
|
|
|
|
_heading = heading;
|
|
|
|
_length = length;
|
|
|
|
_width = width;
|
|
|
|
_displ_thresh1 = displ_thresh1;
|
|
|
|
_displ_thresh2 = displ_thresh2;
|
|
|
|
_stopway1 = stopway1;
|
|
|
|
_stopway2 = stopway2;
|
|
|
|
|
|
|
|
_lighting_flags = lighting_flags;
|
|
|
|
_surface_code = surface_code;
|
|
|
|
_shoulder_code = shoulder_code;
|
|
|
|
_marking_code = marking_code;
|
|
|
|
_smoothness = smoothness;
|
|
|
|
_dist_remaining = dist_remaining;
|
2000-08-16 01:28:33 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
string FGRunway::reverseIdent(const string& aRunwayIdent)
|
|
|
|
{
|
|
|
|
// Helipads don't have a seperate number per end
|
|
|
|
if (aRunwayIdent.size() && (aRunwayIdent[0] == 'H' || aRunwayIdent[0] == 'h' || aRunwayIdent[0] == 'x')) {
|
|
|
|
return aRunwayIdent;
|
|
|
|
}
|
2000-08-16 01:28:33 +00:00
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
std::string ident(aRunwayIdent);
|
2003-03-20 09:38:06 +00:00
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
char buf[4];
|
|
|
|
int rn = atoi(ident.substr(0,2).c_str());
|
|
|
|
rn += 18;
|
|
|
|
while(rn > 36) {
|
|
|
|
rn -= 36;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(buf, "%02i", rn);
|
|
|
|
if(ident.size() == 3) {
|
|
|
|
if(ident.substr(2,1) == "L") {
|
|
|
|
buf[2] = 'R';
|
|
|
|
buf[3] = '\0';
|
|
|
|
} else if (ident.substr(2,1) == "R") {
|
|
|
|
buf[2] = 'L';
|
|
|
|
buf[3] = '\0';
|
|
|
|
} else if (ident.substr(2,1) == "C") {
|
|
|
|
buf[2] = 'C';
|
|
|
|
buf[3] = '\0';
|
|
|
|
} else if (ident.substr(2,1) == "T") {
|
|
|
|
buf[2] = 'T';
|
|
|
|
buf[3] = '\0';
|
2003-08-29 04:11:23 +00:00
|
|
|
} else {
|
2008-08-14 18:13:39 +00:00
|
|
|
SG_LOG(SG_GENERAL, SG_ALERT, "Unknown runway code "
|
|
|
|
<< aRunwayIdent << " passed to FGRunway::reverseIdent");
|
2003-08-29 04:11:23 +00:00
|
|
|
}
|
2008-08-14 18:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
2000-08-16 01:28:33 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
double FGRunway::score(double aLengthWt, double aWidthWt, double aSurfaceWt) const
|
2001-05-15 00:00:08 +00:00
|
|
|
{
|
2008-08-14 18:13:39 +00:00
|
|
|
int surface = 1;
|
|
|
|
if (_surface_code == 12 || _surface_code == 5) // dry lakebed & gravel
|
|
|
|
surface = 2;
|
|
|
|
else if (_surface_code == 1 || _surface_code == 2) // asphalt & concrete
|
|
|
|
surface = 3;
|
|
|
|
|
|
|
|
return _length * aLengthWt + _width * aWidthWt + surface * aSurfaceWt + 1e-20;
|
2000-08-16 01:28:33 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 18:13:39 +00:00
|
|
|
bool FGRunway::isTaxiway() const
|
2001-11-07 17:55:28 +00:00
|
|
|
{
|
2008-08-14 18:13:39 +00:00
|
|
|
return (_rwy_no[0] == 'x');
|
2000-08-16 01:28:33 +00:00
|
|
|
}
|