Created
September 30, 2019 01:07
Star
You must be signed in to star a gist
/app/classes/map.rb KML LineStrings (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 kml_routes(routes, name) | |
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 content_tag(:Folder) do | |
concat content_tag(:name, name) | |
concat safe_join(routes.map{|r| kml_route(r)}) | |
end | |
end | |
def kml_route(airport_pair) | |
detail = airport_pair.map{|a| @airport_details[a]} | |
return content_tag(:Placemark) do | |
concat content_tag(:name, detail.map{|a| a[:iata]}.join("–")) | |
concat content_tag(:styleUrl, "#flightPath") | |
concat (content_tag(:LineString) do | |
concat content_tag(:tessellate, "1") | |
concat content_tag(:coordinates, detail.map{|a| "#{a[:longitude]},#{a[:latitude]},0"}.join(" ")) | |
end) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment