Use a transaction when indexing polylines.
This commit is contained in:
parent
8bfb1c3aa5
commit
cec1de6219
3 changed files with 14 additions and 4 deletions
|
@ -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()
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue