Description Usage Arguments Details Value Examples
View source: R/otp_get_times.R
In its simplest use case the function returns the time in minutes between an origin
and destination by the specified mode(s) for the top itinerary returned by OTP. If
detail
is set to TRUE one or more detailed trip itineraries are returned,
including the time by each mode (if a multimodal trip), waiting time and the
number of transfers. Optionally, the details of each journey leg for each itinerary
can also be returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | otp_get_times(
otpcon,
fromPlace,
toPlace,
mode = "CAR",
date = format(Sys.Date(), "%m-%d-%Y"),
time = format(Sys.time(), "%H:%M:%S"),
maxWalkDistance = NULL,
walkReluctance = 2,
waitReluctance = 1,
arriveBy = FALSE,
transferPenalty = 0,
minTransferTime = 0,
maxItineraries = 1,
detail = FALSE,
includeLegs = FALSE,
extra.params = list()
)
|
otpcon |
An OTP connection object produced by |
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, mode(s) of travel. Valid values are: WALK, BICYCLE, CAR, TRANSIT, BUS, RAIL, TRAM, SUBWAY OR 'c("TRANSIT", "BICYCLE")'. TRANSIT will use all available transit modes. Default is CAR. WALK mode is automatically added for TRANSIT, BUS, RAIL, TRAM, and SUBWAY. |
date |
Character, must be in the format mm-dd-yyyy. This is the desired date of travel. Only relevant for transit modes. Default is the current system date. |
time |
Character, must be in the format hh:mm:ss.
If |
maxWalkDistance |
Numeric. The maximum distance (in meters) that the user is willing to walk. Default is NULL (the parameter is not passed to the API and the OTP default of unlimited takes effect). This is a soft limit in OTPv1 and is ignored if the mode is WALK only. In OTPv2 this parameter imposes a hard limit on WALK, CAR and BICYCLE modes (see: http://docs.opentripplanner.org/en/latest/OTP2-MigrationGuide/#router-config). |
walkReluctance |
A single numeric value. A multiplier for how bad walking is compared to being in transit for equal lengths of time. Default = 2. |
waitReluctance |
A single numeric value. A multiplier for how bad waiting for a
transit vehicle is compared to being on a transit vehicle. This should be greater
than 1 and less than |
arriveBy |
Logical. Whether a trip should depart (FALSE) or arrive (TRUE) at the specified date and time. Default is FALSE. |
transferPenalty |
Integer. An additional penalty added to boardings after the first. The value is in OTP's internal weight units, which are roughly equivalent to seconds. Set this to a high value to discourage transfers. Default is 0. |
minTransferTime |
Integer. The minimum time, in seconds, between successive trips on different vehicles. This is designed to allow for imperfect schedule adherence. This is a minimum; transfers over longer distances might use a longer time. Default is 0. |
maxItineraries |
Integer. Controls the number of trip itineraries that
are returned when |
detail |
Logical. When set to FALSE a single trip time is returned.
When set to TRUE one or more detailed trip itineraries are returned (dependent on |
includeLegs |
Logical. Determines whether or not details of each
journey leg are returned. If TRUE then a nested dataframe of journeys legs will be returned
for each itinerary if |
extra.params |
A list of any other parameters accepted by the OTP API PlannerResource entry point. For advanced users. Be aware that otpr will carry out no validation of these additional parameters. They will be passed directly to the API. |
If you plan to use the function in simple-mode - where just the duration of the top itinerary is returned - it is advisable to first review several detailed itineraries to ensure that the parameters you have set are producing sensible results.
If requested using includeLegs
, the itineraries dataframe will contain a column called 'legs'
which has a nested legs dataframe for each itinerary. Each legs dataframe will contain
a set of core columns that are consistent across all queries. However, as the OTP
API does not consistently return the same attributes for legs, there will be some variation
in columns returned. You should bare this in mind if your post processing
uses these columns (e.g. by checking for column existence).
Returns a list of three or four elements. The first element in the list is errorId
.
This is "OK" if OTP has not returned an error. Otherwise it is the OTP error code. The second element of list
varies:
If OTP has returned an error then errorMessage
contains the OTP error message.
If there is no error and detail
is FALSE then the duration
in minutes is
returned as an integer. This is the duration of the top itinerary returned by the OTP server.
If there is no error and detail
is TRUE then itineraries
as a dataframe.
The third element of the list is query
. This is a character string containing the URL
that was submitted to the OTP API.
1 2 3 4 5 6 7 8 9 10 | ## Not run:
otp_get_times(otpcon, fromPlace = c(53.48805, -2.24258), toPlace = c(53.36484, -2.27108))
otp_get_times(otpcon, fromPlace = c(53.48805, -2.24258), toPlace = c(53.36484, -2.27108),
mode = "BUS", date = "03-26-2019", time = "08:00:00")
otp_get_times(otpcon, fromPlace = c(53.48805, -2.24258), toPlace = c(53.36484, -2.27108),
mode = "BUS", date = "03-26-2019", time = "08:00:00", detail = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.