2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
class QgsSpatialIndex
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsspatialindex.h"
|
|
|
|
%End
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
public:
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/* creation of spatial index */
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Constructor - creates R-tree */
|
2012-09-24 02:28:15 +02:00
|
|
|
QgsSpatialIndex();
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Constructor - creates R-tree and bulk loads it with features from the iterator.
|
2014-12-03 10:52:50 +07:00
|
|
|
* This is much faster approach than creating an empty index and then inserting features one by one.
|
|
|
|
*
|
|
|
|
* @note added in 2.8
|
|
|
|
*/
|
2017-05-01 16:42:33 +02:00
|
|
|
explicit QgsSpatialIndex( const QgsFeatureIterator &fi );
|
2014-12-03 10:52:50 +07:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Copy constructor */
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsSpatialIndex( const QgsSpatialIndex &other );
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Destructor finalizes work with spatial index */
|
2012-09-24 02:28:15 +02:00
|
|
|
~QgsSpatialIndex();
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Implement assignment operator */
|
2017-05-01 16:42:33 +02:00
|
|
|
// QgsSpatialIndex &operator=( const QgsSpatialIndex &other );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/* operations */
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Add feature to index */
|
2017-05-01 16:42:33 +02:00
|
|
|
bool insertFeature( const QgsFeature &f );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Remove feature from index */
|
2017-05-01 16:42:33 +02:00
|
|
|
bool deleteFeature( const QgsFeature &f );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/* queries */
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns features that intersect the specified rectangle */
|
2017-05-01 16:42:33 +02:00
|
|
|
QList<qint64> intersects( const QgsRectangle &rect ) const;
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns nearest neighbors (their count is specified by second parameter) */
|
2017-05-01 16:42:33 +02:00
|
|
|
QList<qint64> nearestNeighbor( const QgsPoint &point, int neighbors ) const;
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
/* debugging */
|
|
|
|
|
|
|
|
//! get reference count - just for debugging!
|
|
|
|
int refs() const;
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
protected:
|
2014-05-27 23:22:50 +02:00
|
|
|
// @note not available in python bindings
|
2017-05-01 16:42:33 +02:00
|
|
|
// static SpatialIndex::Region rectToRegion( const QgsRectangle &rect );
|
2014-05-27 23:22:50 +02:00
|
|
|
// @note not available in python bindings
|
2017-05-01 16:42:33 +02:00
|
|
|
// bool featureInfo( const QgsFeature &f, SpatialIndex::Region &r, QgsFeatureId &id );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|