Class: GeoRuby::Rtree::STRBuilder::Slice
- Inherits:
-
Object
- Object
- GeoRuby::Rtree::STRBuilder::Slice
- Defined in:
- lib/georuby-ext/georuby/rtree.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
-
#node_size ⇒ Object
Returns the value of attribute node_size.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(elements, node_size = 2) ⇒ Slice
constructor
A new instance of Slice.
- #nodes ⇒ Object
- #sort_y ⇒ Object
Constructor Details
#initialize(elements, node_size = 2) ⇒ Slice
Returns a new instance of Slice.
72 73 74 |
# File 'lib/georuby-ext/georuby/rtree.rb', line 72 def initialize(elements, node_size = 2) @elements, @node_size = elements, node_size end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
70 71 72 |
# File 'lib/georuby-ext/georuby/rtree.rb', line 70 def elements @elements end |
#node_size ⇒ Object
Returns the value of attribute node_size.
70 71 72 |
# File 'lib/georuby-ext/georuby/rtree.rb', line 70 def node_size @node_size end |
Instance Method Details
#==(other) ⇒ Object
92 93 94 |
# File 'lib/georuby-ext/georuby/rtree.rb', line 92 def ==(other) other.respond_to?(:elements) and elements == other.elements end |
#nodes ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/georuby-ext/georuby/rtree.rb', line 84 def nodes [].tap do |nodes| sort_y.each_slice(node_size) do |node_elements| nodes << Node.new(node_elements) end end end |
#sort_y ⇒ Object
78 79 80 81 82 |
# File 'lib/georuby-ext/georuby/rtree.rb', line 78 def sort_y elements.sort_by do |element| element.bounds.center.y end end |