GEOS 3.3.8

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

- File List

STRtree.h
1 /**********************************************************************
2 * $Id: STRtree.h 3255 2011-03-01 17:56:10Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2006 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: index/strtree/STRtree.java rev. 1.11
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_INDEX_STRTREE_STRTREE_H
21 #define GEOS_INDEX_STRTREE_STRTREE_H
22
23 #include <geos/export.h>
24 #include <geos/index/strtree/AbstractSTRtree.h> // for inheritance
25 #include <geos/index/SpatialIndex.h> // for inheritance
26 #include <geos/geom/Envelope.h> // for inlines
27
28 #include <vector>
29
30 #ifdef _MSC_VER
31 #pragma warning(push)
32 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
33 #endif
34
35 // Forward declarations
36 namespace geos {
37 namespace index {
38 namespace strtree {
39 class Boundable;
40 }
41 }
42 }
43
44 namespace geos {
45 namespace index { // geos::index
46 namespace strtree { // geos::index::strtree
47
63 class GEOS_DLL STRtree: public AbstractSTRtree, public SpatialIndex
64 {
65 using AbstractSTRtree::insert;
66 using AbstractSTRtree::query;
67
68 private:
69 class GEOS_DLL STRIntersectsOp: public AbstractSTRtree::IntersectsOp {
70 public:
71 bool intersects(const void* aBounds, const void* bBounds);
72 };
73
81 std::auto_ptr<BoundableList> createParentBoundables(BoundableList* childBoundables, int newLevel);
82
83 std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlices(std::vector<BoundableList*>* verticalSlices, int newLevel);
84
85 STRIntersectsOp intersectsOp;
86
87 std::auto_ptr<BoundableList> sortBoundables(const BoundableList* input);
88
89 std::auto_ptr<BoundableList> createParentBoundablesFromVerticalSlice(
90 BoundableList* childBoundables,
91 int newLevel);
92
98 std::vector<BoundableList*>* verticalSlices(
99 BoundableList* childBoundables,
100 size_t sliceCount);
101
102
103 protected:
104
105 AbstractNode* createNode(int level);
106
107 IntersectsOp* getIntersectsOp() {
108 return &intersectsOp;
109 };
110
111 public:
112
113 ~STRtree();
114
119 STRtree(std::size_t nodeCapacity=10);
120
121 void insert(const geom::Envelope *itemEnv,void* item);
122
123 //static double centreX(const geom::Envelope *e);
124
125 static double avg(double a, double b) {
126 return (a + b) / 2.0;
127 }
128
129 static double centreY(const geom::Envelope *e) {
130 return STRtree::avg(e->getMinY(), e->getMaxY());
131 }
132
133 void query(const geom::Envelope *searchEnv, std::vector<void*>& matches) {
134 AbstractSTRtree::query(searchEnv, matches);
135 }
136
137 void query(const geom::Envelope *searchEnv, ItemVisitor& visitor) {
138 return AbstractSTRtree::query(searchEnv, visitor);
139 }
140
141 bool remove(const geom::Envelope *itemEnv, void* item) {
142 return AbstractSTRtree::remove(itemEnv, item);
143 }
144 };
145
146 } // namespace geos::index::strtree
147 } // namespace geos::index
148 } // namespace geos
149
150
151 #ifdef _MSC_VER
152 #pragma warning(pop)
153 #endif
154
155 #endif // GEOS_INDEX_STRTREE_STRTREE_H
156
157 /**********************************************************************
158 * $Log$
159 * Revision 1.3 2006/06/12 10:49:43 strk
160 * unsigned int => size_t
161 *
162 * Revision 1.2 2006/04/03 08:43:09 strk
163 * Added port info, minor cleanups
164 *
165 * Revision 1.1 2006/03/21 10:47:34 strk
166 * indexStrtree.h split
167 *
168 **********************************************************************/
169