class Gippix::GpxGenerator
Attributes
builder[R]
Public Class Methods
new()
click to toggle source
# File lib/gippix.rb, line 52 def initialize @builder = Builder::XmlMarkup.new(:indent => 2) end
Public Instance Methods
build(points)
click to toggle source
# File lib/gippix.rb, line 56 def build(points) gpx_url = 'http://www.topografix.com/GPX/1/1' gpx_params = { :version => "1.1", :creator => 'Zugunroute Mobile http://zugunroute.com', :'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", :'xmlns' => gpx_url, :'xsi:schemaLocation' => "#{gpx_url} #{gpx_url}/gpx.xsd" } builder.gpx( gpx_params ) { |gpx| gpx.metadata { |meta| meta.name "joe" meta.desc "Mamma" meta.author { |a| a.name "Zugunroute" a.email :id => 'support', :domain => 'zugunroute.com' } meta.copyright(:author => "xforty technologies") { |copy| copy.year "2012" } meta.link(:href => "http://zugunroute.com") { |link| link.text "Zugunroute" link.type "text/html" } meta.time DateTime.now.strftime("%Y-%m-%d-T%H:%M:%SZ") } gpx.trk { |trk| trk.trkseg { |seg| points.each { |ll| seg.trkpt(:lat => ll.lat, :lon => ll.lon) { |pt| pt.ele ll.elevation pt.time DateTime.parse(ll.timestamp) } } } } } end
write_to_tempfile()
click to toggle source
# File lib/gippix.rb, line 97 def write_to_tempfile file = Tempfile.new(['activity','.gpx']) file.puts %Q{<?xml version="1.0" encoding="UTF-8"?>} file.puts builder.target! file.flush file end