GEOS: NodeBase.h Source File

GEOS 3.5.0

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

- File List

quadtree/NodeBase.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/quadtree/NodeBase.java rev 1.9 (JTS-1.10)
16 *
17 **********************************************************************/
18
19 #ifndef GEOS_IDX_QUADTREE_NODEBASE_H
20 #define GEOS_IDX_QUADTREE_NODEBASE_H
21
22 #include <geos/export.h>
23 #include <vector>
24 #include <string>
25
26 #ifdef _MSC_VER
27 #pragma warning(push)
28 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
29 #endif
30
31 // Forward declarations
32 namespace geos {
33 namespace geom {
34 class Coordinate;
35 class Envelope;
36 }
37 namespace index {
38 class ItemVisitor;
39 namespace quadtree {
40 class Node;
41 }
42 }
43 }
44
45 namespace geos {
46 namespace index { // geos::index
47 namespace quadtree { // geos::index::quadtree
48
54 class GEOS_DLL NodeBase {
55
56 private:
57
58 void visitItems(const geom::Envelope* searchEnv,
59 ItemVisitor& visitor);
60
61 public:
62
63 static int getSubnodeIndex(const geom::Envelope *env,
64 const geom::Coordinate& centre);
65
66 NodeBase();
67
68 virtual ~NodeBase();
69
70 std::vector<void*>& getItems();
71
74 void add(void* item);
75
77 std::vector<void*>& addAllItems(std::vector<void*>& resultItems) const;
78
79 virtual void addAllItemsFromOverlapping(const geom::Envelope& searchEnv,
80 std::vector<void*>& resultItems) const;
81
82 unsigned int depth() const;
83
84 unsigned int size() const;
85
86 unsigned int getNodeCount() const;
87
88 virtual std::string toString() const;
89
90 virtual void visit(const geom::Envelope* searchEnv, ItemVisitor& visitor);
91
99 bool remove(const geom::Envelope* itemEnv, void* item);
100
101 bool hasItems() const;
102
103 bool hasChildren() const;
104
105 bool isPrunable() const;
106
107 protected:
108
110 std::vector<void*> items;
111
122 Node* subnode[4];
123
124 virtual bool isSearchMatch(const geom::Envelope& searchEnv) const=0;
125 };
126
127
128 // INLINES, To be moved in NodeBase.inl
129
130 inline bool
131 NodeBase::hasChildren() const
132 {
133 for (int i = 0; i < 4; i++)
134 if (subnode[i]) return true;
135 return false;
136 }
137
138 inline bool
139 NodeBase::isPrunable() const
140 {
141 return ! (hasChildren() || hasItems());
142 }
143
144 inline bool
145 NodeBase::hasItems() const
146 {
147 return ! items.empty();
148 }
149
150 } // namespace geos::index::quadtree
151 } // namespace geos::index
152 } // namespace geos
153
154 #ifdef _MSC_VER
155 #pragma warning(pop)
156 #endif
157
158 #endif // GEOS_IDX_QUADTREE_NODEBASE_H
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:53
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::index::quadtree::NodeBase
The base class for nodes in a Quadtree.
Definition: quadtree/NodeBase.h:54
geos::index::ItemVisitor
A visitor for items in an index.
Definition: ItemVisitor.h:29
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::index::quadtree::NodeBase::items
std::vector< void * > items
Actual items are NOT owned by this class.
Definition: quadtree/NodeBase.h:110
geos::index::quadtree::Node
Represents a node of a Quadtree.
Definition: index/quadtree/Node.h:55