Class: GeoRuby::Rtree::STRBuilder::Slice

Inherits:
Object
  • Object
show all
Defined in:
lib/georuby-ext/georuby/rtree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#elementsObject

Returns the value of attribute elements.



70
71
72
# File 'lib/georuby-ext/georuby/rtree.rb', line 70

def elements
  @elements
end

#node_sizeObject

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

#nodesObject



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_yObject



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