Created
January 6, 2020 16:07
-
-
Save imvenj/d6f1a9d9d391bafd7eb9e1fbb1f912dd to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# Generate json for iGolf 2 location simulation. | |
require 'nokogiri' | |
require 'json' | |
doc = Nokogiri::XML(open(ARGV[0])) | |
coordinates = doc.css('coordinates').text.strip.split(/\s+/).map { |s| s.split(',') } | |
arr = [] | |
coordinates.each_with_index do |coord, index| | |
# next if index % 10 != 0 | |
p = { latitude: coord[1].to_f, longitude: coord[0].to_f } | |
arr << p | |
end | |
data = { data: arr } | |
puts data.to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment