Class: KML::LineString
- Defined in:
- lib/kml/line_string.rb
Overview
Defines a connected set of line segments. Use LineStyle to specify the color, color mode, and width of the line. When a LineString is extruded, the line is extended to the ground, forming a polygon that looks somewhat like a wall. For extruded LineStrings, the line itself uses the current LineStyle, and the extrusion uses the current PolyStyle. See the KML Tutorial for examples of LineStrings (or paths).
Instance Attribute Summary
Attributes inherited from Container
Attributes inherited from Feature
#address, #address_details, #description, #look_at, #metadata, #name, #phone_number, #region, #snippet, #style_selector, #style_url, #time_primitive
Attributes inherited from Object
Instance Method Summary collapse
-
#coordinates ⇒ Object
Two or more coordinate tuples, each consisting of floating point values for longitude, latitude, and altitude.
-
#coordinates=(c) ⇒ Object
Set the coordinates.
- #render(xm = Builder::XmlMarkup.new(:indent => 2)) ⇒ Object
Methods inherited from Geometry
#altitude_mode, #altitude_mode=, #altitude_mode_set?, #extrude, #extrude=, #extrude?, parse, #parse, #tessellate, #tessellate=, #tessellate?
Methods inherited from Container
Methods inherited from Feature
#open, #open=, #open?, #parse, #visibility, #visibility=, #visibility?
Methods inherited from Object
Constructor Details
This class inherits a constructor from KML::Object
Instance Method Details
#coordinates ⇒ Object
Two or more coordinate tuples, each consisting of floating point values for longitude, latitude, and altitude. The altitude component is optional.
10 11 12 |
# File 'lib/kml/line_string.rb', line 10 def coordinates @coordinates end |
#coordinates=(c) ⇒ Object
Set the coordinates. When specifying as a String, insert a space or linebreak between tuples. Do not include spaces within a tuple.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kml/line_string.rb', line 16 def coordinates=(c) case c when String @coordinates = c.strip.split(/\s+/).collect { |coord| coord.split(',') } when Array c.each do |coord_array| unless coord_array.is_a?(Array) raise ArgumentError, "If set with an array, coordinates must be specified as an array of arrays" end end @coordinates = c else raise ArgumentError, "Coordinates must either be a String or an Array of Arrays" end end |
#render(xm = Builder::XmlMarkup.new(:indent => 2)) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/kml/line_string.rb', line 32 def render(xm=Builder::XmlMarkup.new(:indent => 2)) raise ArgumentError, "Coordinates required" if coordinates.nil? xm.LineString { super xm.coordinates(coordinates.collect { |c| c.join(',') }.join(" ")) } end |