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


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

def area
  @fg_geom.area
end

#centroidObject


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

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

#coordinatesObject


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

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

#exterior_ringObject


445
446
447
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 445

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

#geometry_typeObject


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

def geometry_type
  Feature::Polygon
end

#hashObject


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

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


453
454
455
456
457
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 453

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)
  end
end

#interior_ringsObject


459
460
461
462
463
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 459

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


449
450
451
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 449

def num_interior_rings
  @fg_geom.num_interior_rings
end

#point_on_surfaceObject


441
442
443
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 441

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

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

465
466
467
468
469
470
471
472
473
474
475
476
477
478
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 465

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