Class: Itinerary::View::KML
- Inherits:
-
Itinerary::View
- Object
- Itinerary::View
- Itinerary::View::KML
- Defined in:
- lib/itinerary/views/kml.rb
Instance Attribute Summary
Attributes inherited from Itinerary::View
#hide_fields, #name, #show_fields
Instance Method Summary collapse
- #render(entries) ⇒ Object
-
#render_record(rec) ⇒ Object
draw points for entries.
-
#render_route ⇒ Object
draw lines for legs of route.
Methods inherited from Itinerary::View
Constructor Details
This class inherits a constructor from Itinerary::View
Instance Method Details
#render(entries) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/itinerary/views/kml.rb', line 5 def render(entries) @kml = Builder::XmlMarkup.new @kml.instruct!(:xml, :version => '1.0', :encoding => 'UTF-8') @kml.kml(:xmlns => 'http://www.opengis.net/kml/2.2') do @kml.Document do @kml.name(@name) super render_route if @itinerary.route end end @kml.target! end |
#render_record(rec) ⇒ Object
draw points for entries
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/itinerary/views/kml.rb', line 20 def render_record(rec) @kml.Placemark(:id => rec.path) do @kml.name(rec.name) @kml.description do @kml.cdata!(rec.to_html(:use_dl => false, :field_keys => @field_keys)) end @kml.Point do #FIXME: fuzz if required @kml.coordinates([rec.longitude, rec.latitude, 0].join(',')) end end end |
#render_route ⇒ Object
draw lines for legs of route
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/itinerary/views/kml.rb', line 35 def render_route @kml.Placemark(:id => 'route') do @kml.LineString do @kml.extrude(1) @kml.tessellate(1) @kml.coordinates do @kml << @itinerary.route.map { |leg| [leg.longitude, leg.latitude].join(',') }.join("\n") end end end end |