_name(name),
_has_metar(has_metar),
_dynamics(0),
- mLoadedXML(false)
+ mRunwaysLoaded(false),
+ mTaxiwaysLoaded(true)
{
}
unsigned int FGAirport::numRunways() const
{
+ loadRunways();
return mRunways.size();
}
FGRunway* FGAirport::getRunwayByIndex(unsigned int aIndex) const
{
+ loadRunways();
+
assert(aIndex >= 0 && aIndex < mRunways.size());
return mRunways[aIndex];
}
FGAirport::Runway_iterator
FGAirport::getIteratorForRunwayIdent(const string& aIdent) const
-{
+{
+ loadRunways();
+
string ident(aIdent);
if ((aIdent.size() == 1) || !isdigit(aIdent[1])) {
ident = "0" + aIdent;
FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
{
+ loadRunways();
+
Runway_iterator it = mRunways.begin();
FGRunway* result = NULL;
double currentBestQuality = 0.0;
bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
{
+ loadRunways();
+
unsigned int numRunways(mRunways.size());
for (unsigned int r=0; r<numRunways; ++r) {
FGRunway* rwy = mRunways[r];
unsigned int FGAirport::numTaxiways() const
{
+ loadTaxiways();
return mTaxiways.size();
}
FGTaxiway* FGAirport::getTaxiwayByIndex(unsigned int aIndex) const
{
+ loadTaxiways();
assert(aIndex >= 0 && aIndex < mTaxiways.size());
return mTaxiways[aIndex];
}
unsigned int FGAirport::numPavements() const
{
+ loadTaxiways();
return mPavements.size();
}
FGPavement* FGAirport::getPavementByIndex(unsigned int aIndex) const
{
+ loadTaxiways();
assert(aIndex >= 0 && aIndex < mPavements.size());
return mPavements[aIndex];
}
envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
}
- FGEnvironment stationWeather(envMgr->getEnvironment(mPosition));
+ // This forces West-facing rwys to be used in no-wind situations
+ // which is consistent with Flightgear's initial setup.
+ double hdg = 270;
- double windSpeed = stationWeather.get_wind_speed_kt();
- double hdg = stationWeather.get_wind_from_heading_deg();
- if (windSpeed <= 0.0) {
- hdg = 270; // This forces West-facing rwys to be used in no-wind situations
- // which is consistent with Flightgear's initial setup.
+ if (envMgr) {
+ FGEnvironment stationWeather(envMgr->getEnvironment(mPosition));
+
+ double windSpeed = stationWeather.get_wind_speed_kt();
+ if (windSpeed > 0.0) {
+ hdg = stationWeather.get_wind_from_heading_deg();
+ }
}
return findBestRunwayForHeading(hdg);
FGAirport* FGAirport::findByIdent(const std::string& aIdent)
{
FGPositionedRef r;
- AirportFilter filter;
+ PortsFilter filter;
r = FGPositioned::findNextWithPartialId(r, aIdent, &filter);
if (!r) {
return NULL; // we don't warn here, let the caller do that
FGAirport* FGAirport::getByIdent(const std::string& aIdent)
{
FGPositionedRef r;
- AirportFilter filter;
+ PortsFilter filter;
r = FGPositioned::findNextWithPartialId(r, aIdent, &filter);
if (!r) {
throw sg_range_exception("No such airport with ident: " + aIdent);
return FGAirport::findByIdent(id);
}
-
-void FGAirport::loadSceneryDefintions() const
+void FGAirport::loadRunways() const
{
- mLoadedXML = true;
+ if (mRunwaysLoaded) {
+ return; // already loaded, great
+ }
+ mRunwaysLoaded = true;
+ loadSceneryDefintions();
+}
+
+void FGAirport::loadTaxiways() const
+{
+ if (mTaxiwaysLoaded) {
+ return; // already loaded, great
+ }
+}
+
+void FGAirport::loadSceneryDefintions() const
+{
// allow users to disable the scenery data in the short-term
// longer term, this option can probably disappear
- if (fgGetBool("/sim/use-scenery-airport-data") == false) {
+ if (!fgGetBool("/sim/paths/use-custom-scenery-data")) {
return;
}
void FGAirport::readTowerData(SGPropertyNode* aRoot)
{
- SGPropertyNode* twrNode = aRoot->getChild("twr");
+ SGPropertyNode* twrNode = aRoot->getChild("tower")->getChild("twr");
double lat = twrNode->getDoubleValue("lat"),
lon = twrNode->getDoubleValue("lon"),
elevM = twrNode->getDoubleValue("elev-m");