GEOS 3.11.1
SortedPackedIntervalRTree.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2006 Refractions Research Inc.
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 *
14 **********************************************************************/
15
16#pragma once
17
18#include <geos/index/intervalrtree/IntervalRTreeNode.h>
19#include <geos/index/intervalrtree/IntervalRTreeBranchNode.h>
20#include <geos/index/intervalrtree/IntervalRTreeLeafNode.h>
21#include <geos/util/UnsupportedOperationException.h>
22
23// forward declarations
24namespace geos {
25namespace index {
26class ItemVisitor;
27}
28}
29
30namespace geos {
31namespace index {
32namespace intervalrtree {
33
52private:
53 std::vector<IntervalRTreeLeafNode> leaves;
54 std::vector<IntervalRTreeBranchNode> branches;
55
62 const IntervalRTreeNode* root = nullptr;
63 int level = 0;
64
65 void init();
66 void buildLevel(IntervalRTreeNode::ConstVect& src, IntervalRTreeNode::ConstVect& dest);
67 const IntervalRTreeNode* buildTree();
68
69protected:
70public:
72
73 SortedPackedIntervalRTree(std::size_t initialCapacity)
74 {
75 leaves.reserve(initialCapacity);
76 }
77
87 void insert(double min, double max, void* item) {
88 if(root != nullptr) {
89 throw util::UnsupportedOperationException("Index cannot be added to once it has been queried");
90 }
91
92 leaves.emplace_back(min, max, item);
93 }
94
103 void query(double min, double max, index::ItemVisitor* visitor);
104
105};
106
107} // geos::intervalrtree
108} // geos::index
109} // geos
110
A visitor for items in an index.
Definition: ItemVisitor.h:28
A static index on a set of 1-dimensional intervals, using an R-Tree packed based on the order of the ...
Definition: SortedPackedIntervalRTree.h:51
void query(double min, double max, index::ItemVisitor *visitor)
void insert(double min, double max, void *item)
Definition: SortedPackedIntervalRTree.h:87
Indicates that the requested operation is unsupported.
Definition: UnsupportedOperationException.h:35
Basic namespace for all GEOS functionalities.
Definition: geos.h:39