Don't rebuild navcache for scenery changes
- Cache can drop all ground-nets.
This commit is contained in:
parent
c00ab21fad
commit
56ca1fe93b
2 changed files with 71 additions and 40 deletions
src/Navaids
|
@ -300,6 +300,8 @@ public:
|
||||||
SG_LOG(SG_NAVCACHE, SG_INFO, "NavDataCache integrity check took:" << st.elapsedMSec());
|
SG_LOG(SG_NAVCACHE, SG_INFO, "NavDataCache integrity check took:" << st.elapsedMSec());
|
||||||
finalize(stmt);
|
finalize(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isCachedFileModified(const SGPath& path, bool verbose);
|
||||||
|
|
||||||
void callSqlite(int result, const string& sql)
|
void callSqlite(int result, const string& sql)
|
||||||
{
|
{
|
||||||
|
@ -939,7 +941,7 @@ public:
|
||||||
std::auto_ptr<RebuildThread> rebuilder;
|
std::auto_ptr<RebuildThread> rebuilder;
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGPositioned* NavDataCache::NavDataCachePrivate::loadById(sqlite3_int64 rowid,
|
FGPositioned* NavDataCache::NavDataCachePrivate::loadById(sqlite3_int64 rowid,
|
||||||
sqlite3_int64& aptId)
|
sqlite3_int64& aptId)
|
||||||
|
@ -1022,7 +1024,37 @@ FGPositioned* NavDataCache::NavDataCachePrivate::loadById(sqlite3_int64 rowid,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NavDataCache::NavDataCachePrivate::isCachedFileModified(const SGPath& path, bool verbose)
|
||||||
|
{
|
||||||
|
if (!path.exists()) {
|
||||||
|
throw sg_io_exception("isCachedFileModified: Missing file:" + path.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlite_bind_temp_stdstring(statCacheCheck, 1, path.str());
|
||||||
|
bool isModified = true;
|
||||||
|
sgDebugPriority logLevel = verbose ? SG_WARN : SG_DEBUG;
|
||||||
|
if (execSelect(statCacheCheck)) {
|
||||||
|
time_t modtime = sqlite3_column_int64(statCacheCheck, 0);
|
||||||
|
time_t delta = std::labs(modtime - path.modTime());
|
||||||
|
if (delta != 0)
|
||||||
|
{
|
||||||
|
SG_LOG(SG_NAVCACHE, logLevel, "NavCache: rebuild required for " << path <<
|
||||||
|
". Timestamps: " << modtime << " != " << path.modTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SG_LOG(SG_NAVCACHE, SG_DEBUG, "NavCache: no rebuild required for " << path);
|
||||||
|
}
|
||||||
|
|
||||||
|
isModified = (delta != 0);
|
||||||
|
} else {
|
||||||
|
SG_LOG(SG_NAVCACHE, logLevel, "NavCache: initial build required for " << path);
|
||||||
|
}
|
||||||
|
|
||||||
|
reset(statCacheCheck);
|
||||||
|
return isModified;
|
||||||
|
}
|
||||||
|
|
||||||
static NavDataCache* static_instance = NULL;
|
static NavDataCache* static_instance = NULL;
|
||||||
|
|
||||||
|
@ -1114,28 +1146,29 @@ bool NavDataCache::isRebuildRequired()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCachedFileModified(d->aptDatPath) ||
|
if (d->isCachedFileModified(d->aptDatPath, true) ||
|
||||||
isCachedFileModified(d->metarDatPath) ||
|
d->isCachedFileModified(d->metarDatPath, true) ||
|
||||||
isCachedFileModified(d->navDatPath) ||
|
d->isCachedFileModified(d->navDatPath, true) ||
|
||||||
isCachedFileModified(d->carrierDatPath) ||
|
d->isCachedFileModified(d->fixDatPath, true) ||
|
||||||
isCachedFileModified(d->fixDatPath) ||
|
d->isCachedFileModified(d->carrierDatPath, true) ||
|
||||||
// since POI loading is disabled on Windows, don't check for it
|
// since POI loading is disabled on Windows, don't check for it
|
||||||
// this caused: https://code.google.com/p/flightgear-bugs/issues/detail?id=1227
|
// this caused: https://code.google.com/p/flightgear-bugs/issues/detail?id=1227
|
||||||
#ifndef SG_WINDOWS
|
#ifndef SG_WINDOWS
|
||||||
isCachedFileModified(d->poiDatPath) ||
|
d->isCachedFileModified(d->poiDatPath, true) ||
|
||||||
#endif
|
#endif
|
||||||
isCachedFileModified(d->airwayDatPath))
|
d->isCachedFileModified(d->airwayDatPath, true))
|
||||||
{
|
{
|
||||||
SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: main cache rebuild required");
|
SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: main cache rebuild required");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string sceneryPaths = simgear::strutils::join(globals->get_fg_scenery(), ";");
|
string sceneryPaths = simgear::strutils::join(globals->get_fg_scenery(), ";");
|
||||||
if (readStringProperty("scenery_paths") != sceneryPaths) {
|
if (readStringProperty("scenery_paths") != sceneryPaths) {
|
||||||
SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: scenery paths changed, main cache rebuild required");
|
SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: scenery paths changed,dropping ground net");
|
||||||
return true;
|
dropAllGroundnets();
|
||||||
|
writeStringProperty("scenery_paths", sceneryPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: no main cache rebuild required");
|
SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: no main cache rebuild required");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1329,32 +1362,7 @@ void NavDataCache::writeStringListProperty(const string& key, const string_list&
|
||||||
|
|
||||||
bool NavDataCache::isCachedFileModified(const SGPath& path) const
|
bool NavDataCache::isCachedFileModified(const SGPath& path) const
|
||||||
{
|
{
|
||||||
if (!path.exists()) {
|
return d->isCachedFileModified(path, false);
|
||||||
throw sg_io_exception("isCachedFileModified: Missing file:" + path.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlite_bind_temp_stdstring(d->statCacheCheck, 1, path.str());
|
|
||||||
bool isModified = true;
|
|
||||||
|
|
||||||
if (d->execSelect(d->statCacheCheck)) {
|
|
||||||
time_t modtime = sqlite3_column_int64(d->statCacheCheck, 0);
|
|
||||||
time_t delta = std::labs(modtime - path.modTime());
|
|
||||||
if (delta != 0)
|
|
||||||
{
|
|
||||||
SG_LOG(SG_NAVCACHE, SG_DEBUG, "NavCache: rebuild required for " << path << ". Timestamps: " << modtime << " != " << path.modTime());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SG_LOG(SG_NAVCACHE, SG_DEBUG, "NavCache: no rebuild required for " << path);
|
|
||||||
}
|
|
||||||
|
|
||||||
isModified = (delta != 0);
|
|
||||||
} else {
|
|
||||||
SG_LOG(SG_NAVCACHE, SG_DEBUG, "NavCache: initial build required for " << path);
|
|
||||||
}
|
|
||||||
|
|
||||||
d->reset(d->statCacheCheck);
|
|
||||||
return isModified;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavDataCache::stampCacheFile(const SGPath& path)
|
void NavDataCache::stampCacheFile(const SGPath& path)
|
||||||
|
@ -2151,6 +2159,21 @@ void NavDataCache::dropGroundnetFor(PositionedID aAirport)
|
||||||
sqlite3_bind_int64(q, 1, aAirport);
|
sqlite3_bind_int64(q, 1, aAirport);
|
||||||
d->execUpdate(q);
|
d->execUpdate(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NavDataCache::dropAllGroundnets()
|
||||||
|
{
|
||||||
|
SG_LOG(SG_NAVCACHE, SG_INFO, "dropping ground-net data");
|
||||||
|
beginTransaction();
|
||||||
|
d->runSQL("DELETE FROM groundnet_edge");
|
||||||
|
d->runSQL("DELETE FROM parking");
|
||||||
|
d->runSQL("DELETE FROM taxi_node");
|
||||||
|
|
||||||
|
sqlite3_stmt_ptr q = d->prepare("DELETE FROM positioned WHERE (type=?1 OR type=?2)");
|
||||||
|
sqlite3_bind_int(q, 1, FGPositioned::TAXI_NODE);
|
||||||
|
sqlite3_bind_int(q, 2, FGPositioned::PARKING);
|
||||||
|
d->execUpdate(q);
|
||||||
|
commitTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
bool NavDataCache::isReadOnly() const
|
bool NavDataCache::isReadOnly() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,6 +120,14 @@ public:
|
||||||
|
|
||||||
void dropGroundnetFor(PositionedID aAirport);
|
void dropGroundnetFor(PositionedID aAirport);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all ground-nets globally from the cache.
|
||||||
|
* This includes parking and taxi-nodes and edges between them. It's useful
|
||||||
|
* when scenery paths change, since the ground-nets depend on the scenery.
|
||||||
|
* Using this we can avoid havind to rebuild the entire cache.
|
||||||
|
*/
|
||||||
|
void dropAllGroundnets();
|
||||||
|
|
||||||
PositionedID insertParking(const std::string& name, const SGGeod& aPos,
|
PositionedID insertParking(const std::string& name, const SGGeod& aPos,
|
||||||
PositionedID aAirport,
|
PositionedID aAirport,
|
||||||
double aHeading, int aRadius, const std::string& aAircraftType,
|
double aHeading, int aRadius, const std::string& aAircraftType,
|
||||||
|
|
Loading…
Add table
Reference in a new issue