Class: CloudMade::Line

Inherits:
Geometry show all
Defined in:
lib/cloudmade/geometry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Geometry

parse

Constructor Details

#initialize(coords) ⇒ Line

Returns a new instance of Line.



80
81
82
# File 'lib/cloudmade/geometry.rb', line 80

def initialize(coords)
  @points = coords.map { |latlng| Point.new(latlng) }
end

Instance Attribute Details

#pointsObject

Returns the value of attribute points.



78
79
80
# File 'lib/cloudmade/geometry.rb', line 78

def points
  @points
end

Instance Method Details

#to_sObject



84
85
86
# File 'lib/cloudmade/geometry.rb', line 84

def to_s
  "Line(#{@points.join(',')})"
end

#to_wktObject



88
89
90
# File 'lib/cloudmade/geometry.rb', line 88

def to_wkt
  "LINESTRING #{wkt_helper}"
end

#wkt_helperObject



92
93
94
# File 'lib/cloudmade/geometry.rb', line 92

def wkt_helper
  "(#{@points.map{ |point| point.wkt_helper }.join(', ')})"
end