View source: R/osrm_prepare_graph.R
| osrm_prepare_graph | R Documentation |
High-level wrapper that first runs osrm-extract on an OSM file
to produce the base .osrm graph, then prepares it for routing via
either the MLD pipeline (osrm-partition + osrm-customize) or the CH pipeline (osrm-contract).
osrm_prepare_graph(
input_osm,
profile = osrm_find_profile("car.lua"),
threads = 8L,
overwrite = FALSE,
verbosity = c("INFO", "NONE", "ERROR", "WARNING", "DEBUG"),
data_version = NULL,
small_component_size = 1000L,
with_osm_metadata = FALSE,
parse_conditional_restrictions = FALSE,
location_dependent_data = NULL,
disable_location_cache = FALSE,
dump_nbg_graph = FALSE,
algorithm = c("mld", "ch"),
balance = 1.2,
boundary = 0.25,
optimizing_cuts = 10L,
max_cell_sizes = c(128, 4096, 65536, 2097152),
quiet = FALSE,
verbose = FALSE,
spinner = TRUE,
echo_cmd = FALSE
)
input_osm |
A string. Path to the input OSM file ( |
profile |
A string. Path to the OSRM Lua profile (e.g. returned by |
threads |
An integer. Number of threads for extract and partition/contract; default |
overwrite |
A logical. If |
verbosity |
A string. Log verbosity for extract/partition/contract
(one of |
data_version |
A string or |
small_component_size |
An integer. For extract & partition; default |
with_osm_metadata |
A logical. Adds |
parse_conditional_restrictions |
A logical. Adds |
location_dependent_data |
A string or |
disable_location_cache |
A logical. Adds |
dump_nbg_graph |
A logical. Adds |
algorithm |
A string. One of |
balance |
A numeric. Balance for |
boundary |
A numeric. Boundary percentage for |
optimizing_cuts |
An integer. Optimizing cuts for |
max_cell_sizes |
A numeric vector. Max cell sizes for |
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 final routing-ready graph file (.osrm.hsgr for CH or .osrm.mldgr for MLD).
The directory containing all OSRM files.
A list of processx::run results for each stage:
extract, partition/contract, and customize (if MLD).
if (identical(Sys.getenv("OSRM_EXAMPLES"), "true")) {
install_dir <- osrm_install(
version = "latest",
path_action = "session",
quiet = TRUE
)
# Prepare a routing-ready graph with the default MLD 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)
graph <- osrm_prepare_graph(
input_osm = tmp_pbf,
overwrite = TRUE,
threads = 1L,
algorithm = "mld"
)
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.