1
0
Fork 0

Fix some groundnet cache issues.

ThorstenB identified some cases where mod-times changing could lead to corrupted ground-cache data in the DB - handle both of these. What's still unclear is why the mod-times changes; hopefully the additional debug info will reveal this.
This commit is contained in:
James Turner 2012-11-24 12:14:56 +00:00
parent 830526a793
commit ec2975bac3
4 changed files with 39 additions and 7 deletions

View file

@ -66,7 +66,7 @@ void FGAirportDynamicsXMLLoader::endXML ()
for (it = _parkingPushbacks.begin(); it != _parkingPushbacks.end(); ++it) {
std::map<int, PositionedID>::iterator j = _idMap.find(it->second);
if (j == _idMap.end()) {
SG_LOG(SG_GENERAL, SG_WARN, "bad groundnet, no node for index:" << it->first);
SG_LOG(SG_NAVAID, SG_WARN, "bad groundnet, no node for index:" << it->first);
continue;
}
@ -74,7 +74,7 @@ void FGAirportDynamicsXMLLoader::endXML ()
}
BOOST_FOREACH(PositionedID id, _unreferencedNodes) {
SG_LOG(SG_GENERAL, SG_WARN, "unreferenced groundnet node:" << id);
SG_LOG(SG_NAVAID, SG_WARN, "unreferenced groundnet node:" << id);
}
}
@ -167,7 +167,7 @@ void FGAirportDynamicsXMLLoader::startNode(const XMLAttributes &atts)
}
if (_idMap.find(index) != _idMap.end()) {
SG_LOG(SG_GENERAL, SG_WARN, "duplicate ground-net index:" << index);
SG_LOG(SG_NAVAID, SG_WARN, "duplicate ground-net index:" << index);
}
SGGeod pos(SGGeod::fromDeg(processPosition(lon), processPosition(lat)));
@ -195,7 +195,7 @@ void FGAirportDynamicsXMLLoader::startArc(const XMLAttributes &atts)
IntPair e(begin, end);
if (_arcSet.find(e) != _arcSet.end()) {
SG_LOG(SG_GENERAL, SG_WARN, _dynamics->parent()->ident() << " ground-net: skipping duplicate edge:" << begin << "->" << end);
SG_LOG(SG_NAVAID, SG_WARN, _dynamics->parent()->ident() << " ground-net: skipping duplicate edge:" << begin << "->" << end);
return;
}

View file

@ -52,12 +52,15 @@ void XMLLoader::load(FGAirportDynamics* d)
return;
}
SG_LOG(SG_GENERAL, SG_INFO, "reading groundnet data from " << path);
SG_LOG(SG_NAVAID, SG_INFO, "reading groundnet data from " << path);
SGTimeStamp t;
try {
cache->beginTransaction();
t.stamp();
{
// drop all current data
cache->dropGroundnetFor(d->parent()->guid());
FGAirportDynamicsXMLLoader visitor(d);
readXML(path.str(), visitor);
} // ensure visitor is destroyed so its destructor runs
@ -67,7 +70,7 @@ void XMLLoader::load(FGAirportDynamics* d)
cache->abortTransaction();
}
SG_LOG(SG_GENERAL, SG_INFO, "parsing XML took " << t.elapsedMSec());
SG_LOG(SG_NAVAID, SG_INFO, "parsing groundnet XML took " << t.elapsedMSec());
}
void XMLLoader::load(FGRunwayPreference* p) {
@ -109,7 +112,7 @@ bool XMLLoader::loadAirportXMLDataIntoVisitor(const string& aICAO,
{
SGPath path;
if (!findAirportData(aICAO, aFileName, path)) {
SG_LOG(SG_GENERAL, SG_DEBUG, "loadAirportXMLDataIntoVisitor: failed to find data for " << aICAO << "/" << aFileName);
SG_LOG(SG_NAVAID, SG_DEBUG, "loadAirportXMLDataIntoVisitor: failed to find data for " << aICAO << "/" << aFileName);
return false;
}

View file

@ -1131,6 +1131,10 @@ void NavDataCache::doRebuild()
d->runSQL("DELETE FROM octree");
d->runSQL("DELETE FROM airway");
d->runSQL("DELETE FROM airway_edge");
d->runSQL("DELETE FROM taxi_node");
d->runSQL("DELETE FROM parking");
d->runSQL("DELETE FROM groundnet_edge");
d->runSQL("DELETE FROM stat_cache");
// initialise the root octree node
d->runSQL("INSERT INTO octree (rowid, children) VALUES (1, 0)");
@ -1991,5 +1995,28 @@ PositionedIDVec NavDataCache::findAirportParking(PositionedID airport, const std
return d->selectIds(d->findAirportParking);
}
void NavDataCache::dropGroundnetFor(PositionedID aAirport)
{
sqlite3_stmt_ptr q = d->prepare("DELETE FROM parking WHERE rowid IN (SELECT rowid FROM positioned WHERE type=?1 AND airport=?2)");
sqlite3_bind_int(q, 1, FGPositioned::PARKING);
sqlite3_bind_int64(q, 2, aAirport);
d->execUpdate(q);
q = d->prepare("DELETE FROM taxi_node WHERE rowid IN (SELECT rowid FROM positioned WHERE type=?1 AND airport=?2)");
sqlite3_bind_int(q, 1, FGPositioned::TAXI_NODE);
sqlite3_bind_int64(q, 2, aAirport);
d->execUpdate(q);
q = d->prepare("DELETE FROM positioned WHERE (type=?1 OR type=?2) AND airport=?3");
sqlite3_bind_int(q, 1, FGPositioned::TAXI_NODE);
sqlite3_bind_int(q, 2, FGPositioned::PARKING);
sqlite3_bind_int64(q, 3, aAirport);
d->execUpdate(q);
q = d->prepare("DELETE FROM groundnet_edge WHERE airport=?1");
sqlite3_bind_int64(q, 1, aAirport);
d->execUpdate(q);
}
} // of namespace flightgear

View file

@ -123,6 +123,8 @@ public:
PositionedID createUserWaypoint(const std::string& ident, const SGGeod& aPos);
void dropGroundnetFor(PositionedID aAirport);
PositionedID insertParking(const std::string& name, const SGGeod& aPos,
PositionedID aAirport,
double aHeading, int aRadius, const std::string& aAircraftType,