if (FALSE) {
locationsDF <- data.frame(
id = c('London center', 'Hyde Park', 'ZSL London Zoo'),
lat = c(51.508930, 51.508824, 51.536067),
lng = c(-0.131387, -0.167093, -0.153596)
)
locations <- apply(locationsDF, 1, function(x)
make_location(id = x['id'], coords = list(lat = as.numeric(x["lat"]),
lng = as.numeric(x["lng"]))))
locations <- unlist(locations, recursive = FALSE)
departure_search <-
make_search(id = "forward search example",
departure_location_id = "London center",
arrival_location_ids = list("Hyde Park", "ZSL London Zoo"),
departure_time = strftime(as.POSIXlt(Sys.time(), "UTC"), "%Y-%m-%dT%H:%M:%SZ"),
travel_time = 1800,
transportation = list(type = "bus"),
properties = list('travel_time'),
range = list(enabled = TRUE, width = 600, max_results = 3))
arrival_search <-
make_search(id = "backward search example",
arrival_location_id = "London center",
departure_location_ids = list("Hyde Park", "ZSL London Zoo"),
arrival_time = strftime(as.POSIXlt(Sys.time(), "UTC"), "%Y-%m-%dT%H:%M:%SZ"),
travel_time = 1800,
transportation = list(type = "public_transport"),
properties = list('travel_time', "distance", "distance_breakdown", "fares"),
range = list(enabled = TRUE, width = 600, max_results = 3))
result <-
time_filter(
departure_searches = departure_search,
arrival_searches = arrival_search,
locations = locations
)
}
Run the code above in your browser using DataLab