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


505
506
507
508
509
510
511
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 505

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


522
523
524
525
526
527
528
529
530
531
532
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 522

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


498
499
500
501
502
503
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 498

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


476
477
478
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 476

def geometry_type
  Feature::GeometryCollection
end

#hashObject


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

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


493
494
495
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 493

def num_geometries
  @fg_geom.num_geometries
end

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 480

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