GEOS 3.9.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#ifndef GEOS_INDEX_INTERVALRTREE_SORTEDPACKEDINTERVALRTREE_H
17#define GEOS_INDEX_INTERVALRTREE_SORTEDPACKEDINTERVALRTREE_H
18
19#include <geos/index/intervalrtree/IntervalRTreeNode.h>
20#include <geos/index/intervalrtree/IntervalRTreeBranchNode.h>
21#include <geos/index/intervalrtree/IntervalRTreeLeafNode.h>
22#include <geos/util/UnsupportedOperationException.h>
23
24// forward declarations
25namespace geos {
26namespace index {
27class ItemVisitor;
28}
29}
30
31namespace geos {
32namespace index {
33namespace intervalrtree {
34
53private:
54 std::vector<IntervalRTreeLeafNode> leaves;
55 std::vector<IntervalRTreeBranchNode> branches;
56
63 const IntervalRTreeNode* root = nullptr;
64 int level = 0;
65
66 void init();
67 void buildLevel(IntervalRTreeNode::ConstVect& src, IntervalRTreeNode::ConstVect& dest);
68 const IntervalRTreeNode* buildTree();
69
70protected:
71public:
73
74 SortedPackedIntervalRTree(std::size_t initialCapacity)
75 {
76 leaves.reserve(initialCapacity);
77 }
78
88 void insert(double min, double max, void* item) {
89 if(root != nullptr) {
90 throw util::UnsupportedOperationException("Index cannot be added to once it has been queried");
91 }
92
93 leaves.emplace_back(min, max, item);
94 }
95
104 void query(double min, double max, index::ItemVisitor* visitor);
105
106};
107
108} // geos::intervalrtree
109} // geos::index
110} // geos
111
112#endif // GEOS_INDEX_INTERVALRTREE_SORTEDPACKEDINTERVALRTREE_H
113
A visitor for items in an index.
Definition ItemVisitor.h:29
A static index on a set of 1-dimensional intervals, using an R-Tree packed based on the order of the ...
Definition SortedPackedIntervalRTree.h:52
void query(double min, double max, index::ItemVisitor *visitor)
void insert(double min, double max, void *item)
Definition SortedPackedIntervalRTree.h:88
Indicates that the requested operation is unsupported.
Definition UnsupportedOperationException.h:36
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26