mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	A very fast static spatial index for 2D points based on a flat KD-tree, using https://github.com/mourner/kdbush.hpp Compared to QgsSpatialIndex, this index: - supports single point features only (no multipoints) - is static (features cannot be added or removed from the index after construction) - is much faster! - supports true "distance based" searches, i.e. return all points within a radius from a search point
		
			
				
	
	
		
			137 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			137 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/core/qgsspatialindex.h                                           *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | 
						|
 ************************************************************************/
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
class QgsSpatialIndex
 | 
						|
{
 | 
						|
%Docstring
 | 
						|
 | 
						|
A spatial index for QgsFeature objects.
 | 
						|
 | 
						|
QgsSpatialIndex objects are implicitly shared and can be inexpensively copied.
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   While the underlying libspatialindex is not thread safe on some platforms, the QgsSpatialIndex
 | 
						|
   class implements its own locks and accordingly, a single QgsSpatialIndex object can safely
 | 
						|
   be used across multiple threads.
 | 
						|
 | 
						|
.. seealso:: :py:class:`QgsSpatialIndexKDBush`
 | 
						|
%End
 | 
						|
 | 
						|
%TypeHeaderCode
 | 
						|
#include "qgsspatialindex.h"
 | 
						|
%End
 | 
						|
  public:
 | 
						|
 | 
						|
 | 
						|
    QgsSpatialIndex();
 | 
						|
%Docstring
 | 
						|
Constructor for QgsSpatialIndex. Creates an empty R-tree index.
 | 
						|
%End
 | 
						|
 | 
						|
    explicit QgsSpatialIndex( const QgsFeatureIterator &fi, QgsFeedback *feedback = 0 );
 | 
						|
%Docstring
 | 
						|
Constructor - creates R-tree and bulk loads it with features from the iterator.
 | 
						|
This is much faster approach than creating an empty index and then inserting features one by one.
 | 
						|
 | 
						|
The optional ``feedback`` object can be used to allow cancelation of bulk feature loading. Ownership
 | 
						|
of ``feedback`` is not transferred, and callers must take care that the lifetime of feedback exceeds
 | 
						|
that of the spatial index construction.
 | 
						|
 | 
						|
.. versionadded:: 2.8
 | 
						|
%End
 | 
						|
 | 
						|
    explicit QgsSpatialIndex( const QgsFeatureSource &source, QgsFeedback *feedback = 0 );
 | 
						|
%Docstring
 | 
						|
Constructor - creates R-tree and bulk loads it with features from the source.
 | 
						|
This is much faster approach than creating an empty index and then inserting features one by one.
 | 
						|
 | 
						|
The optional ``feedback`` object can be used to allow cancelation of bulk feature loading. Ownership
 | 
						|
of ``feedback`` is not transferred, and callers must take care that the lifetime of feedback exceeds
 | 
						|
that of the spatial index construction.
 | 
						|
 | 
						|
.. versionadded:: 3.0
 | 
						|
%End
 | 
						|
 | 
						|
    QgsSpatialIndex( const QgsSpatialIndex &other );
 | 
						|
%Docstring
 | 
						|
Copy constructor
 | 
						|
%End
 | 
						|
 | 
						|
    ~QgsSpatialIndex();
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    bool insertFeature( const QgsFeature &feature );
 | 
						|
%Docstring
 | 
						|
Adds a ``feature`` to the index.
 | 
						|
%End
 | 
						|
 | 
						|
    bool insertFeature( QgsFeatureId id, const QgsRectangle &bounds );
 | 
						|
%Docstring
 | 
						|
Add a feature ``id`` to the index with a specified bounding box.
 | 
						|
 | 
						|
:return: true if feature was successfully added to index.
 | 
						|
 | 
						|
.. versionadded:: 3.0
 | 
						|
%End
 | 
						|
 | 
						|
    bool deleteFeature( const QgsFeature &feature );
 | 
						|
%Docstring
 | 
						|
Removes a ``feature`` from the index.
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    QList<QgsFeatureId> intersects( const QgsRectangle &rectangle ) const;
 | 
						|
%Docstring
 | 
						|
Returns a list of features with a bounding box which intersects the specified ``rectangle``.
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   The intersection test is performed based on the feature bounding boxes only, so for non-point
 | 
						|
   geometry features it is necessary to manually test the returned features for exact geometry intersection
 | 
						|
   when required.
 | 
						|
%End
 | 
						|
 | 
						|
    QList<QgsFeatureId> nearestNeighbor( const QgsPointXY &point, int neighbors ) const;
 | 
						|
%Docstring
 | 
						|
Returns nearest neighbors to a ``point``. The number of neighbours returned is specified
 | 
						|
by the ``neighbours`` argument.
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   The nearest neighbour test is performed based on the feature bounding boxes only, so for non-point
 | 
						|
   geometry features this method is not guaranteed to return the actual closest neighbours.
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
    int  refs() const;
 | 
						|
%Docstring
 | 
						|
Gets reference count - just for debugging!
 | 
						|
%End
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/core/qgsspatialindex.h                                           *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | 
						|
 ************************************************************************/
 |