MyNixOS website logo
Description

Wrapper for the 'OSRM' API.

Wrapper around the 'Open Source Routing Machine (OSRM)' API <http://project-osrm.org/>. 'osrmr' works with API versions 4 and 5 and can handle servers that run locally as well as the 'OSRM' webserver.

'osrmr'

'osrmr' is a wrapper around the OSRM API (https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md). 'osrmr' works with API versions 4 and 5 and can handle servers that run locally as well as the osrm webserver.

Installation

You can install 'osrmr' from CRAN or github with:

install.packages("osrmr")

# install.packages("devtools")
devtools::install_github("ims-fhs/osrmr")

Examples

Access the OSRM with R using the onlinehost (webserver) of OSRM to:

  • generate coordinates from given coordinates, which are accessible by car with nearest()
  • calculate waytimes and more for specific routes from start- to end-destination with viaroute()
  • decode polylines using a polyline-specific precision with decode_geom()
library(osrmr)
nearest(lat = 47, lng = 8, api_version = 5, localhost = FALSE)
#>        lat      lng
#> 1 47.00008 8.003016
viaroute(lat1 = 47.1, lng1 = 8.1, lat2 = 46.9, lng2 = 8.3, instructions = FALSE,
         api_version = 5, localhost = FALSE)
#> [1] 2637.1

encoded_polyline_precision_5 <- rjson::fromJSON(file = "http://router.project-osrm.org/route/v1/driving/8.0997,47.1002;8.101110,47.10430?steps=false&geometries=polyline")$routes[[1]]$geometry
decode_geom(encoded_polyline_precision_5, precision = 5)
#>        lat     lng
#> 1 47.10020 8.09970
#> 2 47.10099 8.09952
#> 3 47.10161 8.10037
#> 4 47.10171 8.10066
#> 5 47.10215 8.10083
#> 6 47.10234 8.10098
#> 7 47.10287 8.10123
#> 8 47.10322 8.10125
#> 9 47.10430 8.10110

Note

  1. In order to use the localhost of OSRM you need a local build on your device. For more Information on the localhost see https://github.com/Project-OSRM/osrm-backend/wiki/Building-OSRM.
  2. When using the localhost it's recommended to set the path of your local build as environment variable.

For more detailed Information about the components of the 'osrmr' package, check out the vignette.

Metadata

Version

0.1.36

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows