GEOS: Quadtree.h Source File

GEOS 3.3.8

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

- File List

Quadtree.h
1 /**********************************************************************
2 * $Id: Quadtree.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/quadtree/Quadtree.java rev. 1.16 (JTS-1.10)
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_IDX_QUADTREE_QUADTREE_H
21 #define GEOS_IDX_QUADTREE_QUADTREE_H
22
23 #include <geos/export.h>
24 #include <geos/index/SpatialIndex.h> // for inheritance
25 #include <geos/index/quadtree/Root.h> // for composition
26
27 #include <vector>
28 #include <string>
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 geom {
38 class Envelope;
39 }
40 namespace index {
41 namespace quadtree {
42 // class Root;
43 }
44 }
45 }
46
47 namespace geos {
48 namespace index { // geos::index
49 namespace quadtree { // geos::index::quadtree
50
73 class GEOS_DLL Quadtree: public SpatialIndex {
74
75 private:
76
77 std::vector<geom::Envelope *> newEnvelopes;
78
79 void collectStats(const geom::Envelope& itemEnv);
80
81 Root root;
82
94 double minExtent;
95
96 public:
104 static geom::Envelope* ensureExtent(const geom::Envelope *itemEnv,
105 double minExtent);
106
111 Quadtree()
112 :
113 root(),
114 minExtent(1.0)
115 {}
116
117 ~Quadtree();
118
120 int depth();
121
123 int size();
124
125 void insert(const geom::Envelope *itemEnv, void *item);
126
144 void query(const geom::Envelope *searchEnv, std::vector<void*>& ret);
145
146
163 void query(const geom::Envelope *searchEnv, ItemVisitor& visitor)
164 {
165 /*
166 * the items that are matched are the items in quads which
167 * overlap the search envelope
168 */
169 root.visit(searchEnv, visitor);
170 }
171
179 bool remove(const geom::Envelope* itemEnv, void* item);
180
182 std::vector<void*>* queryAll();
183
184 std::string toString() const;
185
186 };
187
188 } // namespace geos::index::quadtree
189 } // namespace geos::index
190 } // namespace geos
191
192 #ifdef _MSC_VER
193 #pragma warning(pop)
194 #endif
195
196 #endif // GEOS_IDX_QUADTREE_QUADTREE_H
197
198 /**********************************************************************
199 * $Log$
200 * Revision 1.2 2006/04/03 08:29:30 strk
201 * Added port info, cleaned up log message, minor assertion checking.
202 *
203 * Revision 1.1 2006/03/22 12:22:50 strk
204 * indexQuadtree.h split
205 *
206 **********************************************************************/
207