Quantum GIS API Documentation
1.7.4
|
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 /* $Id$ */ 00016 00017 #ifndef QGSSPATIALINDEX_H 00018 #define QGSSPATIALINDEX_H 00019 00020 // forward declaration 00021 namespace SpatialIndex 00022 { 00023 class IStorageManager; 00024 class ISpatialIndex; 00025 00026 namespace StorageManager 00027 { 00028 class IBuffer; 00029 } 00030 } 00031 00032 namespace Tools 00033 { 00034 namespace Geometry 00035 { 00036 class Region; 00037 } 00038 } 00039 00040 class QgsFeature; 00041 class QgsRectangle; 00042 class QgsPoint; 00043 #include <QList> 00044 00045 class CORE_EXPORT QgsSpatialIndex 00046 { 00047 00048 public: 00049 00050 /* creation of spatial index */ 00051 00053 //static QgsSpatialIndex* createMemoryIndex(); 00054 00056 //static QgsSpatialIndex* createDiskIndex(QString fileName); 00057 00059 QgsSpatialIndex(); 00060 00062 ~QgsSpatialIndex(); 00063 00064 00065 /* operations */ 00066 00068 bool insertFeature( QgsFeature& f ); 00069 00071 bool deleteFeature( QgsFeature& f ); 00072 00073 00074 /* queries */ 00075 00077 QList<int> intersects( QgsRectangle rect ); 00078 00080 QList<int> nearestNeighbor( QgsPoint point, int neighbors ); 00081 00082 00083 protected: 00084 00085 Tools::Geometry::Region rectToRegion( QgsRectangle rect ); 00086 00087 bool featureInfo( QgsFeature& f, Tools::Geometry::Region& r, long& id ); 00088 00089 00090 private: 00091 00093 SpatialIndex::IStorageManager* mStorageManager; 00094 00096 SpatialIndex::StorageManager::IBuffer* mStorage; 00097 00099 SpatialIndex::ISpatialIndex* mRTree; 00100 00101 }; 00102 00103 #endif 00104