GEOS 3.11.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#pragma once
16
17#include <geos/export.h>
18
19#include <geos/index/strtree/AbstractSTRtree.h> // for inheritance
20#include <geos/index/strtree/Interval.h> // for inline
21
22#include <vector>
23#include <memory>
24
25namespace geos {
26namespace index { // geos::index
27namespace strtree { // geos::index::strtree
28
40class GEOS_DLL SIRtree: public AbstractSTRtree {
43
44public:
45
50
55 SIRtree(std::size_t nodeCapacity);
56
57 ~SIRtree() override;
58
59 void insert(double x1, double x2, void* item);
60
66 std::vector<void*>*
67 query(double x1, double x2)
68 {
69 std::vector<void*>* results = new std::vector<void*>();
70 Interval interval(std::min(x1, x2), std::max(x1, x2));
71 AbstractSTRtree::query(&interval, *results);
72 return results;
73 }
74
78 std::vector<void*>*
79 query(double x)
80 {
81 return query(x, x);
82 }
83
88 SIRtree(const SIRtree&) = delete;
89 SIRtree& operator=(const SIRtree&) = delete;
90
91protected:
92
93 class SIRIntersectsOp: public AbstractSTRtree::IntersectsOp {
94 public:
95 bool intersects(const void* aBounds, const void* bBounds) override;
96 };
97
102 std::unique_ptr<BoundableList> createParentBoundables(
103 BoundableList* childBoundables, int newLevel) override;
104
105 AbstractNode* createNode(int level) override;
106
109 {
110 return intersectsOp;
111 }
112
113 std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input);
114
115private:
116 IntersectsOp* intersectsOp;
117 std::vector<std::unique_ptr<Interval>> intervals;
118};
119
120
121} // namespace geos::index::strtree
122} // namespace geos::index
123} // namespace geos
124
A node of the STR tree.
Definition: AbstractNode.h:43
A test for intersection between two bounds, necessary because subclasses of AbstractSTRtree have diff...
Definition: AbstractSTRtree.h:175
Base class for STRtree and SIRtree.
Definition: AbstractSTRtree.h:138
virtual void insert(const void *bounds, void *item)
Also builds the tree, if necessary.
void query(const void *searchBounds, std::vector< void * > &foundItems)
Also builds the tree, if necessary.
A contiguous portion of 1D-space. Used internally by SIRtree.
Definition: strtree/Interval.h:29
One-dimensional version of an STR-packed R-tree.
Definition: SIRtree.h:40
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:79
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:67
IntersectsOp * getIntersectsOp() override
Definition: SIRtree.h:108
std::vector< Boundable * > BoundableList
A list of boundables. TODO: use a list.
Definition: AbstractSTRtree.h:43
Basic namespace for all GEOS functionalities.
Definition: geos.h:39