Created
April 9, 2015 19:06
-
-
Save jshiell/e8405fe9d27b58afcb2b to your computer and use it in GitHub Desktop.
A quick & dirty script to annotate GPX with fake time data, so you can import it into Strava.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rexml/document' | |
require 'rexml/element' | |
doc = REXML::Document.new(File.open('London_Classic_2015.gpx', 'r')) | |
second = 0 | |
min = 0 | |
hour = 1 | |
doc.elements.each('//trkpt') do |point| | |
time = REXML::Element.new('time') | |
time.text = "2013-05-11T%s:%s:%sZ" % [hour.to_s.rjust(2, "0"), min.to_s.rjust(2, "0"), second.to_s.rjust(2, "0")] | |
second += 1 | |
if second > 59 | |
second = 0 | |
min += 1 | |
end | |
if min > 59 | |
min = 0 | |
hour += 1 | |
end | |
point.add time | |
end | |
doc.write(File.open('out.gpx', 'w'), 2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't work!