Module: RGeo::Geos::FFIGeometryCollectionMethods
- Includes:
- Enumerable
- Included in:
- FFIGeometryCollectionImpl, FFIMultiLineStringImpl, FFIMultiPointImpl, FFIMultiPolygonImpl
- Defined in:
- lib/rgeo/geos/ffi_feature_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
- #[](n_) ⇒ Object
- #each ⇒ Object
- #geometry_n(n_) ⇒ Object
- #geometry_type ⇒ Object
- #hash ⇒ Object
- #num_geometries ⇒ Object (also: #size)
- #rep_equals?(rhs_) ⇒ Boolean
Instance Method Details
#[](n_) ⇒ Object
488 489 490 491 492 493 494 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 488 def [](n_) n_ += @fg_geom.num_geometries if n_ < 0 if n_ >= 0 && n_ < @fg_geom.num_geometries @factory._wrap_fg_geom(@fg_geom.get_geometry_n(n_), @_klasses ? @_klasses[n_] : nil) end end |
#each ⇒ Object
505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 505 def each if block_given? @fg_geom.num_geometries.times do |n_| yield @factory._wrap_fg_geom(@fg_geom.get_geometry_n(n_), @_klasses ? @_klasses[n_] : nil) end self else enum_for end end |
#geometry_n(n_) ⇒ Object
481 482 483 484 485 486 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 481 def geometry_n(n_) if n_ >= 0 && n_ < @fg_geom.num_geometries @factory._wrap_fg_geom(@fg_geom.get_geometry_n(n_), @_klasses ? @_klasses[n_] : nil) end end |
#geometry_type ⇒ Object
459 460 461 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 459 def geometry_type Feature::GeometryCollection end |
#hash ⇒ Object
496 497 498 499 500 501 502 503 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 496 def hash @hash ||= begin hash_ = [@factory, geometry_type].hash (0...num_geometries).inject(hash_) do |h_, i_| (1_664_525 * h_ + geometry_n(i_).hash).hash end end end |
#num_geometries ⇒ Object Also known as: size
476 477 478 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 476 def num_geometries @fg_geom.num_geometries end |
#rep_equals?(rhs_) ⇒ Boolean
463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 463 def rep_equals?(rhs_) if rhs_.class == self.class && rhs_.factory.eql?(@factory) size_ = @fg_geom.num_geometries if size_ == rhs_.num_geometries size_.times do |n_| return false unless geometry_n(n_).rep_equals?(rhs_.geometry_n(n_)) end return true end end false end |