Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 /* $Id$ */
16 
17 #ifndef QGSSPATIALINDEX_H
18 #define QGSSPATIALINDEX_H
19 
20 // forward declaration
21 namespace SpatialIndex
22 {
23  class IStorageManager;
24  class ISpatialIndex;
25 
26  namespace StorageManager
27  {
28  class IBuffer;
29  }
30 }
31 
32 namespace Tools
33 {
34  namespace Geometry
35  {
36  class Region;
37  }
38 }
39 
40 class QgsFeature;
41 class QgsRectangle;
42 class QgsPoint;
43 #include <QList>
44 
45 class CORE_EXPORT QgsSpatialIndex
46 {
47 
48  public:
49 
50  /* creation of spatial index */
51 
53  //static QgsSpatialIndex* createMemoryIndex();
54 
56  //static QgsSpatialIndex* createDiskIndex(QString fileName);
57 
60 
62  ~QgsSpatialIndex();
63 
64 
65  /* operations */
66 
68  bool insertFeature( QgsFeature& f );
69 
71  bool deleteFeature( QgsFeature& f );
72 
73 
74  /* queries */
75 
77  QList<int> intersects( QgsRectangle rect );
78 
80  QList<int> nearestNeighbor( QgsPoint point, int neighbors );
81 
82 
83  protected:
84 
85  Tools::Geometry::Region rectToRegion( QgsRectangle rect );
86 
87  bool featureInfo( QgsFeature& f, Tools::Geometry::Region& r, long& id );
88 
89 
90  private:
91 
93  SpatialIndex::IStorageManager* mStorageManager;
94 
96  SpatialIndex::StorageManager::IBuffer* mStorage;
97 
99  SpatialIndex::ISpatialIndex* mRTree;
100 
101 };
102 
103 #endif
104