Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null check for departure_datetime parameter #147

Closed
mattwigway opened this issue Feb 23, 2021 · 2 comments
Closed

Null check for departure_datetime parameter #147

mattwigway opened this issue Feb 23, 2021 · 2 comments

Comments

@mattwigway
Copy link
Contributor

If you feed a NULL departure_datetime parameter to travel_time_matrix, it crashes with the message "java.lang.NullPointerException" and no other details. It would be great to have a null check for this parameter.

@rafapereirabr
Copy link
Member

Thanks for the heads up. As it stands, the routing functions in r5r set departure_datetime = Sys.time() by default. Nonetheles, the functions were throwing an error because the time zone information was missing. I've fixed this so that r5r now considers the user's time zone by default. See reprex below.

As an alternative, the user can set a different time zone using: as.POSIXct("13-05-2019 14:00:00", format = "%d-%m-%Y %H:%M:%S", tz="UTC")

Reprex:

library(r5r)

# build transport network and load origin/destination points
data_path <- system.file("extdata/spo", package = "r5r")
r5r_core <- setup_r5(data_path = data_path)
points <- read.csv(file.path(data_path, "spo_hexgrid.csv"))[1:5,]

ttm <- travel_time_matrix(r5r_core,
                   origins = points,
                   destinations = points,
                   mode = c("WALK"),
                   max_walk_dist = Inf,
                   max_trip_duration = 120L)

@mattwigway
Copy link
Contributor Author

Wouldn't it be better to use the transport network's time zone? Otherwise results from identical code could change depending on where the user is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants