Skip to content

Instantly share code, notes, and snippets.

@shostakovich
Last active January 3, 2016 01:19
Show Gist options
  • Save shostakovich/8388387 to your computer and use it in GitHub Desktop.
Save shostakovich/8388387 to your computer and use it in GitHub Desktop.
Dirty Little Tools to convert data from my Garmin into a Google Maps Compatible CSV
def minimum_distance(a, b)
((a[0] - b[0]).abs > 0.1) || ((a[1] - b[1]).abs > 0.1)
end
last_coordinate = [0,0]
txt = File.read("/Users/shostakovich/data.txt")
puts "lat,lon,Name"
txt.scan(/lat="([^"]*)"lon="([^"]*)">/) do |coordinate|
coordinate[0] = coordinate[0].to_f
coordinate[1] = coordinate[1].to_f
next unless minimum_distance(coordinate, last_coordinate)
puts "#{coordinate[0]},#{coordinate[1]},"
last_coordinate = coordinate
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment