GEOS  3.7.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 
26 namespace geos {
27 namespace index { // geos::index
28 namespace strtree { // geos::index::strtree
29 
41 class GEOS_DLL SIRtree: public AbstractSTRtree {
44 
45 public:
46 
50  SIRtree();
51 
56  SIRtree(std::size_t nodeCapacity);
57 
58  ~SIRtree() override;
59 
60  void insert(double x1, double x2, void* item);
61 
66  std::vector<void*>* query(double x1, double x2)
67  {
68  std::vector<void*>* results = new std::vector<void*>();
69  Interval interval(std::min(x1, x2), std::max(x1, x2));
70  AbstractSTRtree::query(&interval, *results);
71  return results;
72  }
73 
77  std::vector<void*>* query(double x) { return query(x,x); }
78 
83  SIRtree(const SIRtree&) = delete;
84  SIRtree& operator=(const SIRtree&) = delete;
85 
86 protected:
87 
88  class SIRIntersectsOp:public AbstractSTRtree::IntersectsOp {
89  public:
90  bool intersects(const void* aBounds, const void* bBounds) override;
91  };
92 
97  std::unique_ptr<BoundableList> createParentBoundables(
98  BoundableList* childBoundables, int newLevel) override;
99 
100  AbstractNode* createNode(int level) override;
101 
102  IntersectsOp* getIntersectsOp() override {return intersectsOp;}
103 
104  std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input) override;
105 
106 private:
107  IntersectsOp* intersectsOp;
108  std::vector<std::unique_ptr<Interval>> intervals;
109 };
110 
111 
112 } // namespace geos::index::strtree
113 } // namespace geos::index
114 } // namespace geos
115 
116 #endif // GEOS_INDEX_STRTREE_SIRTREE_H
A contiguous portion of 1D-space. Used internally by SIRtree.
Definition: strtree/Interval.h:28
std::vector< void * > * query(double x1, double x2)
Definition: SIRtree.h:66
std::vector< void * > * query(double x)
Definition: SIRtree.h:77
Base class for STRtree and SIRtree.
Definition: AbstractSTRtree.h:132
void query(const void *searchBounds, std::vector< void * > &foundItems)
Also builds the tree, if necessary.
A test for intersection between two bounds, necessary because subclasses of AbstractSTRtree have diff...
Definition: AbstractSTRtree.h:166
virtual void insert(const void *bounds, void *item)
Also builds the tree, if necessary.
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
IntersectsOp * getIntersectsOp() override
Definition: SIRtree.h:102
One-dimensional version of an STR-packed R-tree.
Definition: SIRtree.h:41
std::vector< Boundable * > BoundableList
A list of boundables. TODO: use a list.
Definition: AbstractSTRtree.h:44