Class: GeoRuby::Rtree::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*children) ⇒ Node

Returns a new instance of Node.



103
104
105
# File 'lib/georuby-ext/georuby/rtree.rb', line 103

def initialize(*children)
  @children = children.flatten
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



101
102
103
# File 'lib/georuby-ext/georuby/rtree.rb', line 101

def children
  @children
end

Instance Method Details

#==(other) ⇒ Object



114
115
116
# File 'lib/georuby-ext/georuby/rtree.rb', line 114

def ==(other)
  other.respond_to?(:children) and children == other.children
end

#boundsObject Also known as: envelope



107
108
109
# File 'lib/georuby-ext/georuby/rtree.rb', line 107

def bounds
  @bounds ||= GeoRuby::SimpleFeatures::Envelope.bounds(children)
end

#containing(bounds) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/georuby-ext/georuby/rtree.rb', line 118

def containing(bounds)
  children.select do |child|
    child.bounds.overlaps?(bounds) 
  end.collect do |child|
    if child.respond_to?(:containing)
      child.containing(bounds)
    else
      child
    end
  end.flatten
end