GEOS 3.9.1
SIRtree.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#ifndef GEOS_INDEX_STRTREE_SIRTREE_H
16#define GEOS_INDEX_STRTREE_SIRTREE_H
17
18#include <geos/export.h>
19
20#include <geos/index/strtree/AbstractSTRtree.h> // for inheritance
21#include <geos/index/strtree/Interval.h> // for inline
22
23#include <vector>
24#include <memory>
25
26namespace geos {
27namespace index { // geos::index
28namespace strtree { // geos::index::strtree
29
41class GEOS_DLL SIRtree: public AbstractSTRtree {
42 using AbstractSTRtree::insert;
43 using AbstractSTRtree::query;
44
45public:
46
51
56 SIRtree(std::size_t nodeCapacity);
57
58 ~SIRtree() override;
59
60 void insert(double x1, double x2, void* item);
61
67 std::vector<void*>*
68 query(double x1, double x2)
69 {
70 std::vector<void*>* results = new std::vector<void*>();
71 Interval interval(std::min(x1, x2), std::max(x1, x2));
72 AbstractSTRtree::query(&interval, *results);
73 return results;
74 }
75
79 std::vector<void*>*
80 query(double x)
81 {
82 return query(x, x);
83 }
84
89 SIRtree(const SIRtree&) = delete;
90 SIRtree& operator=(const SIRtree&) = delete;
91
92protected:
93
94 class SIRIntersectsOp: public AbstractSTRtree::IntersectsOp {
95 public:
96 bool intersects(const void* aBounds, const void* bBounds) override;
97 };
98
103 std::unique_ptr<BoundableList> createParentBoundables(
104 BoundableList* childBoundables, int newLevel) override;
105
106 AbstractNode* createNode(int level) override;
107
110 {
111 return intersectsOp;
112 }
113
114 std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input);
115
116private:
117 IntersectsOp* intersectsOp;
118 std::vector<std::unique_ptr<Interval>> intervals;
119};
120
121
122} // namespace geos::index::strtree
123} // namespace geos::index
124} // namespace geos
125
126#endif // GEOS_INDEX_STRTREE_SIRTREE_H
A node of the STR tree.
Definition: AbstractNode.h:44
A test for intersection between two bounds, necessary because subclasses of AbstractSTRtree have diff...
Definition: AbstractSTRtree.h:176
Base class for STRtree and SIRtree.
Definition: AbstractSTRtree.h:139
A contiguous portion of 1D-space. Used internally by SIRtree.
Definition: strtree/Interval.h:28
One-dimensional version of an STR-packed R-tree.
Definition: SIRtree.h:41
SIRtree()
Constructs an SIRtree with the default node capacity.
SIRtree(std::size_t nodeCapacity)
Constructs an SIRtree with the given maximum number of child nodes that a node may have.
std::vector< void * > * query(double x)
Definition: SIRtree.h:80
SIRtree(const SIRtree &)=delete
std::unique_ptr< BoundableList > createParentBoundables(BoundableList *childBoundables, int newLevel) override
Sorts the childBoundables then divides them into groups of size M, where M is the node capacity.
std::vector< void * > * query(double x1, double x2)
Definition: SIRtree.h:68
IntersectsOp * getIntersectsOp() override
Definition: SIRtree.h:109
std::vector< Boundable * > BoundableList
A list of boundables. TODO: use a list.
Definition: AbstractSTRtree.h:44
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26