Route types will change extraordinarily rarely --- this would require PTV to
add a new route type akin to "train" or "bus". To avoid querying the API too
much, we prefer to use cached values for route type translation wherever
possible. This function effectively wraps route_types
, returning cached
results if possible or caching results otherwise. Note that if a user
specifically calls route_types
then we do not return cached results.
We use the pkg_env
as a cache, which is an environment created on package
load. This is not truly private --- users could still access this as an
internal value. But it's effectively "out of the way".
cached_route_types(
user_id = determine_user_id(),
api_key = determine_api_key()
)
A named integer vector in which the values are the route type descriptions, and the names of the vector are the route type numbers.
Integer or character. A user ID or devid provided by Public
Transport Victoria. Refer to ?ptvapi
for more details.
Character. An API key, with dashes, provided by Public
Transport Victoria. Refer to ?ptvapi
for more details.