]> git.mxchange.org Git - flightgear.git/commitdiff
Use a transaction when indexing polylines.
authorJames Turner <zakalawe@mac.com>
Sun, 29 Nov 2015 14:18:30 +0000 (14:18 +0000)
committerJames Turner <zakalawe@mac.com>
Sun, 29 Nov 2015 14:18:30 +0000 (14:18 +0000)
src/GUI/QtLauncher.cxx
src/Navaids/PolyLine.cxx
src/Navaids/PolyLine.hxx

index d9a226da894b71e65f2bfc62a6e86b02c7b7573f..713f51749eb8420b15fc387b9c698cba90a519a1 100644 (file)
@@ -357,10 +357,7 @@ void loadNaturalEarthFile(const std::string& aFileName,
 
     flightgear::PolyLineList lines;
     flightgear::SHPParser::parsePolyLines(path, aType, lines, areClosed);
-    flightgear::PolyLineList::iterator it;
-    for (it=lines.begin(); it != lines.end(); ++it) {
-        (*it)->addToSpatialIndex();
-    }
+    flightgear::PolyLine::bulkAddToSpatialIndex(lines);
 }
 
 void loadNaturalEarthData()
index bf82df6d247af610106a3237ee84beac513a362d..38777c6538036f5aa5924ff4a90941cf2c0f609f 100644 (file)
@@ -29,6 +29,7 @@
 #include <boost/foreach.hpp>
 
 #include <simgear/math/sg_geodesy.hxx>
+#include <simgear/structure/exception.hxx>
 
 #include <Navaids/PositionedOctree.hxx>
 
@@ -100,6 +101,16 @@ PolyLineRef PolyLine::create(PolyLine::Type aTy, const SGGeodVec &aRawPoints)
     return new PolyLine(aTy, aRawPoints);
 }
 
+void PolyLine::bulkAddToSpatialIndex(const PolyLineList &lines)
+{
+    NavDataCache::Transaction txn( NavDataCache::instance());
+    flightgear::PolyLineList::const_iterator it;
+    for (it=lines.begin(); it != lines.end(); ++it) {
+        (*it)->addToSpatialIndex();
+    }
+    txn.commit();
+}
+
 void PolyLine::addToSpatialIndex() const
 {
     Octree::Node* node = Octree::global_spatialOctree->findNodeForBox(cartesianBox());
index ff7753bed0ba8b811a27c6c97e23fc9e67e8c140..57e827c9722998083d294e2127d4bee59f5af8e8 100644 (file)
@@ -91,6 +91,8 @@ public:
     
     static PolyLineRef create(Type aTy, const SGGeodVec& aRawPoints);
 
+    static void bulkAddToSpatialIndex(const PolyLineList& lines);
+
     /**
      * retrieve all the lines within a range of a search point.
      * lines are returned if any point is near the search location.