otp_get_distance: Finds the distance in metres between supplied origin and...

Description Usage Arguments Value Examples

View source: R/otp_get_distance.R

Description

Finds the distance in metres between supplied origin and destination. Only makes sense for walk, cycle or car modes (not transit)

Usage

1
otp_get_distance(otpcon, fromPlace, toPlace, mode = "CAR")

Arguments

otpcon

An OTP connection object produced by otp_connect.

fromPlace

Numeric vector, Latitude/Longitude pair, e.g. 'c(53.48805, -2.24258)'

toPlace

Numeric vector, Latitude/Longitude pair, e.g. 'c(53.36484, -2.27108)'

mode

Character vector, single mode of travel. Valid values are WALK, BICYCLE, or CAR. Default is CAR.

Value

If OTP has not returned an error then a list containing errorId with the value "OK", and the distance in metres. If OTP has returned an error then a list containing errorId with the OTP error code and errorMessage with the error message returned by OTP. In both cases there will be a third element named query which is a character string containing the URL that was submitted to the OTP API.

Examples

1
2
3
4
5
6
7
## Not run: 
otp_get_distance(otpcon, fromPlace = c(53.48805, -2.24258), toPlace = c(53.36484, -2.27108))

otp_get_distance(otpcon, fromPlace = c(53.48805, -2.24258), toPlace = c(53.36484, -2.27108),
mode = "WALK")

## End(Not run)

otpr documentation built on Jan. 7, 2022, 5:26 p.m.