Created
September 30, 2019 01:02
-
-
Save bogardpd/f491e84de5c090563e05da1c9939c828 to your computer and use it in GitHub Desktop.
/app/classes/map.rb Routes
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
#/app/classes/map.rb | |
def gpx_routes(routes) | |
return nil unless routes.any? | |
routes = routes.map{|r| r.sort_by{|x| @airport_details[x][:iata]}}.uniq.sort_by{|y| [@airport_details[y[0]][:iata], @airport_details[y[1]][:iata]]} | |
return safe_join(routes.map{|r| gpx_route(r)}) | |
end | |
def gpx_route(airport_pair) | |
detail = airport_pair.map{|a| @airport_details[a]} | |
return content_tag(:rte) do | |
concat content_tag(:name, detail.map{|a| a[:iata]}.join("–")) | |
concat content_tag(:desc, detail.map{|a| a[:city]}.join(" – ")) | |
concat content_tag(:link, nil, href: "https://www.flighthistorian.com/routes/#{detail[0][:iata]}-#{detail[1][:iata]}") | |
concat safe_join(airport_pair.map{|a| gpx_airport(a, :rtept)}) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment