- rename dynamics to _dynamics for consistency reasons
- preserve information from apt.dat about whether an airport is a "normal" airport, a seaport, or a heliport. Do it without wasting another byte in the FGAirport structure (saves 50kB of memory). Yes, I know bitfields. :-)
This commit is contained in:
parent
2cef9cc16a
commit
f8b8077801
3 changed files with 62 additions and 48 deletions
|
@ -46,31 +46,31 @@
|
||||||
|
|
||||||
static void addAirport(FGAirportList *airports, const string& apt_id, const string& apt_name,
|
static void addAirport(FGAirportList *airports, const string& apt_id, const string& apt_name,
|
||||||
int rwy_count, double rwy_lat_accum, double rwy_lon_accum, double last_rwy_heading,
|
int rwy_count, double rwy_lat_accum, double rwy_lon_accum, double last_rwy_heading,
|
||||||
double apt_elev, SGGeod& tower, bool got_tower)
|
double apt_elev, SGGeod& tower, bool got_tower, int type)
|
||||||
{
|
{
|
||||||
if (!apt_id.empty()) {
|
if (apt_id.empty())
|
||||||
if (rwy_count > 0) {
|
return;
|
||||||
double lat = rwy_lat_accum / (double)rwy_count;
|
|
||||||
double lon = rwy_lon_accum / (double)rwy_count;
|
|
||||||
|
|
||||||
if (!got_tower) {
|
if (!rwy_count) {
|
||||||
// tower height hard coded for now...
|
SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: No runways for " << apt_id
|
||||||
const float tower_height = 50.0f;
|
<< ", skipping." );
|
||||||
// make a little off the heading for 1 runway airports...
|
return;
|
||||||
float fudge_lon = fabs(sin(last_rwy_heading * SGD_DEGREES_TO_RADIANS)) * .003f;
|
|
||||||
float fudge_lat = .003f - fudge_lon;
|
|
||||||
|
|
||||||
tower = SGGeod::fromDegFt(lon + fudge_lon, lat + fudge_lat, apt_elev + tower_height);
|
|
||||||
}
|
|
||||||
|
|
||||||
airports->add(apt_id, SGGeod::fromDegFt(lon, lat, apt_elev), tower, apt_name, false);
|
|
||||||
} else {
|
|
||||||
if ( apt_id.length() ) {
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: No runways for " << apt_id
|
|
||||||
<< ", skipping." );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double lat = rwy_lat_accum / (double)rwy_count;
|
||||||
|
double lon = rwy_lon_accum / (double)rwy_count;
|
||||||
|
|
||||||
|
if (!got_tower) {
|
||||||
|
// tower height hard coded for now...
|
||||||
|
const float tower_height = 50.0f;
|
||||||
|
// make a little off the heading for 1 runway airports...
|
||||||
|
float fudge_lon = fabs(sin(last_rwy_heading * SGD_DEGREES_TO_RADIANS)) * .003f;
|
||||||
|
float fudge_lat = .003f - fudge_lon;
|
||||||
|
tower = SGGeod::fromDegFt(lon + fudge_lon, lat + fudge_lat, apt_elev + tower_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
airports->add(apt_id, SGGeod::fromDegFt(lon, lat, apt_elev), tower, apt_name, false,
|
||||||
|
type == 1/*airport*/, type == 16/*seaport*/, type == 17/*heliport*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the airport data base from the specified aptdb file. The
|
// Load the airport data base from the specified aptdb file. The
|
||||||
|
@ -151,7 +151,7 @@ bool fgAirportDBLoad( FGAirportList *airports, FGRunwayList *runways,
|
||||||
<< elev );
|
<< elev );
|
||||||
|
|
||||||
addAirport(airports, last_apt_id, last_apt_name, rwy_count, rwy_lat_accum, rwy_lon_accum,
|
addAirport(airports, last_apt_id, last_apt_name, rwy_count, rwy_lat_accum, rwy_lon_accum,
|
||||||
last_rwy_heading, last_apt_elev, last_tower, got_tower);
|
last_rwy_heading, last_apt_elev, last_tower, got_tower, line_id);
|
||||||
|
|
||||||
last_apt_id = id;
|
last_apt_id = id;
|
||||||
last_apt_elev = elev;
|
last_apt_elev = elev;
|
||||||
|
@ -244,7 +244,7 @@ bool fgAirportDBLoad( FGAirportList *airports, FGRunwayList *runways,
|
||||||
|
|
||||||
// add the last airport being processed if any
|
// add the last airport being processed if any
|
||||||
addAirport(airports, last_apt_id, last_apt_name, rwy_count, rwy_lat_accum, rwy_lon_accum,
|
addAirport(airports, last_apt_id, last_apt_name, rwy_count, rwy_lat_accum, rwy_lon_accum,
|
||||||
last_rwy_heading, last_apt_elev, last_tower, got_tower);
|
last_rwy_heading, last_apt_elev, last_tower, got_tower, 0);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -61,42 +61,46 @@ SG_USING_STD(random_shuffle);
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* FGAirport
|
* FGAirport
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
FGAirport::FGAirport()
|
FGAirport::FGAirport() : _dynamics(0)
|
||||||
{
|
{
|
||||||
dynamics = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FGAirport::FGAirport(const string &id, const SGGeod& location, const SGGeod& tower_location, const string &name, bool has_metar)
|
FGAirport::FGAirport(const string &id, const SGGeod& location, const SGGeod& tower_location,
|
||||||
|
const string &name, bool has_metar, bool is_airport, bool is_seaport,
|
||||||
|
bool is_heliport) :
|
||||||
|
_id(id),
|
||||||
|
_location(location),
|
||||||
|
_tower_location(tower_location),
|
||||||
|
_name(name),
|
||||||
|
_has_metar(has_metar),
|
||||||
|
_is_airport(is_airport),
|
||||||
|
_is_seaport(is_seaport),
|
||||||
|
_is_heliport(is_heliport),
|
||||||
|
_dynamics(0)
|
||||||
{
|
{
|
||||||
_id = id;
|
|
||||||
_location = location;
|
|
||||||
_tower_location = tower_location;
|
|
||||||
_name = name;
|
|
||||||
_has_metar = has_metar;
|
|
||||||
dynamics = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FGAirport::~FGAirport()
|
FGAirport::~FGAirport()
|
||||||
{
|
{
|
||||||
delete dynamics;
|
delete _dynamics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FGAirportDynamics * FGAirport::getDynamics()
|
FGAirportDynamics * FGAirport::getDynamics()
|
||||||
{
|
{
|
||||||
if (dynamics != 0) {
|
if (_dynamics != 0) {
|
||||||
return dynamics;
|
return _dynamics;
|
||||||
} else {
|
} else {
|
||||||
//cerr << "Trying to load dynamics for " << _id << endl;
|
//cerr << "Trying to load dynamics for " << _id << endl;
|
||||||
dynamics = new FGAirportDynamics(this);
|
_dynamics = new FGAirportDynamics(this);
|
||||||
XMLLoader::load(dynamics);
|
XMLLoader::load(_dynamics);
|
||||||
|
|
||||||
FGRunwayPreference rwyPrefs(this);
|
FGRunwayPreference rwyPrefs(this);
|
||||||
XMLLoader::load(&rwyPrefs);
|
XMLLoader::load(&rwyPrefs);
|
||||||
dynamics->setRwyUse(rwyPrefs);
|
_dynamics->setRwyUse(rwyPrefs);
|
||||||
}
|
}
|
||||||
return dynamics;
|
return _dynamics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,9 +146,11 @@ FGAirportList::~FGAirportList( void )
|
||||||
|
|
||||||
// add an entry to the list
|
// add an entry to the list
|
||||||
void FGAirportList::add( const string &id, const SGGeod& location, const SGGeod& tower_location,
|
void FGAirportList::add( const string &id, const SGGeod& location, const SGGeod& tower_location,
|
||||||
const string &name, const bool has_metar )
|
const string &name, bool has_metar, bool is_airport, bool is_seaport,
|
||||||
|
bool is_heliport)
|
||||||
{
|
{
|
||||||
FGAirport* a = new FGAirport(id, location, tower_location, name, has_metar);
|
FGAirport* a = new FGAirport(id, location, tower_location, name, has_metar,
|
||||||
|
is_airport, is_seaport, is_heliport);
|
||||||
|
|
||||||
airports_by_id[a->getId()] = a;
|
airports_by_id[a->getId()] = a;
|
||||||
// try and read in an auxilary file
|
// try and read in an auxilary file
|
||||||
|
|
|
@ -69,12 +69,16 @@ private:
|
||||||
SGGeod _tower_location;
|
SGGeod _tower_location;
|
||||||
string _name;
|
string _name;
|
||||||
bool _has_metar;
|
bool _has_metar;
|
||||||
FGAirportDynamics *dynamics;
|
bool _is_airport;
|
||||||
|
bool _is_seaport;
|
||||||
|
bool _is_heliport;
|
||||||
|
FGAirportDynamics *_dynamics;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGAirport();
|
FGAirport();
|
||||||
// FGAirport(const FGAirport &other);
|
// FGAirport(const FGAirport &other);
|
||||||
FGAirport(const string& id, const SGGeod& location, const SGGeod& tower, const string& name, bool has_metar);
|
FGAirport(const string& id, const SGGeod& location, const SGGeod& tower, const string& name,
|
||||||
|
bool has_metar, bool is_airport, bool is_seaport, bool is_heliport);
|
||||||
~FGAirport();
|
~FGAirport();
|
||||||
|
|
||||||
const string& getId() const { return _id; }
|
const string& getId() const { return _id; }
|
||||||
|
@ -85,6 +89,9 @@ public:
|
||||||
// Returns ft
|
// Returns ft
|
||||||
double getElevation() const { return _location.getElevationFt(); }
|
double getElevation() const { return _location.getElevationFt(); }
|
||||||
bool getMetar() const { return _has_metar; }
|
bool getMetar() const { return _has_metar; }
|
||||||
|
bool isAirport() const { return _is_airport; }
|
||||||
|
bool isSeaport() const { return _is_seaport; }
|
||||||
|
bool isHeliport() const { return _is_heliport; }
|
||||||
|
|
||||||
const SGGeod& getTowerLocation() const { return _tower_location; }
|
const SGGeod& getTowerLocation() const { return _tower_location; }
|
||||||
|
|
||||||
|
@ -126,7 +133,8 @@ public:
|
||||||
|
|
||||||
// add an entry to the list
|
// add an entry to the list
|
||||||
void add( const string& id, const SGGeod& location, const SGGeod& tower,
|
void add( const string& id, const SGGeod& location, const SGGeod& tower,
|
||||||
const string& name, const bool has_metar );
|
const string& name, bool has_metar, bool is_airport,
|
||||||
|
bool is_seaport, bool is_heliport );
|
||||||
|
|
||||||
// search for the specified id.
|
// search for the specified id.
|
||||||
// Returns NULL if unsucessfull.
|
// Returns NULL if unsucessfull.
|
||||||
|
|
Loading…
Reference in a new issue