Ticket #320: hobu-fs.patch
| File hobu-fs.patch, 4.8 kB (added by sgillies, 2 years ago) |
|---|
-
rtree/wrapper.cc
old new 56 56 57 57 extern "C" 58 58 GISPySpatialIndex * 59 RtreeIndex_new( )59 RtreeIndex_new(char* filename, unsigned long nPageLength) 60 60 { 61 return new GISPySpatialIndex; 61 if (!filename) 62 return new GISPySpatialIndex; 63 else 64 { 65 if (!nPageLength) nPageLength=1; 66 return new GISPySpatialIndex(filename, nPageLength); 67 } 62 68 } 63 69 64 70 extern "C" … … 74 80 double *min, double *max) 75 81 { 76 82 /* TODO: handle possible exceptions */ 77 index-> mRTree->insertData(0, 0, Tools::Geometry::Region(min, max, 2), id);83 index->index().insertData(0, 0, Tools::Geometry::Region(min, max, 2), id); 78 84 } 79 85 80 86 extern "C" … … 88 94 ids = PyList_New((size_t)count); 89 95 PyListVisitor *visitor = new PyListVisitor(ids); 90 96 const Tools::Geometry::Region *region = new Tools::Geometry::Region(min, max, 2); 91 index-> mRTree->intersectsWithQuery(97 index->index().intersectsWithQuery( 92 98 (*region), (*visitor) 93 99 ); 94 100 delete region; -
rtree/gispyspatialindex.cc
old new 25 25 26 26 using namespace SpatialIndex; 27 27 28 GISPySpatialIndex::GISPySpatialIndex( )28 GISPySpatialIndex::GISPySpatialIndex(const char* pszFilename, unsigned long nPageSize) 29 29 { 30 // for now only memory manager31 mStorageManager = StorageManager::createNewMemoryStorageManager();32 30 33 // create buffer 31 std::string oFilename = std::string(pszFilename); 32 mStorageManager = StorageManager::createNewDiskStorageManager(oFilename, nPageSize); 34 33 34 Initialize(); 35 36 } 37 38 void GISPySpatialIndex::Initialize() 39 { 35 40 unsigned int capacity = 10; 36 41 bool writeThrough = false; 37 42 mStorage = StorageManager::createNewRandomEvictionsBuffer(*mStorageManager, capacity, writeThrough); … … 46 51 // create R-tree 47 52 long indexId; 48 53 mRTree = RTree::createNewRTree(*mStorage, fillFactor, indexCapacity, 49 leafCapacity, dimension, variant, indexId); 54 leafCapacity, dimension, variant, indexId); 55 56 50 57 } 58 GISPySpatialIndex::GISPySpatialIndex() 59 { 51 60 61 mStorageManager = StorageManager::createNewMemoryStorageManager(); 62 63 Initialize(); 64 } 65 52 66 GISPySpatialIndex:: ~GISPySpatialIndex() 53 67 { 54 68 delete mRTree; -
rtree/wrapper.h
old new 26 26 27 27 typedef struct RtreeIndex_t *RtreeIndex; 28 28 29 RtreeIndex RtreeIndex_new( );29 RtreeIndex RtreeIndex_new(char* filename, unsigned long nPagesize); 30 30 void RtreeIndex_del(RtreeIndex index); 31 31 void RtreeIndex_insertData(RtreeIndex index, long id, 32 32 double *min, double *max); -
rtree/gispyspatialindex.h
old new 21 21 */ 22 22 23 23 #include <Python.h> 24 #include <string> 24 25 25 26 namespace SpatialIndex 26 27 { … … 46 47 47 48 public: 48 49 GISPySpatialIndex(); 50 GISPySpatialIndex(const char* pszFilename, unsigned long nPageSize); 49 51 ~GISPySpatialIndex(); 52 50 53 bool insertFeature(long id, double *min, double *max); 51 /*void deleteFeature(QgsFeature& f);*/52 54 PyObject *intersects(double *min, double *max); 55 SpatialIndex::ISpatialIndex& index() {return *mRTree;} 56 57 private: 58 void Initialize(); 53 59 SpatialIndex::IStorageManager* mStorageManager; 54 60 SpatialIndex::StorageManager::IBuffer* mStorage; 55 61 SpatialIndex::ISpatialIndex* mRTree; -
rtree/_rtreemodule.cc
old new 42 42 static int 43 43 Rtree_init(Rtree *self, PyObject *args, PyObject *kwds) 44 44 { 45 self->index = RtreeIndex_new(); 45 char* filename = NULL; 46 unsigned long nPageLength = 0; 47 48 if (!PyArg_ParseTuple(args, "|si", &filename, (unsigned long)&nPageLength)) 49 return NULL; 50 51 self->index = RtreeIndex_new(filename,nPageLength); 46 52 return 0; 47 53 } 48 54 -
tests/R-Tree.txt
old new 18 18 >>> len(hits) 19 19 10 20 20 21 Instantiate indexes that are disk based 22 23 >>> index2 = Rtree("foodx",3) 24 >>> index3 = Rtree("foodex")
