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


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

def area
  @fg_geom.area
end

#centroidObject


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

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

#coordinatesObject


470
471
472
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 470

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

#exterior_ringObject


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

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

#geometry_typeObject


409
410
411
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 409

def geometry_type
  Feature::Polygon
end

#hashObject


460
461
462
463
464
465
466
467
468
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 460

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


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

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


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

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


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

def num_interior_rings
  @fg_geom.num_interior_rings
end

#point_on_surfaceObject


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

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

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 445

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