Note: set CYCLESTREETS_BATCH
and CYCLESTREETS_PW
environment variables, e.g. with usethis::edit_r_environ()
before trying this.
batch(
desire_lines,
directory = tempdir(),
wait_time = NULL,
name = "test batch",
serverId = 21,
strategies = "quietest",
bothDirections = 0,
minDistance = 50,
maxDistance = 5000,
filename = "test",
includeJsonOutput = 1,
emailOnCompletion = "you@example.com",
username = "yourname",
password = Sys.getenv("CYCLESTREETS_PW"),
base_url = "https://api.cyclestreets.net/v2/batchroutes.createjob",
id = NULL,
pat = Sys.getenv("CYCLESTREETS_BATCH"),
silent = TRUE
)
Geographic desire lines representing origin-destination data
Where to save the data? tempdir()
by default
How long to wait before getting the data in seconds?
NULL by default, meaning it will be calculated by the private function
wait_s()
.
The name of the batch routing job for CycleStreets
The server ID to use (21 by default)
Route plan types, e.g. "fastest"
int (1|0) Whether to plan in both directions, i.e. A-B as well as B-A. 0, meaning only one way routes, is the default in the R default.
Min Euclidean distance of routes to be calculated
Maximum Euclidean distance of routes to be calculated
Character string
int (1|0) Whether to include a column in the resulting CSV data giving the full JSON output from the API, rather than just summary information like distance and time.
Email on completion?
string Your CycleStreets account username. In due course this will be replaced with an OAuth token.
string Your CycleStreets account password. You can set it with Sys.setenv(CYCLESTREETS_PW="xxxxxx")
The base url from which to construct API requests (with default set to main server)
int Batch job ID, as returned from batchroutes.createjob. action string (start|pause|continue|terminate) Action to take. Available actions are: start: Start (open) job pause: Pause job continue: Continue (re-open) job terminate: Terminate job and delete data
The API key used. By default this uses Sys.getenv("CYCLESTREETS")
.
Logical (default is FALSE). TRUE hides request sent.
if(FALSE) {
library(sf)
desire_lines = od::od_to_sf(od::od_data_df, od::od_data_zones)[4:5, 1:3]
u = paste0("https://github.com/cyclestreets/cyclestreets-r/",
"releases/download/v0.5.3/od-longford-10-test.Rds")
desire_lines = readRDS(url(u))
routes = batch(desire_lines, username = "robinlovelace")
names(routes)
plot(routes$geometry)
plot(desire_lines$geometry, add = TRUE, col = "red")
routes = batch(desire_lines, username = "robinlovelace", wait_time = 5)
}