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


559
560
561
562
563
564
565
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 559

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)
  end
end

#eachObject


576
577
578
579
580
581
582
583
584
585
586
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 576

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


552
553
554
555
556
557
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 552

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)
  end
end

#geometry_typeObject


530
531
532
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 530

def geometry_type
  Feature::GeometryCollection
end

#hashObject


567
568
569
570
571
572
573
574
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 567

def hash
  @hash ||= begin
    hash = [@factory, geometry_type].hash
    (0...num_geometries).inject(hash) do |h, i|
      (1_664_525 * h + geometry_n(i).hash).hash
    end
  end
end

#num_geometriesObject Also known as: size


547
548
549
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 547

def num_geometries
  @fg_geom.num_geometries
end

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 534

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