QGIS API Documentation  2.99.0-Master (0a63d1f)
qgsspatialindex.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsspatialindex.h - wrapper class for spatial index library
3  ----------------------
4  begin : December 2006
5  copyright : (C) 2006 by Martin Dobias
6  email : wonder.sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSSPATIALINDEX_H
17 #define QGSSPATIALINDEX_H
18 
19 // forward declaration
20 namespace SpatialIndex
21 {
22  class IStorageManager;
23  class ISpatialIndex;
24  class Region;
25  class Point;
26 
27  namespace StorageManager
28  {
29  class IBuffer;
30  }
31 }
32 
33 class QgsFeature;
34 class QgsRectangle;
35 class QgsPoint;
36 
37 #include "qgis_core.h"
38 #include <QList>
39 #include <QSharedDataPointer>
40 
41 #include "qgsfeature.h"
42 
44 class QgsFeatureIterator;
45 
49 class CORE_EXPORT QgsSpatialIndex
50 {
51 
52  public:
53 
54  /* creation of spatial index */
55 
58 
64  explicit QgsSpatialIndex( const QgsFeatureIterator& fi );
65 
67  QgsSpatialIndex( const QgsSpatialIndex& other );
68 
70  ~QgsSpatialIndex();
71 
73  QgsSpatialIndex& operator=( const QgsSpatialIndex& other );
74 
75  /* operations */
76 
78  bool insertFeature( const QgsFeature& f );
79 
81  bool deleteFeature( const QgsFeature& f );
82 
83 
84  /* queries */
85 
87  QList<QgsFeatureId> intersects( const QgsRectangle& rect ) const;
88 
90  QList<QgsFeatureId> nearestNeighbor( const QgsPoint& point, int neighbors ) const;
91 
92  /* debugging */
93 
95  QAtomicInt refs() const;
96 
97  protected:
99  static SpatialIndex::Region rectToRegion( const QgsRectangle& rect );
101  static bool featureInfo( const QgsFeature& f, SpatialIndex::Region& r, QgsFeatureId &id );
102 
103  friend class QgsFeatureIteratorDataStream; // for access to featureInfo()
104 
105  private:
106 
107  QSharedDataPointer<QgsSpatialIndexData> d;
108 
109 };
110 
111 #endif
112 
Wrapper for iterator of features from vector data provider or vector layer.
A rectangle specified with double values.
Definition: qgsrectangle.h:36
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:136
Data of spatial index that may be implicitly shared.
Utility class for bulk loading of R-trees.
A class to represent a point.
Definition: qgspoint.h:143
qint64 QgsFeatureId
Definition: qgsfeature.h:33