QGIS API Documentation 3.99.0-Master (e9821da5c6b)
Loading...
Searching...
No Matches
qgsspatialindexkdbush.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsspatialindexkdbush.h
3 -----------------
4 begin : July 2018
5 copyright : (C) 2018 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSSPATIALINDEXKDBUSH_H
19#define QGSSPATIALINDEXKDBUSH_H
20
22class QgsFeedback;
24class QgsSpatialIndexKDBushPrivate;
25class QgsRectangle;
26class QgsFeature;
27
28#include <functional>
29#include <memory>
30
31#include "qgis_core.h"
32#include "qgspointxy.h"
34
35#include <QList>
36
56class CORE_EXPORT QgsSpatialIndexKDBush
57{
58 public:
59
69 explicit QgsSpatialIndexKDBush( QgsFeatureIterator &fi, QgsFeedback *feedback = nullptr );
70
80 explicit QgsSpatialIndexKDBush( const QgsFeatureSource &source, QgsFeedback *feedback = nullptr );
81
82#ifndef SIP_RUN
83
101 explicit QgsSpatialIndexKDBush( QgsFeatureIterator &fi, const std::function< bool( const QgsFeature & ) > &callback, QgsFeedback *feedback = nullptr );
102#endif
103
112
115
117
127 bool addFeature( QgsFeatureId id, const QgsPointXY &point );
128
137 void finalize();
138
142 QList<QgsSpatialIndexKDBushData> intersects( const QgsRectangle &rectangle ) const;
143
149 void intersects( const QgsRectangle &rectangle, const std::function<void( QgsSpatialIndexKDBushData )> &visitor ) const SIP_SKIP;
150
155 QList<QgsSpatialIndexKDBushData> within( const QgsPointXY &point, double radius ) const;
156
163 void within( const QgsPointXY &point, double radius, const std::function<void( QgsSpatialIndexKDBushData )> &visitor ) SIP_SKIP;
164
168 qgssize size() const;
169
170 private:
171
173 QgsSpatialIndexKDBushPrivate *d = nullptr;
174
176};
177
178#endif // QGSSPATIALINDEXKDBUSH_H
Wrapper for iterator of features from vector data provider or vector layer.
An interface for objects which provide features via a getFeatures method.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Represents a 2D point.
Definition qgspointxy.h:62
A rectangle specified with double values.
A container for data stored inside a QgsSpatialIndexKDBush index.
void finalize()
Finalizes the index after manually adding features.
QgsSpatialIndexKDBush(QgsFeatureIterator &fi, QgsFeedback *feedback=nullptr)
Constructor - creates KDBush index and bulk loads it with features from the iterator.
qgssize size() const
Returns the size of the index, i.e.
QList< QgsSpatialIndexKDBushData > intersects(const QgsRectangle &rectangle) const
Returns the list of features which fall within the specified rectangle.
bool addFeature(QgsFeatureId id, const QgsPointXY &point)
Adds a single feature to the index.
QgsSpatialIndexKDBush(QgsFeatureIterator &fi, const std::function< bool(const QgsFeature &) > &callback, QgsFeedback *feedback=nullptr)
Constructor - creates KDBush index and bulk loads it with features from the source.
QgsSpatialIndexKDBush & operator=(const QgsSpatialIndexKDBush &other)
QList< QgsSpatialIndexKDBushData > within(const QgsPointXY &point, double radius) const
Returns the list of features which are within the given search radius of point.
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
Definition qgis.h:7447
#define SIP_SKIP
Definition qgis_sip.h:134
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features