Module: RGeo::Geos::FFIPolygonMethods
- Included in:
- FFIPolygonImpl
- Defined in:
- lib/rgeo/geos/ffi_feature_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
- #area ⇒ Object
- #centroid ⇒ Object
- #coordinates ⇒ Object
- #exterior_ring ⇒ Object
- #geometry_type ⇒ Object
- #hash ⇒ Object
- #interior_ring_n(idx) ⇒ Object
- #interior_rings ⇒ Object
- #num_interior_rings ⇒ Object
- #point_on_surface ⇒ Object
- #rep_equals?(rhs) ⇒ Boolean
Instance Method Details
#area ⇒ Object
415 416 417 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 415 def area @fg_geom.area end |
#centroid ⇒ Object
419 420 421 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 419 def centroid @factory.wrap_fg_geom(@fg_geom.centroid, FFIPointImpl) end |
#coordinates ⇒ Object
474 475 476 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 474 def coordinates ([exterior_ring] + interior_rings).map(&:coordinates) end |
#exterior_ring ⇒ Object
427 428 429 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 427 def exterior_ring @factory.wrap_fg_geom(@fg_geom.exterior_ring, FFILinearRingImpl) end |
#geometry_type ⇒ Object
411 412 413 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 411 def geometry_type Feature::Polygon end |
#hash ⇒ Object
462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 462 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
435 436 437 438 439 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 435 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_rings ⇒ Object
441 442 443 444 445 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 441 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_rings ⇒ Object
431 432 433 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 431 def num_interior_rings @fg_geom.num_interior_rings end |
#point_on_surface ⇒ Object
423 424 425 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 423 def point_on_surface @factory.wrap_fg_geom(@fg_geom.point_on_surface, FFIPointImpl) end |
#rep_equals?(rhs) ⇒ Boolean
447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 447 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 |