class Geos::GeometryCollection

Public Instance Methods

[](*args) click to toggle source
# File lib/ffi-geos/geometry_collection.rb, line 30
def [](*args)
  if args.length == 1 && args.first.is_a?(Numeric) && args.first >= 0
    get_geometry_n(args.first)
  else
    to_a[*args]
  end
end
Also aliased as: slice, at
at(*args)
Alias for: []
dump_points(cur_path = []) click to toggle source
# File lib/ffi-geos/geometry_collection.rb, line 40
def dump_points(cur_path = [])
  each do |geom|
    cur_path << geom.dump_points
  end
  cur_path
end
each() { |get_geometry_n(n)| ... } click to toggle source

Yields each Geometry in the GeometryCollection.

# File lib/ffi-geos/geometry_collection.rb, line 8
def each
  if block_given?
    num_geometries.times do |n|
      yield get_geometry_n(n)
    end
    self
  else
    num_geometries.times.collect { |n|
      get_geometry_n(n)
    }.to_enum
  end
end
geometry_n(n)
Alias for: get_geometry_n
get_geometry_n(n) click to toggle source
# File lib/ffi-geos/geometry_collection.rb, line 21
def get_geometry_n(n)
  if n.negative? || n >= num_geometries
    nil
  else
    cast_geometry_ptr(FFIGeos.GEOSGetGeometryN_r(Geos.current_handle_pointer, ptr, n), auto_free: false)
  end
end
Also aliased as: geometry_n
slice(*args)
Alias for: []