Last active
January 3, 2016 01:19
-
-
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
This file contains 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
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