GEOS 3.4.2

- 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