Skip to content

Instantly share code, notes, and snippets.

@imvenj
Created January 6, 2020 16:07
Show Gist options
  • Save imvenj/d6f1a9d9d391bafd7eb9e1fbb1f912dd to your computer and use it in GitHub Desktop.
Save imvenj/d6f1a9d9d391bafd7eb9e1fbb1f912dd to your computer and use it in GitHub Desktop.
#!/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