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


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

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


518
519
520
521
522
523
524
525
526
527
528
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 518

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


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

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


472
473
474
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 472

def geometry_type
  Feature::GeometryCollection
end

#hashObject


509
510
511
512
513
514
515
516
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 509

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


489
490
491
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 489

def num_geometries
  @fg_geom.num_geometries
end

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 476

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