Geometry
Represents a collection of arbitrary geometries
creates a new GeometryCollection from an array of geometries
# File lib/geo_ruby/simple_features/geometry_collection.rb, line 129 def self.from_geometries(geometries,srid=DEFAULT_SRID,with_z=false,with_m=false) geometry_collection = new(srid,with_z,with_m) geometry_collection.concat(geometries) geometry_collection end
tests the equality of geometry collections
# File lib/geo_ruby/simple_features/geometry_collection.rb, line 67 def ==(other_collection) if(other_collection.class != self.class) false elsif length != other_collection.length false else index=0 while index<length return false if self[index] != other_collection[index] index+=1 end true end end
Bounding box in 2D/3D. Returns an array of 2 points
# File lib/geo_ruby/simple_features/geometry_collection.rb, line 20 def bounding_box max_x, min_x, max_y, min_y = -Float::MAX, Float::MAX, -Float::MAX, Float::MAX, -Float::MAX, Float::MAX if with_z max_z, min_z = -Float::MAX, Float::MAX each do |geometry| bbox = geometry.bounding_box sw = bbox[0] ne = bbox[1] max_y = ne.y if ne.y > max_y min_y = sw.y if sw.y < min_y max_x = ne.x if ne.x > max_x min_x = sw.x if sw.x < min_x max_z = ne.z if ne.z > max_z min_z = sw.z if sw.z < min_z end [Point.from_x_y_z(min_x,min_y,min_z),Point.from_x_y_z(max_x,max_y,max_z)] else each do |geometry| bbox = geometry.bounding_box sw = bbox[0] ne = bbox[1] max_y = ne.y if ne.y > max_y min_y = sw.y if sw.y < min_y max_x = ne.x if ne.x > max_x min_x = sw.x if sw.x < min_x end [Point.from_x_y(min_x,min_y),Point.from_x_y(max_x,max_y)] end end
Generated with the Darkfish Rdoc Generator 2.