Module: RGeo::ImplHelper::BasicGeometryCollectionMethods
- 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 Method Summary collapse
- #[](n_) ⇒ Object
-
#_copy_state_from(obj_) ⇒ Object
:nodoc:.
-
#_elements ⇒ Object
:nodoc:.
- #dimension ⇒ Object
- #each(&block_) ⇒ Object
- #geometry_n(n_) ⇒ Object
- #geometry_type ⇒ Object
- #hash ⇒ Object
- #initialize(factory_, elements_) ⇒ Object
- #is_empty? ⇒ Boolean
- #num_geometries ⇒ Object
- #rep_equals?(rhs_) ⇒ Boolean
Instance Method Details
#[](n_) ⇒ Object
28 29 30 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 28 def [](n_) @elements[n_] end |
#_copy_state_from(obj_) ⇒ Object
:nodoc:
70 71 72 73 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 70 def _copy_state_from(obj_) # :nodoc: super @elements = obj_._elements end |
#_elements ⇒ Object
:nodoc:
75 76 77 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 75 def _elements # :nodoc: @elements end |
#dimension ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 36 def dimension unless defined?(@dimension) @dimension = -1 @elements.each do |elem_| dim_ = elem_.dimension @dimension = dim_ if @dimension < dim_ end end @dimension end |
#each(&block_) ⇒ Object
32 33 34 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 32 def each(&block_) @elements.each(&block_) end |
#geometry_n(n_) ⇒ Object
24 25 26 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 24 def geometry_n(n_) n_ < 0 ? nil : @elements[n_] end |
#geometry_type ⇒ Object
47 48 49 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 47 def geometry_type Feature::GeometryCollection end |
#hash ⇒ Object
63 64 65 66 67 68 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 63 def hash @hash ||= begin hash_ = [factory, geometry_type].hash @elements.inject(hash_) { |h_, g_| (1_664_525 * h_ + g_.hash).hash } end end |
#initialize(factory_, elements_) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 10 def initialize(factory_, elements_) _set_factory(factory_) @elements = elements_.map do |elem_| elem_ = Feature.cast(elem_, factory_) raise Error::InvalidGeometry, "Could not cast #{elem_}" unless elem_ elem_ end _validate_geometry end |
#is_empty? ⇒ Boolean
51 52 53 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 51 def is_empty? @elements.size == 0 end |
#num_geometries ⇒ Object
20 21 22 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 20 def num_geometries @elements.size end |
#rep_equals?(rhs_) ⇒ Boolean
55 56 57 58 59 60 61 |
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 55 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 |