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 (!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 (apt_id.empty())
+ return;
+
+ 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
<< 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;
}
}
- // 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,
- last_rwy_heading, last_apt_elev, last_tower, got_tower);
+ last_rwy_heading, last_apt_elev, last_tower, got_tower, 0);
//
/***************************************************************************
* 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;
}
// 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
-
+
airports_array.push_back( a );
SG_LOG( SG_GENERAL, SG_BULK, "Adding " << id << " pos = " << location.getLongitudeDeg()
<< ", " << location.getLatitudeDeg() << " elev = " << location.getElevationFt() );
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; }
// 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; }
// 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.