Class: Geos::GeometryCollection

Inherits:
Geometry
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ffi-geos/geometry_collection.rb

Direct Known Subclasses

MultiLineString, MultiPoint, MultiPolygon

Constant Summary

Constants included from GeomTypes

Geos::GeomTypes::GEOS_GEOMETRYCOLLECTION, Geos::GeomTypes::GEOS_LINEARRING, Geos::GeomTypes::GEOS_LINESTRING, Geos::GeomTypes::GEOS_MULTILINESTRING, Geos::GeomTypes::GEOS_MULTIPOINT, Geos::GeomTypes::GEOS_MULTIPOLYGON, Geos::GeomTypes::GEOS_POINT, Geos::GeomTypes::GEOS_POLYGON

Instance Attribute Summary

Attributes inherited from Geometry

#ptr

Instance Method Summary collapse

Methods inherited from Geometry

#area, #boundary, #buffer, #centroid, #contains?, #convex_hull, #coord_seq, #covered_by?, #covers?, #crosses?, #difference, #dimensions, #disjoint?, #distance, #empty?, #end_point, #envelope, #eql?, #eql_almost?, #eql_exact?, #extract_unique_points, #geom_type, #has_z?, #hausdorff_distance, #initialize, #initialize_copy, #interpolate, #interpolate_normalized, #intersection, #intersects?, #length, #line_merge, #normalize!, #num_coordinates, #num_geometries, #overlaps?, #point_on_surface, #polygonize, #polygonize_cut_edges, #polygonize_full, #project, #project_normalized, #relate, #relate_boundary_node_rule, #relate_pattern, release, #ring?, #shared_paths, #simple?, #simplify, #snap, #srid, #srid=, #start_point, #sym_difference, #to_prepared, #to_s, #topology_preserve_simplify, #touches?, #type_id, #unary_union, #union, #union_cascaded, #valid?, #valid_detail, #valid_reason, #within?

Methods included from Tools

#bool_result, #cast_geometry_ptr, #check_enum_value, #check_geometry, #pick_srid_according_to_policy, #pick_srid_from_geoms, #symbol_for_enum

Constructor Details

This class inherits a constructor from Geos::Geometry

Instance Method Details

#[](*args) ⇒ Object Also known as: slice, at



30
31
32
33
34
35
36
# File 'lib/ffi-geos/geometry_collection.rb', line 30

def [](*args)
  if args.length == 1 && args.first.is_a?(Numeric) && args.first >= 0
    self.get_geometry_n(args.first)
  else
    self.to_a[*args]
  end
end

#eachObject

Yields each Geometry in the GeometryCollection.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ffi-geos/geometry_collection.rb', line 8

def each
  if block_given?
    self.num_geometries.times do |n|
      yield self.get_geometry_n(n)
    end
    self
  else
    self.num_geometries.times.collect { |n|
      self.get_geometry_n(n)
    }.to_enum
  end
end

#get_geometry_n(n) ⇒ Object Also known as: geometry_n



21
22
23
24
25
26
27
# File 'lib/ffi-geos/geometry_collection.rb', line 21

def get_geometry_n(n)
  if n < 0 || n >= self.num_geometries
    nil
  else
    cast_geometry_ptr(FFIGeos.GEOSGetGeometryN_r(Geos.current_handle, self.ptr, n), :auto_free => false)
  end
end