gh_get_routes: Get multiple routes

Description Usage Arguments Examples

View source: R/get-multiple-routes.R

Description

Internally it just calls gh_get_route sevaral times. See also gh_get_spt.

Usage

1
gh_get_routes(x, y, ..., callback = NULL)

Arguments

x

A single start point as (lat, lon) pair

y

A matrix or a data frame containing columns with latitudes and longitudes that are used as endpoints. Needs (lat, lon) order.

...

Parameters that are passed to gh_get_route.

callback

A callback function that is applied to every calculated route.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
if (FALSE) {
  start_point <- c(52.519772, 13.392334)

  end_points <- rbind(
    c(52.564665, 13.42083),
    c(52.564456, 13.342724),
    c(52.489261, 13.324871),
    c(52.48738, 13.454647)
  )

  time_distance_table <- gh_get_routes(
    start_point, end_points, calc_points = FALSE,
    callback = gh_time_distance
  ) %>%
    dplyr::bind_rows()

  routes_sf <- gh_get_routes(start_point, end_points, callback = gh_as_sf) %>%
    do.call(rbind, .)
}

Example output



graphhopper documentation built on Feb. 6, 2021, 5:05 p.m.