require 'geo_ruby/simple_features/geometry' module GeoRuby module SimpleFeatures #Represents a collection of arbitrary geometries class GeometryCollection < Geometry attr_reader :geometries def initialize(srid = DEFAULT_SRID,with_z=false,with_m=false) super(srid,with_z,with_m) @geometries = [] end #add a geometry to the collection def <<(geometry) @geometries << geometry end #add geometries to the collection def concat(geometries) @geometries.concat geometries end #number of geometries in the collection def length @geometries.length end #gets the nth geometry def [](n) @geometries[n] end #replaces the nth geometry def []=(n,geometry) @geometries[n]=geometry end #iterates over all the geometries def each(&proc) @geometries.each(&proc) end #iterates over all the geometries, passing the index to the bloc def each_index(&proc) @geometries.each_index(&proc) end #inserts geometries at the nth position def insert(n,*geometry) @geometries.insert(n,*geometry) end #index of the geometry def index(geometry) @geometries.index(geometry) end #remove a slice of the collection def remove(*slice) @geometries.slice(*slice) end #tests the equality of geometry collections def ==(other_collection) if(other_collection.class != self.class) false elsif length != other_collection.length false else index=0 while index