View source: R/osrm_contract.R
| osrm_contract | R Documentation |
Run the osrm-contract tool to contract an OSRM graph for the CH pipeline.
After running, a companion <base>.osrm.hsgr file must exist to confirm success.
osrm_contract(
input_osrm,
threads = 8L,
verbosity = c("INFO", "NONE", "ERROR", "WARNING", "DEBUG"),
segment_speed_file = NULL,
turn_penalty_file = NULL,
edge_weight_updates_over_factor = 0,
parse_conditionals_from_now = 0,
time_zone_file = NULL,
quiet = FALSE,
verbose = FALSE,
spinner = TRUE,
echo_cmd = FALSE
)
input_osrm |
A string. Path to a |
threads |
An integer. Number of threads to use; default |
verbosity |
A string. Log verbosity level passed to |
segment_speed_file |
A string or |
turn_penalty_file |
A string or |
edge_weight_updates_over_factor |
A numeric. Threshold for logging large weight updates; default |
parse_conditionals_from_now |
A numeric. UTC timestamp for conditional restrictions; default |
time_zone_file |
A string or |
quiet |
A logical. Master switch that suppresses package messages and
process output when |
verbose |
A logical. When |
spinner |
A logical. When |
echo_cmd |
A logical. When |
An object of class osrm_job with the following elements:
The path to the contracted .osrm.hsgr file.
The directory containing all OSRM files.
The processx::run result object.
if (identical(Sys.getenv("OSRM_EXAMPLES"), "true")) {
install_dir <- osrm_install(
version = "latest",
path_action = "session",
quiet = TRUE
)
# Prepare a small graph then contract it for the CH pipeline
pbf_path <- system.file("extdata/cur.osm.pbf", package = "osrm.backend")
osrm_dir <- file.path(tempdir(), paste0("osrm-", Sys.getpid()))
dir.create(osrm_dir, recursive = TRUE)
tmp_pbf <- file.path(osrm_dir, "cur.osm.pbf")
file.copy(from = pbf_path, to = tmp_pbf, overwrite = TRUE)
profile <- osrm_find_profile("car.lua")
extract_job <- osrm_extract(
input_osm = tmp_pbf,
profile = profile,
overwrite = TRUE,
threads = 1L
)
ch_graph <- osrm_contract(extract_job, threads = 1L, verbose = TRUE)
ch_graph$osrm_job_artifact
osrm_uninstall(
dest_dir = install_dir,
clear_path = TRUE,
force = TRUE,
quiet = TRUE
)
unlink(osrm_dir, recursive = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.