From: James Turner Date: Sun, 29 Nov 2015 14:18:30 +0000 (+0000) Subject: Use a transaction when indexing polylines. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cec1de6219e62dd975eafbfe6e4768e12e25d5b8;p=flightgear.git Use a transaction when indexing polylines. --- diff --git a/src/GUI/QtLauncher.cxx b/src/GUI/QtLauncher.cxx index d9a226da8..713f51749 100644 --- a/src/GUI/QtLauncher.cxx +++ b/src/GUI/QtLauncher.cxx @@ -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() diff --git a/src/Navaids/PolyLine.cxx b/src/Navaids/PolyLine.cxx index bf82df6d2..38777c653 100644 --- a/src/Navaids/PolyLine.cxx +++ b/src/Navaids/PolyLine.cxx @@ -29,6 +29,7 @@ #include #include +#include #include @@ -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()); diff --git a/src/Navaids/PolyLine.hxx b/src/Navaids/PolyLine.hxx index ff7753bed..57e827c97 100644 --- a/src/Navaids/PolyLine.hxx +++ b/src/Navaids/PolyLine.hxx @@ -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.