GEOS: STRtree.h Source File

GEOS 3.5.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

STRtree.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 * Last port: index/strtree/STRtree.java rev. 1.11
16 *
17 **********************************************************************/
18
19 #ifndef GEOS_INDEX_STRTREE_STRTREE_H
20 #define GEOS_INDEX_STRTREE_STRTREE_H
21
22 #include <geos/export.h>
23 #include <geos/index/strtree/AbstractSTRtree.h> // for inheritance
24 #include <geos/index/SpatialIndex.h> // for inheritance
25 #include <geos/geom/Envelope.h> // for inlines
26
27 #include <vector>
28
29 #ifdef _MSC_VER
30 #pragma warning(push)
31 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
32 #endif
33
34 // Forward declarations
35 namespace geos {
36 namespace index {
37 namespace strtree {
38 class Boundable;
39 }
40 }
41 }
42
43 namespace geos {
44 namespace index { // geos::index
45 namespace strtree { // geos::index::strtree
46
62 class GEOS_DLL STRtree: public AbstractSTRtree, public SpatialIndex
63 {
64 using AbstractSTRtree::insert;
65 using AbstractSTRtree::query;
66
67 private:
68 class GEOS_DLL STRIntersectsOp: public AbstractSTRtree::IntersectsOp {
69 public:
70 bool intersects(const void* aBounds, const void* bBounds);
71 };
72
80 std::auto_ptr<BoundableList> createParentBoundables(BoundableList* childBoundables, int newLevel);
81
82 std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlices(std::vector<BoundableList*>* verticalSlices, int newLevel);
83
84 STRIntersectsOp intersectsOp;
85
86 std::auto_ptr<BoundableList> sortBoundables(const BoundableList* input);
87
88 std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlice(
89 BoundableList* childBoundables,
90 int newLevel);
91
97 std::vector<BoundableList*>* verticalSlices(
98 BoundableList* childBoundables,
99 size_t sliceCount);
100
101
102 protected:
103
104 AbstractNode* createNode(int level);
105
106 IntersectsOp* getIntersectsOp() {
107 return &intersectsOp;
108 }
109
110 public:
111
112 ~STRtree();
113
118 STRtree(std::size_t nodeCapacity=10);
119
120 void insert(const geom::Envelope *itemEnv,void* item);
121
122 //static double centreX(const geom::Envelope *e);
123
124 static double avg(double a, double b) {
125 return (a + b) / 2.0;
126 }
127
128 static double centreY(const geom::Envelope *e) {
129 return STRtree::avg(e->getMinY(), e->getMaxY());
130 }
131
132 void query(const geom::Envelope *searchEnv, std::vector<void*>& matches) {
133 AbstractSTRtree::query(searchEnv, matches);
134 }
135
136 void query(const geom::Envelope *searchEnv, ItemVisitor& visitor) {
137 return AbstractSTRtree::query(searchEnv, visitor);
138 }
139
140 bool remove(const geom::Envelope *itemEnv, void* item) {
141 return AbstractSTRtree::remove(itemEnv, item);
142 }
143 };
144
145 } // namespace geos::index::strtree
146 } // namespace geos::index
147 } // namespace geos
148
149
150 #ifdef _MSC_VER
151 #pragma warning(pop)
152 #endif
153
154 #endif // GEOS_INDEX_STRTREE_STRTREE_H
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:53
geos::index::strtree::AbstractSTRtree
Base class for STRtree and SIRtree.
Definition: AbstractSTRtree.h:132
geos::index::strtree::AbstractSTRtree::query
void query(const void *searchBounds, std::vector< void * > &foundItems)
Also builds the tree, if necessary.
geos::index::strtree::STRtree::query
void query(const geom::Envelope *searchEnv, ItemVisitor &visitor)
Queries the index for all items whose extents intersect the given search Envelope and applies an Item...
Definition: STRtree.h:136
geos::geom::Envelope::getMinY
double getMinY() const
geos::index::strtree::STRtree
A query-only R-tree created using the Sort-Tile-Recursive (STR) algorithm. For two-dimensional spatia...
Definition: STRtree.h:62
geos::index::strtree::STRtree::query
void query(const geom::Envelope *searchEnv, std::vector< void * > &matches)
Queries the index for all items whose extents intersect the given search Envelope.
Definition: STRtree.h:132
geos::index::SpatialIndex
Abstract class defines basic insertion and query operations supported by classes implementing spatial...
Definition: SpatialIndex.h:47
geos::index::strtree::AbstractSTRtree::IntersectsOp
A test for intersection between two bounds, necessary because subclasses of AbstractSTRtree have diff...
Definition: AbstractSTRtree.h:166
geos::index::ItemVisitor
A visitor for items in an index.
Definition: ItemVisitor.h:29
geos::index::strtree::AbstractSTRtree::insert
virtual void insert(const void *bounds, void *item)
Also builds the tree, if necessary.
geos::geom::Envelope::getMaxY
double getMaxY() const
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::index::strtree::AbstractNode
A node of the STR tree.
Definition: AbstractNode.h:42
geos::index::strtree::BoundableList
std::vector< Boundable * > BoundableList
A list of boundables. TODO: use a list.
Definition: AbstractSTRtree.h:44
geos::index::strtree::STRtree::getIntersectsOp
IntersectsOp * getIntersectsOp()
Definition: STRtree.h:106