GEOS: Node.h Source File

GEOS 3.3.8

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

- File List

index/quadtree/Node.h
1 /**********************************************************************
2 * $Id: Node.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/Node.java rev 1.8 (JTS-1.10)
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_IDX_QUADTREE_NODE_H
21 #define GEOS_IDX_QUADTREE_NODE_H
22
23 #include <geos/export.h>
24 #include <geos/index/quadtree/NodeBase.h> // for inheritance
25 #include <geos/geom/Coordinate.h> // for composition
26 #include <geos/geom/Envelope.h> // for inline
27
28 #include <string>
29 #include <memory>
30
31 #ifdef _MSC_VER
32 #pragma warning(push)
33 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
34 #endif
35
36 // Forward declarations
37 namespace geos {
38 namespace geom {
39 //class Coordinate;
40 class Envelope;
41 }
42 }
43
44 namespace geos {
45 namespace index { // geos::index
46 namespace quadtree { // geos::index::quadtree
47
56 class GEOS_DLL Node: public NodeBase {
57
58 private:
59
61 std::auto_ptr<geom::Envelope> env;
62
63 geom::Coordinate centre;
64
65 int level;
66
73 Node* getSubnode(int index);
74
75 std::auto_ptr<Node> createSubnode(int index);
76
77 protected:
78
79 bool isSearchMatch(const geom::Envelope& searchEnv) const {
80 return env->intersects(searchEnv);
81 }
82
83 public:
84
85 // Create a node computing level from given envelope
86 static std::auto_ptr<Node> createNode(const geom::Envelope& env);
87
89 //
93 static std::auto_ptr<Node> createExpanded(std::auto_ptr<Node> node,
94 const geom::Envelope& addEnv);
95
96 Node(std::auto_ptr<geom::Envelope> nenv, int nlevel)
97 :
98 env(nenv),
99 centre((env->getMinX()+env->getMaxX())/2,
100 (env->getMinY()+env->getMaxY())/2),
101 level(nlevel)
102 {
103 }
104
105 virtual ~Node() {}
106
109 geom::Envelope* getEnvelope() { return env.get(); }
110
116 Node* getNode(const geom::Envelope *searchEnv);
117
122 NodeBase* find(const geom::Envelope *searchEnv);
123
124 void insertNode(std::auto_ptr<Node> node);
125
126 std::string toString() const;
127
128 };
129
130 } // namespace geos::index::quadtree
131 } // namespace geos::index
132 } // namespace geos
133
134 #ifdef _MSC_VER
135 #pragma warning(pop)
136 #endif
137
138 #endif // GEOS_IDX_QUADTREE_NODE_H
139
140 /**********************************************************************
141 * $Log$
142 * Revision 1.1 2006/03/22 12:22:50 strk
143 * indexQuadtree.h split
144 *
145 **********************************************************************/
146