#include <Navaids/waypoint.hxx>
#include <ATC/CommStation.hxx>
#include <Navaids/NavDataCache.hxx>
+#include <Navaids/navrecord.hxx>
using std::vector;
using std::pair;
mHelipadsLoaded(false),
mTaxiwaysLoaded(false),
mProceduresLoaded(false),
+ mThresholdDataLoaded(false),
mILSDataLoaded(false)
{
}
return; // already loaded, great
}
- loadSceneryDefinitions();
-
mHelipadsLoaded = true;
mHelipads = itemsOfType(FGPositioned::HELIPAD);
}
void FGAirport::loadSceneryDefinitions() const
{
+ if (mThresholdDataLoaded) {
+ return;
+ }
+
+ mThresholdDataLoaded = true;
+
SGPath path;
if (!XMLLoader::findAirportData(ident(), "threshold", path)) {
return; // no XML threshold data
mTowerPosition = SGGeod::fromDegM(lon, lat, fieldElevationM + elevM);
}
-bool FGAirport::validateILSData()
+void FGAirport::validateILSData()
{
if (mILSDataLoaded) {
- return false;
+ return;
}
+ // to avoid re-entrancy on this code-path, ensure we set loaded
+ // immediately.
mILSDataLoaded = true;
- NavDataCache* cache = NavDataCache::instance();
- if (cache->isReadOnly()) {
- return false;
- }
SGPath path;
if (!XMLLoader::findAirportData(ident(), "ils", path)) {
- return false; // no XML tower data
+ return; // no XML tower data
}
- if (!cache->isCachedFileModified(path)) {
- // cached values are correct, we're all done
- return false;
+ try {
+ SGPropertyNode_ptr rootNode = new SGPropertyNode;
+ readProperties(path.str(), rootNode);
+ readILSData(rootNode);
+ } catch (sg_exception& e){
+ SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading ils XML failed:" << e.getFormattedMessage());
}
-
- try {
- SGPropertyNode_ptr rootNode = new SGPropertyNode;
- readProperties(path.str(), rootNode);
-
- flightgear::NavDataCache::Transaction txn(cache);
- readILSData(rootNode);
- cache->stampCacheFile(path);
- txn.commit();
-// we loaded data, tell the caller it might need to reload things
- return true;
- } catch (sg_exception& e){
- SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading ils XML failed:" << e.getFormattedMessage());
- }
-
- return false;
}
void FGAirport::readILSData(SGPropertyNode* aRoot)
-{
+{
NavDataCache* cache = NavDataCache::instance();
-
// find the entry matching the runway
SGPropertyNode* runwayNode, *ilsNode;
for (int i=0; (runwayNode = aRoot->getChild("runway", i)) != NULL; ++i) {
ilsNode->getStringValue("nav-id"));
if (ils == 0) {
SG_LOG(SG_GENERAL, SG_INFO, "reading ILS data for " << ident() <<
- ", couldn;t find runway/navaid for:" <<
+ ", couldn't find runway/navaid for:" <<
ilsNode->getStringValue("rwy") << "/" <<
ilsNode->getStringValue("nav-id"));
continue;
lat = ilsNode->getDoubleValue("lat"),
elevM = ilsNode->getDoubleValue("elev-m");
- cache->updateILS(ils, SGGeod::fromDegM(lon, lat, elevM), hdgDeg);
+ FGNavRecordRef nav(FGPositioned::loadById<FGNavRecord>(ils));
+ assert(nav.valid());
+ nav->updateFromXML(SGGeod::fromDegM(lon, lat, elevM), hdgDeg);
} // of ILS iteration
} // of runway iteration
}