Module: RGeo::ImplHelper::BasicGeometryCollectionMethods
- Includes:
- Enumerable
- Included in:
- Cartesian::GeometryCollectionImpl, Cartesian::MultiLineStringImpl, Cartesian::MultiPointImpl, Cartesian::MultiPolygonImpl, Geographic::ProjectedGeometryCollectionImpl, Geographic::ProjectedMultiLineStringImpl, Geographic::ProjectedMultiPointImpl, Geographic::ProjectedMultiPolygonImpl, Geographic::SphericalGeometryCollectionImpl, Geographic::SphericalMultiLineStringImpl, Geographic::SphericalMultiPointImpl, Geographic::SphericalMultiPolygonImpl
- Defined in:
- lib/rgeo/impl_helper/basic_geometry_collection_methods.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Instance Method Summary collapse
- #[](idx) ⇒ Object
- #dimension ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #geometries ⇒ Object
- #geometry_n(idx) ⇒ Object
- #geometry_type ⇒ Object
- #hash ⇒ Object
- #initialize(factory, elements) ⇒ Object
- #num_geometries ⇒ Object
- #rep_equals?(rhs) ⇒ Boolean
Instance Attribute Details
#elements ⇒ Object (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 |
#dimension ⇒ Object
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
54 55 56 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 54 def empty? @elements.size == 0 end |
#geometries ⇒ Object
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_type ⇒ Object
50 51 52 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 50 def geometry_type Feature::GeometryCollection end |
#hash ⇒ Object
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_geometries ⇒ Object
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
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 |