Skip to content

Instantly share code, notes, and snippets.

@sriyoda
Created February 14, 2016 08:17
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 sriyoda/59a1c7de8e03e9842743 to your computer and use it in GitHub Desktop.
Save sriyoda/59a1c7de8e03e9842743 to your computer and use it in GitHub Desktop.
lat_filtered <- airport$lat[airport$FAA == input$Input1]
lng_filtered <- airport$lng[airport$FAA == input$Input1]
airport <- filter(airport, Country=="United States")
airport <- inner_join(airport, major, by="Name")
for(i in 1:nrow(airport)) {
if(airport$Country[i] == "United States" & airport$FAA[i] != input$Input1) {
route <- gcIntermediate(c(lng_filtered, lat_filtered),
c(airport$lng[i], airport$lat[i]),
n = 200, addStartEnd = TRUE)
route <- as.data.frame(route)
if(!is.null(route))
routes[[length(routes)+1]] <- route
}
}
addRoutes <- function(map, x, ...) {
for(i in 1:length(x)) {
tryCatch(map <- addPolylines(map, lat = x[[i]]$lat, lng = x[[i]]$lon, ...),
error = function(e) map,
finally = map)
}
return(map)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment