Module: RGeo::ImplHelper::BasicGeometryCollectionMethods

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#dimensionObject



82
83
84
85
86
87
88
89
90
91
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 82

def dimension
  unless @dimension
    @dimension = -1
    @elements.each do |elem_|
      dim_ = elem_.dimension
      @dimension = dim_ if @dimension < dim_
    end
  end
  @dimension
end

#each(&block_) ⇒ Object



77
78
79
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 77

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

#eql?(rhs_) ⇒ Boolean

Returns:

  • (Boolean)


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

def eql?(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_].eql?(p_) }
  else
    false
  end
end

#geometry_n(n_) ⇒ Object



72
73
74
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 72

def geometry_n(n_)
  @elements[n_]
end

#geometry_typeObject



94
95
96
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 94

def geometry_type
  Feature::GeometryCollection
end

#initialize(factory_, elements_) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 45

def initialize(factory_, elements_)
  _set_factory(factory_)
  @elements = elements_.map do |elem_|
    elem_ = Feature.cast(elem_, factory_)
    unless elem_
      raise Error::InvalidGeometry, "Could not cast #{elem_}"
    end
    elem_
  end
  _validate_geometry
end

#is_empty?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 99

def is_empty?
  @elements.size == 0
end

#num_geometriesObject



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

def num_geometries
  @elements.size
end