QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <QList>
38 
39 #include "qgsfeature.h"
40 
41 class CORE_EXPORT QgsSpatialIndex
42 {
43 
44  public:
45 
46  /* creation of spatial index */
47 
50 
52  ~QgsSpatialIndex();
53 
54 
55  /* operations */
56 
58  bool insertFeature( QgsFeature& f );
59 
61  bool deleteFeature( QgsFeature& f );
62 
63 
64  /* queries */
65 
67  QList<QgsFeatureId> intersects( QgsRectangle rect );
68 
70  QList<QgsFeatureId> nearestNeighbor( QgsPoint point, int neighbors );
71 
72 
73  protected:
74  // @note not available in python bindings
75  SpatialIndex::Region rectToRegion( QgsRectangle rect );
76  // @note not available in python bindings
77  bool featureInfo( QgsFeature& f, SpatialIndex::Region& r, QgsFeatureId &id );
78 
79  private:
80 
82  SpatialIndex::IStorageManager* mStorageManager;
83 
85  SpatialIndex::StorageManager::IBuffer* mStorage;
86 
88  SpatialIndex::ISpatialIndex* mRTree;
89 
90 };
91 
92 #endif
93