- 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,
|
||||
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 (rwy_count > 0) {
|
||||
double lat = rwy_lat_accum / (double)rwy_count;
|
||||
double lon = rwy_lon_accum / (double)rwy_count;
|
||||
if (apt_id.empty())
|
||||
return;
|
||||
|
||||
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);
|
||||
} else {
|
||||
if ( apt_id.length() ) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: No runways for " << apt_id
|
||||
<< ", skipping." );
|
||||
}
|
||||
}
|
||||
if (!rwy_count) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: No runways for " << apt_id
|
||||
<< ", skipping." );
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -151,7 +151,7 @@ bool fgAirportDBLoad( FGAirportList *airports, FGRunwayList *runways,
|
|||
<< elev );
|
||||
|
||||
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_elev = elev;
|
||||
|
@ -244,7 +244,7 @@ bool fgAirportDBLoad( FGAirportList *airports, FGRunwayList *runways,
|
|||
|
||||
// add the last airport being processed if any
|
||||
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() : _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()
|
||||
{
|
||||
delete dynamics;
|
||||
delete _dynamics;
|
||||
}
|
||||
|
||||
|
||||
FGAirportDynamics * FGAirport::getDynamics()
|
||||
{
|
||||
if (dynamics != 0) {
|
||||
return dynamics;
|
||||
if (_dynamics != 0) {
|
||||
return _dynamics;
|
||||
} else {
|
||||
//cerr << "Trying to load dynamics for " << _id << endl;
|
||||
dynamics = new FGAirportDynamics(this);
|
||||
XMLLoader::load(dynamics);
|
||||
_dynamics = new FGAirportDynamics(this);
|
||||
XMLLoader::load(_dynamics);
|
||||
|
||||
FGRunwayPreference rwyPrefs(this);
|
||||
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
|
||||
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;
|
||||
// try and read in an auxilary file
|
||||
|
|
|
@ -69,12 +69,16 @@ private:
|
|||
SGGeod _tower_location;
|
||||
string _name;
|
||||
bool _has_metar;
|
||||
FGAirportDynamics *dynamics;
|
||||
bool _is_airport;
|
||||
bool _is_seaport;
|
||||
bool _is_heliport;
|
||||
FGAirportDynamics *_dynamics;
|
||||
|
||||
public:
|
||||
FGAirport();
|
||||
// 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();
|
||||
|
||||
const string& getId() const { return _id; }
|
||||
|
@ -85,6 +89,9 @@ public:
|
|||
// Returns ft
|
||||
double getElevation() const { return _location.getElevationFt(); }
|
||||
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; }
|
||||
|
||||
|
@ -126,7 +133,8 @@ public:
|
|||
|
||||
// add an entry to the list
|
||||
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.
|
||||
// Returns NULL if unsucessfull.
|
||||
|
|
Loading…
Reference in a new issue