Skip to content

Instantly share code, notes, and snippets.

@miguelrios
Forked from anonymous/recons.rb
Created September 5, 2017 05:38
Show Gist options
  • Save miguelrios/d3bc80cab7c9013540f2b74d49e70346 to your computer and use it in GitHub Desktop.
Save miguelrios/d3bc80cab7c9013540f2b74d49e70346 to your computer and use it in GitHub Desktop.
Read latest vortex reads for Hurricane Irma
#!/opt/twitter/rvm/rubies/ruby-2.1.5/bin/ruby
require 'nokogiri'
require 'zip'
require 'open-uri'
parent_urls = "http://tropicalatlantic.com/recon/google_earth/listings_for_network_links/North_Atlantic.kml"
parent_doc = Nokogiri::XML(open(parent_urls))
urls = parent_doc.css("href").map do |i| i.text end
readings = urls.map do |url|
Zip::InputStream.open(open(url)) do |io|
while (entry = io.get_next_entry)
if(entry.name == "map.kml")
c = io.read
end
end
doc = Nokogiri::XML(c)
f = doc.css("Folder").select do |item| item.css("> name:contains('Vortex Messages')").size > 0 end
readings = f.flatten.first.css("Folder").map do |item| [item.css("name").text, [item.css("longitude").text, item.css("latitude").text]] end
[url, readings]
end
end
readings.each do |reading|
puts "READINGS FOR MISSION: " + reading[0]
reading[1].sort do |a,b| b[0] <=> a[0] end.each do |r|
puts " -- OBSERVATION: " + r[0]
puts " -- COORDINATES: "
puts " ---- LONGITUDE: " + r[1][0].to_s
puts " ---- LATITUDE: " + r[1][1].to_s
puts "--------------------------------"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment