]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/xmlloader.cxx
NasalCanvas: Clean up and expose Element node ghost
[flightgear.git] / src / Airports / xmlloader.cxx
index 71082a331732b96c96459835d468df87f452feca..901d1235f19d34fe566946c6c55862be94b574dc 100644 (file)
@@ -20,6 +20,7 @@
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/xml/easyxml.hxx>
 #include <simgear/misc/strutils.hxx>
+#include <simgear/timing/timestamp.hxx>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include "runwayprefloader.hxx"
 
 #include "dynamics.hxx"
+#include "simple.hxx"
 #include "runwayprefs.hxx"
 
+#include <Navaids/NavDataCache.hxx>
+
 using std::string;
 
 XMLLoader::XMLLoader() {}
 XMLLoader::~XMLLoader() {}
 
-void XMLLoader::load(FGAirportDynamics* d) {
-  FGAirportDynamicsXMLLoader visitor(d);
-  if(loadAirportXMLDataIntoVisitor(d->getId(), "groundnet", visitor)) {
-    d->init();
+void XMLLoader::load(FGAirportDynamics* d)
+{
+  SGPath path;
+  if (!findAirportData(d->parent()->ident(), "groundnet", path)) {
+    return;
+  }
+
+  flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
+  if (!cache->isCachedFileModified(path)) {
+    return;
+  }
+  
+  SG_LOG(SG_GENERAL, SG_INFO, "reading groundnet data from " << path);
+  SGTimeStamp t;
+  try {
+    cache->beginTransaction();
+    t.stamp();
+    {
+      FGAirportDynamicsXMLLoader visitor(d);
+      readXML(path.str(), visitor);
+    } // ensure visitor is destroyed so its destructor runs
+    cache->stampCacheFile(path);
+    cache->commitTransaction();
+  } catch (sg_exception& e) {
+    cache->abortTransaction();
   }
+
+  SG_LOG(SG_GENERAL, SG_INFO, "parsing XML took " << t.elapsedMSec());
 }
 
 void XMLLoader::load(FGRunwayPreference* p) {
@@ -48,13 +75,6 @@ void XMLLoader::load(FGRunwayPreference* p) {
   loadAirportXMLDataIntoVisitor(p->getId(), "rwyuse", visitor);
 }
 
-void XMLLoader::load(FGSidStar* p) {
-  SGPath path;
-  if (findAirportData(p->getId(), "SID", path)) {
-    p->load(path);
-  }
-}
-
 bool XMLLoader::findAirportData(const std::string& aICAO, 
     const std::string& aFileName, SGPath& aPath)
 {