libSpatialindex

libspatialindex是一种高效的C++空间索引库。支持复杂查询,如范围查询、点位置查询、 最近邻查询、K邻近查询以及参数化查询。创建内存空间索引示例代码:


IStorageManager* diskfile = StorageManager::createNewMemoryStorageManager();
StorageManager::IBuffer* file = StorageManager::createNewRandomEvictionsBuffer(*diskfile, 10, false);
double fillFactor = 0.7;
uint32_t indexCapacity = 10;
uint32_t leafCapacity = 10;
uint32_t dimension = 2;
RTree::RTreeVariant variant = RTree::RV_RSTAR;
 
id_type indexIdentifier;
ISpatialIndex* tree = RTree::createNewRTree(*file, fillFactor, indexCapacity, leafCapacity, dimension, variant, indexIdentifier);
x1 = enve.MinX;
y1 = enve.MinY;
x2 = enve.MaxX;
y2 = enve.MaxY;
plow[0] = x1;
plow[1] = y1;
phigh[0] = x2;
phigh[1] = y2;
//r为几何对象的外接矩形,id为唯一的标识符,为长整型
Region r = Region(plow, phigh, 2);
tree->insertData(0, 0, r, id);
delete tree;
delete file;
delete diskfile;
posted @ 2020-05-10 11:04  ParamousGIS  阅读(1015)  评论(0编辑  收藏  举报