Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgsspatialindex.h - wrapper class for spatial index library 00003 ---------------------- 00004 begin : December 2006 00005 copyright : (C) 2006 by Martin Dobias 00006 email : wonder.sk at gmail dot com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 00016 #ifndef QGSSPATIALINDEX_H 00017 #define QGSSPATIALINDEX_H 00018 00019 // forward declaration 00020 namespace SpatialIndex 00021 { 00022 class IStorageManager; 00023 class ISpatialIndex; 00024 class Region; 00025 class Point; 00026 00027 namespace StorageManager 00028 { 00029 class IBuffer; 00030 } 00031 } 00032 00033 class QgsFeature; 00034 class QgsRectangle; 00035 class QgsPoint; 00036 00037 #include <QList> 00038 00039 #include "qgsfeature.h" 00040 00041 class CORE_EXPORT QgsSpatialIndex 00042 { 00043 00044 public: 00045 00046 /* creation of spatial index */ 00047 00049 //static QgsSpatialIndex* createMemoryIndex(); 00050 00052 //static QgsSpatialIndex* createDiskIndex(QString fileName); 00053 00055 QgsSpatialIndex(); 00056 00058 ~QgsSpatialIndex(); 00059 00060 00061 /* operations */ 00062 00064 bool insertFeature( QgsFeature& f ); 00065 00067 bool deleteFeature( QgsFeature& f ); 00068 00069 00070 /* queries */ 00071 00073 QList<QgsFeatureId> intersects( QgsRectangle rect ); 00074 00076 QList<QgsFeatureId> nearestNeighbor( QgsPoint point, int neighbors ); 00077 00078 00079 protected: 00080 00081 SpatialIndex::Region rectToRegion( QgsRectangle rect ); 00082 00083 bool featureInfo( QgsFeature& f, SpatialIndex::Region& r, QgsFeatureId &id ); 00084 00085 00086 private: 00087 00089 SpatialIndex::IStorageManager* mStorageManager; 00090 00092 SpatialIndex::StorageManager::IBuffer* mStorage; 00093 00095 SpatialIndex::ISpatialIndex* mRTree; 00096 00097 }; 00098 00099 #endif 00100