viaroute: Query OSRM service and return json string result

Description Usage Arguments Details See Also Examples

View source: R/osrmfunctions.R

Description

Query OSRM service and return json string result

Usage

1
2
3
4
5
viaroute(startlat = NULL, startlng = NULL, endlat = NULL,
  endlng = NULL, viapoints = NULL, api = 5, profile = "driving",
  protocol = "v1", osrmurl = "http://router.project-osrm.org",
  zoom = 18, instructions = TRUE, alt = TRUE, geometry = TRUE,
  uturns = "default")

Arguments

startlat

A single value or vector containing latitude(s) of the start of routes.

startlng

A single value or vector containing longitude(s) of the end of routes.

endlat

A single value or vector containing latitude(s) of the end of routes.

endlng

A single value or vector containing longitude(s) of the end of routes.

viapoints

A list of dataframes containing latitude (first column), longitude (second) column for points to use for each route. Optionally a third column containing a boolean value indicating if u-turns are allowed at each viapoint.

api

An integer value containing the OSRM API version (either 4 or 5). Default is 5.

profile

OSRM profile to use (for API v5), defaults to "driving".

protocol

The protocol to use for the API (for v5), defaults to "v1".

osrmurl

URL for OSRM sservice, e.g. an osrm instance running on localhost. By default this is "http://router.project-osrm.org".

zoom

Zoom level for route geometry (0 to 18) for API v4 (default = 18). Higher values are more detailed.

instructions

Boolean value to return instructions (default = TRUE).

alt

Boolean value to return alternative routes (default = TRUE).

geometry

Boolean value to return route geometries (default = TRUE).

uturns

Boolean value to allow uturns at via points (default = TRUE).

Details

Constructs the query URL used with the OSRM HTTP API and returns a string or vector of strings with the json-encoded results. Can be used in conjunction with the viaroute2sldf function.

See also https://cran.r-project.org/web/packages/osrm/index.html

See Also

Other routes: line2routeRetry, line2route, nearest2spdf, route_cyclestreet, route_dodgr, route_graphhopper, route_local, route_osrm, route_transportapi_public, route, viaroute2sldf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
exroutes <- viaroute(50, 0, 51, 1)
r <- viaroute2sldf(exroutes)
plot(r)
lngs <- c(-33.5, -33.6, -33.7)
lats <- c(150, 150.1, 150.2)
exroutes <- viaroute(viapoints = list(data.frame(x = lngs, y = lats)))
r <- viaroute2sldf(exroutes)
plot(r)

## End(Not run)

stplanr documentation built on March 23, 2019, 1:05 a.m.