23 #include "SpatialIndex.h"
25 using namespace SpatialIndex;
35 void visitNode(
const INode& n )
38 void visitData(
const IData& d )
40 mList.append( d.getIdentifier() );
43 void visitData( std::vector<const IData*>& v )
54 mStorageManager = StorageManager::createNewMemoryStorageManager();
58 unsigned int capacity = 10;
59 bool writeThrough =
false;
60 mStorage = StorageManager::createNewRandomEvictionsBuffer( *mStorageManager, capacity, writeThrough );
63 double fillFactor = 0.7;
64 unsigned long indexCapacity = 10;
65 unsigned long leafCapacity = 10;
66 unsigned long dimension = 2;
67 RTree::RTreeVariant variant = RTree::RV_RSTAR;
70 SpatialIndex::id_type indexId;
71 mRTree = RTree::createNewRTree( *mStorage, fillFactor, indexCapacity,
72 leafCapacity, dimension, variant, indexId );
79 delete mStorageManager;
84 double pt1[2], pt2[2];
89 return Region( pt1, pt2, 2 );
107 if ( !featureInfo( f, r,
id ) )
116 catch ( Tools::Exception &e )
119 QgsDebugMsg( QString(
"Tools::Exception caught: " ).arg( e.what().c_str() ) );
121 catch (
const std::exception &e )
124 QgsDebugMsg( QString(
"std::exception caught: " ).arg( e.what() ) );
128 QgsDebugMsg(
"unknown spatial index exception caught" );
138 if ( !featureInfo( f, r,
id ) )
147 QList<QgsFeatureId> list;
150 Region r = rectToRegion( rect );
152 mRTree->intersectsWithQuery( r, visitor );
159 QList<QgsFeatureId> list;
167 mRTree->nearestNeighborQuery( neighbors, p, visitor );