Module: RGeo::ImplHelper::BasicGeometryCollectionMethods

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



14
15
16
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 14

def elements
  @elements
end

Instance Method Details

#[](idx) ⇒ Object



34
35
36
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 34

def [](idx)
  @elements[idx]
end

#dimensionObject



46
47
48
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 46

def dimension
  @dimension ||= @elements.map(&:dimension).max || -1
end

#each(&block) ⇒ Object



38
39
40
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 38

def each(&block)
  @elements.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 54

def empty?
  @elements.size == 0
end

#geometriesObject



42
43
44
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 42

def geometries
  @elements
end

#geometry_n(idx) ⇒ Object



30
31
32
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 30

def geometry_n(idx)
  idx < 0 ? nil : @elements[idx]
end

#geometry_typeObject



50
51
52
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 50

def geometry_type
  Feature::GeometryCollection
end

#hashObject



66
67
68
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 66

def hash
  @hash ||= [factory, geometry_type, *@elements].hash
end

#initialize(factory, elements) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 16

def initialize(factory, elements)
  self.factory = factory
  @elements = elements.map do |elem|
    elem = Feature.cast(elem, factory)
    raise Error::InvalidGeometry, "Could not cast #{elem}" unless elem
    elem
  end
  init_geometry
end

#num_geometriesObject



26
27
28
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 26

def num_geometries
  @elements.size
end

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
61
62
63
64
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 58

def rep_equals?(rhs)
  if rhs.is_a?(self.class) && rhs.factory.eql?(@factory) && @elements.size == rhs.num_geometries
    rhs.each_with_index { |p, i| return false unless @elements[i].rep_equals?(p) }
  else
    false
  end
end