Represents a line string as an array of points (see Point).
Creates a new line string. Accept a sequence of points as argument : ((x,y)…(x,y))
# File lib/geo_ruby/simple_features/line_string.rb, line 158 def self.from_coordinates(points,srid=DEFAULT_SRID,with_z=false,with_m=false) line_string = new(srid,with_z,with_m) line_string.concat( points.collect{|point_coords| Point.from_coordinates(point_coords,srid,with_z,with_m) } ) line_string end
Creates a new line string. Accept an array of points as argument
# File lib/geo_ruby/simple_features/line_string.rb, line 151 def self.from_points(points,srid=DEFAULT_SRID,with_z=false,with_m=false) line_string = new(srid,with_z,with_m) line_string.concat(points) line_string end
Tests the equality of line strings
# File lib/geo_ruby/simple_features/line_string.rb, line 65 def ==(other_line_string) if(other_line_string.class != self.class or other_line_string.length != self.length) false else index=0 while index<length return false if self[index] != other_line_string[index] index+=1 end true end end
Bounding box in 2D/3D. Returns an array of 2 points
# File lib/geo_ruby/simple_features/line_string.rb, line 27 def bounding_box max_x, min_x, max_y, min_y = -Float::MAX, Float::MAX, -Float::MAX, Float::MAX if(with_z) max_z, min_z = -Float::MAX,Float::MAX each do |point| max_y = point.y if point.y > max_y min_y = point.y if point.y < min_y max_x = point.x if point.x > max_x min_x = point.x if point.x < min_x max_z = point.z if point.z > max_z min_z = point.z if point.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 |point| max_y = point.y if point.y > max_y min_y = point.y if point.y < min_y max_x = point.x if point.x > max_x min_x = point.x if point.x < min_x end [Point.from_x_y(min_x,min_y),Point.from_x_y(max_x,max_y)] end end
tests if the line string is closed
# File lib/geo_ruby/simple_features/line_string.rb, line 21 def is_closed #a bit naive... @points.first == @points.last end
Generated with the Darkfish Rdoc Generator 2.