1
0
Fork 0

Use a transaction when indexing polylines.

This commit is contained in:
James Turner 2015-11-29 14:18:30 +00:00
parent 8bfb1c3aa5
commit cec1de6219
3 changed files with 14 additions and 4 deletions

View 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()

View 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());

View 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.