Module: RGeo::Geos::FFIGeometryCollectionMethods

Includes:
Enumerable
Included in:
FFIGeometryCollectionImpl, FFIMultiLineStringImpl, FFIMultiPointImpl, FFIMultiPolygonImpl
Defined in:
lib/rgeo/geos/ffi_feature_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#[](n_) ⇒ Object


617
618
619
620
621
622
623
624
625
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 617

def [](n_)
  n_ += @fg_geom.num_geometries if n_ < 0
  if n_ >= 0 && n_ < @fg_geom.num_geometries
    @factory._wrap_fg_geom(@fg_geom.get_geometry_n(n_),
      @_klasses ? @_klasses[n_] : nil)
  else
    nil
  end
end

#eachObject


638
639
640
641
642
643
644
645
646
647
648
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 638

def each
  if block_given?
    @fg_geom.num_geometries.times do |n_|
      yield @factory._wrap_fg_geom(@fg_geom.get_geometry_n(n_),
        @_klasses ? @_klasses[n_] : nil)
    end
    self
  else
    enum_for
  end
end

#geometry_n(n_) ⇒ Object


607
608
609
610
611
612
613
614
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 607

def geometry_n(n_)
  if n_ >= 0 && n_ < @fg_geom.num_geometries
    @factory._wrap_fg_geom(@fg_geom.get_geometry_n(n_),
      @_klasses ? @_klasses[n_] : nil)
  else
    nil
  end
end

#geometry_typeObject


582
583
584
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 582

def geometry_type
  Feature::GeometryCollection
end

#hashObject


628
629
630
631
632
633
634
635
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 628

def hash
  @hash ||= begin
    hash_ = [@factory, geometry_type].hash
    (0...num_geometries).inject(hash_) do |h_, i_|
      (1664525 * h_ + geometry_n(i_).hash).hash
    end
  end
end

#num_geometriesObject Also known as: size


601
602
603
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 601

def num_geometries
  @fg_geom.num_geometries
end

#rep_equals?(rhs_) ⇒ Boolean

Returns:

  • (Boolean)

587
588
589
590
591
592
593
594
595
596
597
598
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 587

def rep_equals?(rhs_)
  if rhs_.class == self.class && rhs_.factory.eql?(@factory)
    size_ = @fg_geom.num_geometries
    if size_ == rhs_.num_geometries
      size_.times do |n_|
        return false unless geometry_n(n_).rep_equals?(rhs_.geometry_n(n_))
      end
      return true
    end
  end
  false
end