Class: GeoTreeModule::NodeL
- Inherits:
-
Node
- Object
- Node
- GeoTreeModule::NodeL
show all
- Defined in:
- lib/geotree/node.rb
Instance Attribute Summary collapse
Attributes inherited from Node
#bounds, #leaf, #modified, #name, #next_node, #prev_node, #vertical
Instance Method Summary
collapse
Methods inherited from Node
#splittable
Constructor Details
#initialize(name, vertical, bounds) ⇒ NodeL
Returns a new instance of NodeL.
87
88
89
90
91
92
|
# File 'lib/geotree/node.rb', line 87
def initialize(name,vertical,bounds)
super(name,true,vertical,bounds)
@data_pts = []
@used = 0
@overflow = 0
end
|
Instance Attribute Details
#overflow ⇒ Object
name of overflow block (or zero)
86
87
88
|
# File 'lib/geotree/node.rb', line 86
def overflow
@overflow
end
|
Instance Method Details
#add_data_point(dp) ⇒ Object
110
111
112
|
# File 'lib/geotree/node.rb', line 110
def add_data_point(dp)
@data_pts << dp
end
|
#data_point(index) ⇒ Object
106
107
108
|
# File 'lib/geotree/node.rb', line 106
def data_point(index)
@data_pts[index]
end
|
#find_point(pt) ⇒ Object
Find position of a point, given its name; returns -1 if not found
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/geotree/node.rb', line 119
def find_point(pt)
ret = -1
@data_pts.each_with_index do |dp,i|
if DataPoint.match(dp,pt)
ret = i
break
end
end
ret
end
|
#inspect ⇒ Object
142
143
144
|
# File 'lib/geotree/node.rb', line 142
def inspect
to_s
end
|
#pop_last_point ⇒ Object
114
115
116
|
# File 'lib/geotree/node.rb', line 114
def pop_last_point
@data_pts.pop
end
|
#pts ⇒ Object
98
99
100
|
# File 'lib/geotree/node.rb', line 98
def pts
@data_pts
end
|
#set_data_point(index, dp) ⇒ Object
102
103
104
|
# File 'lib/geotree/node.rb', line 102
def set_data_point(index, dp)
@data_pts[index] = dp
end
|
#to_s ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/geotree/node.rb', line 130
def to_s
s = "LEAF=> ##{name} "
s << "us=#{used} ov=#{overflow} ["
used.times do |i|
dp = data_point(i)
s << " #{dp.name}"
end
s << ']'
s
end
|
#used ⇒ Object
94
95
96
|
# File 'lib/geotree/node.rb', line 94
def used
@data_pts.size
end
|