ICAO.twr.xml works in read-only mode.
This commit is contained in:
parent
afe02b9b36
commit
5f9c17bd69
2 changed files with 28 additions and 43 deletions
|
@ -630,16 +630,7 @@ void FGAirport::processThreshold(SGPropertyNode* aThreshold)
|
||||||
SGGeod FGAirport::getTowerLocation() const
|
SGGeod FGAirport::getTowerLocation() const
|
||||||
{
|
{
|
||||||
validateTowerData();
|
validateTowerData();
|
||||||
|
return mTowerPosition;
|
||||||
NavDataCache* cache = NavDataCache::instance();
|
|
||||||
PositionedIDVec towers = cache->airportItemsOfType(guid(), FGPositioned::TOWER);
|
|
||||||
if (towers.empty()) {
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "No towers defined for:" <<ident());
|
|
||||||
return SGGeod();
|
|
||||||
}
|
|
||||||
|
|
||||||
FGPositionedRef tower = cache->loadById(towers.front());
|
|
||||||
return tower->geod();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAirport::validateTowerData() const
|
void FGAirport::validateTowerData() const
|
||||||
|
@ -649,28 +640,29 @@ void FGAirport::validateTowerData() const
|
||||||
}
|
}
|
||||||
|
|
||||||
mTowerDataLoaded = true;
|
mTowerDataLoaded = true;
|
||||||
|
|
||||||
|
// first, load data from the cache (apt.dat)
|
||||||
NavDataCache* cache = NavDataCache::instance();
|
NavDataCache* cache = NavDataCache::instance();
|
||||||
if (cache->isReadOnly()) {
|
PositionedIDVec towers = cache->airportItemsOfType(guid(), FGPositioned::TOWER);
|
||||||
return;
|
if (towers.empty()) {
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "No towers defined for:" <<ident());
|
||||||
|
mTowerPosition = geod(); // use airport position
|
||||||
|
// increase tower elevation by 20 metres above the field elevation
|
||||||
|
mTowerPosition.setElevationM(geod().getElevationM() + 20.0);
|
||||||
|
} else {
|
||||||
|
FGPositionedRef tower = cache->loadById(towers.front());
|
||||||
|
mTowerPosition = tower->geod();
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPath path;
|
SGPath path;
|
||||||
if (!XMLLoader::findAirportData(ident(), "twr", path)) {
|
if (!XMLLoader::findAirportData(ident(), "twr", path)) {
|
||||||
return; // no XML tower data
|
return; // no XML tower data, base position is fine
|
||||||
}
|
|
||||||
|
|
||||||
if (!cache->isCachedFileModified(path)) {
|
|
||||||
// cached values are correct, we're all done
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
flightgear::NavDataCache::Transaction txn(cache);
|
|
||||||
SGPropertyNode_ptr rootNode = new SGPropertyNode;
|
SGPropertyNode_ptr rootNode = new SGPropertyNode;
|
||||||
readProperties(path.str(), rootNode);
|
readProperties(path.str(), rootNode);
|
||||||
const_cast<FGAirport*>(this)->readTowerData(rootNode);
|
const_cast<FGAirport*>(this)->readTowerData(rootNode);
|
||||||
cache->stampCacheFile(path);
|
|
||||||
txn.commit();
|
|
||||||
} catch (sg_exception& e){
|
} catch (sg_exception& e){
|
||||||
SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading twr XML failed:" << e.getFormattedMessage());
|
SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading twr XML failed:" << e.getFormattedMessage());
|
||||||
}
|
}
|
||||||
|
@ -685,17 +677,8 @@ void FGAirport::readTowerData(SGPropertyNode* aRoot)
|
||||||
// tower elevation is AGL, not AMSL. Since we don't want to depend on the
|
// tower elevation is AGL, not AMSL. Since we don't want to depend on the
|
||||||
// scenery for a precise terrain elevation, we use the field elevation
|
// scenery for a precise terrain elevation, we use the field elevation
|
||||||
// (this is also what the apt.dat code does)
|
// (this is also what the apt.dat code does)
|
||||||
double fieldElevationM = elevationM();
|
double fieldElevationM = geod().getElevationM();
|
||||||
SGGeod towerLocation(SGGeod::fromDegM(lon, lat, fieldElevationM + elevM));
|
mTowerPosition = SGGeod::fromDegM(lon, lat, fieldElevationM + elevM);
|
||||||
|
|
||||||
NavDataCache* cache = NavDataCache::instance();
|
|
||||||
PositionedIDVec towers = cache->airportItemsOfType(guid(), FGPositioned::TOWER);
|
|
||||||
if (towers.empty()) {
|
|
||||||
cache->insertTower(guid(), towerLocation);
|
|
||||||
} else {
|
|
||||||
// update the position
|
|
||||||
cache->updatePosition(towers.front(), towerLocation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FGAirport::validateILSData()
|
bool FGAirport::validateILSData()
|
||||||
|
|
|
@ -314,6 +314,8 @@ private:
|
||||||
void loadProcedures() const;
|
void loadProcedures() const;
|
||||||
|
|
||||||
mutable bool mTowerDataLoaded;
|
mutable bool mTowerDataLoaded;
|
||||||
|
mutable SGGeod mTowerPosition;
|
||||||
|
|
||||||
mutable bool mRunwaysLoaded;
|
mutable bool mRunwaysLoaded;
|
||||||
mutable bool mHelipadsLoaded;
|
mutable bool mHelipadsLoaded;
|
||||||
mutable bool mTaxiwaysLoaded;
|
mutable bool mTaxiwaysLoaded;
|
||||||
|
|
Loading…
Add table
Reference in a new issue