23 #include "SpatialIndex.h"
25 using namespace SpatialIndex;
41 mList.append( d.getIdentifier() );
55 : mNewIndex( newIndex ) {}
62 SpatialIndex::IShape* shape;
64 mNewIndex->insertData( 0, 0, *shape, d.getIdentifier() );
86 : QSharedData( other )
91 double low[] = { DBL_MIN, DBL_MIN };
92 double high[] = { DBL_MAX, DBL_MAX };
93 SpatialIndex::Region query( low, high, 2 );
95 other.
mRTree->intersectsWithQuery( query, visitor );
107 mStorage = StorageManager::createNewMemoryStorageManager();
110 double fillFactor = 0.7;
111 unsigned long indexCapacity = 10;
112 unsigned long leafCapacity = 10;
113 unsigned long dimension = 2;
114 RTree::RTreeVariant variant = RTree::RV_RSTAR;
117 SpatialIndex::id_type indexId;
118 mRTree = RTree::createNewRTree( *mStorage, fillFactor, indexCapacity,
119 leafCapacity, dimension, variant, indexId );
148 if (
this != &other )
155 double pt1[2], pt2[2];
160 return Region( pt1, pt2, 2 );
188 catch ( Tools::Exception &e )
191 QgsDebugMsg( QString(
"Tools::Exception caught: " ).arg( e.what().c_str() ) );
193 catch (
const std::exception &e )
196 QgsDebugMsg( QString(
"std::exception caught: " ).arg( e.what() ) );
200 QgsDebugMsg(
"unknown spatial index exception caught" );
219 QList<QgsFeatureId> list;
224 d->mRTree->intersectsWithQuery( r, visitor );
231 QList<QgsFeatureId> list;
239 d->mRTree->nearestNeighborQuery( neighbors, p, visitor );
QgsFeatureId id() const
Get the feature id for this feature.
A rectangle specified with double values.
SpatialIndex::IStorageManager * mStorage
storage manager
QgsSpatialIndex & operator=(const QgsSpatialIndex &other)
implement assignment operator
static SpatialIndex::Region rectToRegion(QgsRectangle rect)
SpatialIndex::ISpatialIndex * mRTree
R-tree containing spatial index.
bool deleteFeature(const QgsFeature &f)
remove feature from index
double yMaximum() const
Get the y maximum value (top side of rectangle)
SpatialIndex::ISpatialIndex * mNewIndex
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
QSharedDataPointer< QgsSpatialIndexData > d
void visitNode(const INode &n)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsSpatialIndexCopyVisitor(SpatialIndex::ISpatialIndex *newIndex)
QList< QgsFeatureId > intersects(QgsRectangle rect) const
returns features that intersect the specified rectangle
QgsSpatialIndexData(const QgsSpatialIndexData &other)
QList< QgsFeatureId > & mList
QgisVisitor(QList< QgsFeatureId > &list)
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
#define FID_TO_NUMBER(fid)
Data of spatial index that may be implicitly shared.
QList< QgsFeatureId > nearestNeighbor(QgsPoint point, int neighbors) const
returns nearest neighbors (their count is specified by second parameter)
QgsSpatialIndex()
constructor - creates R-tree
void visitData(std::vector< const IData * > &v)
A class to represent a point geometry.
void visitData(const IData &d)
void visitData(const IData &d)
QgsRectangle boundingBox()
Returns the bounding box of this feature.
bool insertFeature(const QgsFeature &f)
add feature to index
~QgsSpatialIndex()
destructor finalizes work with spatial index
int refs() const
get reference count - just for debugging!
void visitData(std::vector< const IData * > &v)
void visitNode(const INode &n)
bool featureInfo(const QgsFeature &f, SpatialIndex::Region &r, QgsFeatureId &id)
double xMinimum() const
Get the x minimum value (left side of rectangle)