#!/usr/bin/env ruby # # Created by sjavey on 2007-07-10. # Copyright (c) 2007. All rights reserved. # # To run this program you must add /full-path.../note19/trunk to your RUBYLIB # environment variable. # require 'n19gpx/document' class ElevationChart attr_reader :elevation_time attr_reader :gpx def initialize(gpxfile) @gpx = N19GPX::Document.new(gpxfile) @index = -1 @counter = -1 @elevation_time = "" end def addPoint(point) @elevation_time << "{ x: #{point.pst_hour_minute} , y: #{point.ele} },\n" end def trackHtml(track) track.points.each { |point| addPoint(point) } end def html @htmlHeader = < note19 Scripts #{elevationChart()}
EOS end def tracksHtml @gpx.tracks.each {|track| trackHtml(track) } end def timeLabel min = @gpx.to_hour_min(@gpx.start_time) max = @gpx.to_hour_min(@gpx.end_time) i = min s = "" while (i < max) s << sprintf("%.2f", i) << "," i = i + 0.5 end return s << sprintf("%.2f",max) end def elevationChart tracksHtml str = <djConfig={isDebug:true} EOS end end # test the googlemap generation track = "21-oct-2007" gmap = ElevationChart.new(track + ".gpx") file = File.new(track + "-elevation.html", "w") file.puts gmap.html() #puts gmap.elevation_time[0..gmap.elevation_time.length-3] file.close