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



416
417
418
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 416

def area
  @fg_geom.area
end

#centroidObject



420
421
422
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 420

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

#coordinatesObject



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

def coordinates
  ([exterior_ring] + interior_rings).map(&:coordinates)
end

#exterior_ringObject



428
429
430
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 428

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

#geometry_typeObject



412
413
414
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 412

def geometry_type
  Feature::Polygon
end

#hashObject



463
464
465
466
467
468
469
470
471
472
473
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 463

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



436
437
438
439
440
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 436

def interior_ring_n(idx)
  return unless idx >= 0 && idx < @fg_geom.num_interior_rings

  @factory.wrap_fg_geom(@fg_geom.interior_ring_n(idx), FFILinearRingImpl)
end

#interior_ringsObject



442
443
444
445
446
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 442

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



432
433
434
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 432

def num_interior_rings
  @fg_geom.num_interior_rings
end

#point_on_surfaceObject



424
425
426
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 424

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

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)


448
449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 448

def rep_equals?(rhs)
  if rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
    rhs.exterior_ring.rep_equals?(exterior_ring)
    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