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

#[](idx) ⇒ Object



511
512
513
514
515
516
517
518
519
520
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 511

def [](idx)
  idx += @fg_geom.num_geometries if idx < 0

  return unless idx >= 0 && idx < @fg_geom.num_geometries

  @factory.wrap_fg_geom(
    @fg_geom.get_geometry_n(idx),
    @_klasses ? @_klasses[idx] : nil
  )
end

#eachObject



526
527
528
529
530
531
532
533
534
535
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 526

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(idx) ⇒ Object



502
503
504
505
506
507
508
509
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 502

def geometry_n(idx)
  return unless idx >= 0 && idx < @fg_geom.num_geometries

  @factory.wrap_fg_geom(
    @fg_geom.get_geometry_n(idx),
    @_klasses ? @_klasses[idx] : nil
  )
end

#geometry_typeObject



480
481
482
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 480

def geometry_type
  Feature::GeometryCollection
end

#hashObject



522
523
524
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 522

def hash
  @hash ||= [@factory, geometry_type, *(0...num_geometries).map { |i| geometry_n(i) }].hash
end

#num_geometriesObject Also known as: size



497
498
499
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 497

def num_geometries
  @fg_geom.num_geometries
end

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)


484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 484

def rep_equals?(rhs)
  if rhs.instance_of?(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