Module: RGeo::Geos::FFIPolygonMethods

Included in:
FFIPolygonImpl
Defined in:
lib/rgeo/geos/ffi_feature_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#areaObject


507
508
509
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 507

def area
  @fg_geom.area
end

#centroidObject


512
513
514
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 512

def centroid
  @factory._wrap_fg_geom(@fg_geom.centroid, FFIPointImpl)
end

#exterior_ringObject


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

def exterior_ring
  @factory._wrap_fg_geom(@fg_geom.exterior_ring, FFILinearRingImpl)
end

#geometry_typeObject


502
503
504
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 502

def geometry_type
  Feature::Polygon
end

#hashObject


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

def hash
  @hash ||= begin
    hash_ = Utils.ffi_coord_seq_hash(@fg_geom.exterior_ring.coord_seq,
      [@factory, geometry_type].hash)
    @fg_geom.interior_rings.inject(hash_) do |h_, r_|
      Utils.ffi_coord_seq_hash(r_.coord_seq, h_)
    end
  end
end

#interior_ring_n(n_) ⇒ Object


532
533
534
535
536
537
538
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 532

def interior_ring_n(n_)
  if n_ >= 0 && n_ < @fg_geom.num_interior_rings
    @factory._wrap_fg_geom(@fg_geom.interior_ring_n(n_), FFILinearRingImpl)
  else
    nil
  end
end

#interior_ringsObject


541
542
543
544
545
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 541

def interior_rings
  ::Array.new(@fg_geom.num_interior_rings) do |n_|
    @factory._wrap_fg_geom(@fg_geom.interior_ring_n(n_), FFILinearRingImpl)
  end
end

#num_interior_ringsObject


527
528
529
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 527

def num_interior_rings
  @fg_geom.num_interior_rings
end

#point_on_surfaceObject


517
518
519
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 517

def point_on_surface
  @factory._wrap_fg_geom(@fg_geom.point_on_surface, FFIPointImpl)
end

#rep_equals?(rhs_) ⇒ Boolean

Returns:

  • (Boolean)

548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 548

def rep_equals?(rhs_)
  if rhs_.class == self.class && rhs_.factory.eql?(@factory) &&
    rhs_.exterior_ring.rep_equals?(self.exterior_ring)
  then
    sn_ = @fg_geom.num_interior_rings
    rn_ = rhs_.num_interior_rings
    if sn_ == rn_
      sn_.times do |i_|
        return false unless interior_ring_n(i_).rep_equals?(rhs_.interior_ring_n(i_))
      end
      return true
    end
  end
  false
end