GEOS  3.9.1dev
SortedPackedIntervalRTree.h
Go to the documentation of this file.
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 
23 
24 // forward declarations
25 namespace geos {
26 namespace index {
27 class ItemVisitor;
28 }
29 }
30 
31 namespace geos {
32 namespace index {
33 namespace intervalrtree {
34 
53 private:
54  std::vector<IntervalRTreeLeafNode> leaves;
55  std::vector<IntervalRTreeBranchNode> branches;
56 
63  const IntervalRTreeNode* root = nullptr;
64  int level = 0;
65 
66  void init();
68  const IntervalRTreeNode* buildTree();
69 
70 protected:
71 public:
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 static index on a set of 1-dimensional intervals, using an R-Tree packed based on the order of the ...
A visitor for items in an index.
Definition: ItemVisitor.h:29
Basic namespace for all GEOS functionalities.
Indicates that the requested operation is unsupported.
std::vector< const IntervalRTreeNode * > ConstVect