Loading...
Searching...
No Matches
Node.h
Go to the documentation of this file.
1/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 TerraLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19
20/*!
21 \file Node.h
22
23 \brief A class that represents an R-tree node.
24*/
25
26#ifndef __TERRALIB_SAM_RTREE_INTERNAL_NODE_H
27#define __TERRALIB_SAM_RTREE_INTERNAL_NODE_H
28
29// TerraLib
30#include "Branch.h"
31
32namespace te
33{
34 namespace sam
35 {
36 namespace rtree
37 {
38 /*!
39 \class Node
40
41 \brief A class that represents an R-tree node.
42
43 Level 0 indicates that this is a leaf node, other values indicate that it is an internal node.
44 */
45 template<class DATATYPE, int MAXNODES = 8, int MINNODES = MAXNODES / 2> class Node
46 {
47 public:
48
50
51 /*! \brief Constructor. */
53 : m_count(0), m_level(-1)
54 {
55 }
56
57 /*!
58 \brief It returns true if this is a internal node.
59
60 \return True if this is a internal node and false if it is a leaf.
61 */
62 bool isInternalNode() const
63 {
64 return (m_level > 0);
65 }
66
67 /*!
68 \brief It returns true if this is a leaf node.
69
70 \return True if this is a leaf node and false if it is internal.
71 */
72 bool isLeaf() const
73 {
74 return (m_level == 0);
75 }
76
77 /*! \brief This method is used during split when a node retained and used again (beeing re-filled). */
78 void init()
79 {
80 m_count = 0;
81 m_level = -1;
82 for(unsigned int i = 0; i < MAXNODES; ++i)
83 {
84 m_branch[i].m_child = 0;
86 }
87 }
88
89 private:
90
91 /*!
92 \brief No copy constructor allowed.
93
94 \param rhs The other geometry.
95 */
96 Node(const Node& rhs);
97
98 /*!
99 \brief No assignment operator allowed.
100
101 \param rhs The other geometry.
102
103 \return A reference for this.
104 */
105 Node& operator=(const Node& rhs);
106
107
108 public:
109
110 int m_count; //!< The number of elements in the node (count).
111 int m_level; //!< Leaf is zero, others positive.
112 BranchType m_branch[MAXNODES]; //!< Branches.
113 };
114
115 } // end namespace rtree
116 } // end namespace sam
117} // end namespace te
118
119
120#endif // __TERRALIB_SAM_RTREE_INTERNAL_NODE_H
121
A struct that represents a node-branch in an R-tree.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
A class that represents an R-tree node.
Definition: Node.h:46
BranchType m_branch[MAXNODES]
Branches.
Definition: Node.h:112
bool isInternalNode() const
It returns true if this is a internal node.
Definition: Node.h:62
te::sam::rtree::Branch< Node, DATATYPE > BranchType
Definition: Node.h:49
Node()
Constructor.
Definition: Node.h:52
void init()
This method is used during split when a node retained and used again (beeing re-filled).
Definition: Node.h:78
int m_count
The number of elements in the node (count).
Definition: Node.h:110
Node & operator=(const Node &rhs)
No assignment operator allowed.
bool isLeaf() const
It returns true if this is a leaf node.
Definition: Node.h:72
Node(const Node &rhs)
No copy constructor allowed.
int m_level
Leaf is zero, others positive.
Definition: Node.h:111
TerraLib.
It represents a node-branch of a Rtree.
Definition: Branch.h:46
NODE * m_child
A pointer to the child node.
Definition: Branch.h:51
te::gm::Envelope m_mbr
Bounding box containing all the objects under the branch or an object bounding box.
Definition: Branch.h:47