Skip to content

Instantly share code, notes, and snippets.

@bogardpd
Created September 30, 2019 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogardpd/f491e84de5c090563e05da1c9939c828 to your computer and use it in GitHub Desktop.
Save bogardpd/f491e84de5c090563e05da1c9939c828 to your computer and use it in GitHub Desktop.
/app/classes/map.rb Routes
#/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