ipeaGIT / gtfs2gps

Convert GTFS data into a data.table with GPS-like records in R
https://ipeagit.github.io/gtfs2gps/
Other
69 stars 10 forks source link

More Berlin gtfs2gps function issues #99

Closed ahermanski closed 4 years ago

ahermanski commented 4 years ago

After you made some updates I again dove in to the Berlin gtfs file.

The new filter_day_period function seems to work as intended, and is a welcome addition, sadly though I'm still getting errors.

berlin <- read_gtfs("berlin.zip")

berlin <- filter_valid_stop_times(berlin)

berlin_s <- filter_by_agency_id(berlin, 1)

berlin_5 <- filter_day_period(berlin_s, period_start = "04:00", period_end = "05:00")

berlin_gps <- gtfs2gps(berlin_5, progress = TRUE, spatial_resolution = 150)

22.
stop(err$message, call. = FALSE)
21.
.checkTypos(e, names_x)
20.
value[[3L]](cond)
19.
tryCatchOne(expr, names, parentenv, handlers[[1L]])
18.
tryCatchList(expr, classes, parentenv, handlers)
17.
tryCatch(eval(.massagei(isub), x, ienv), error = function(e) .checkTypos(e, names_x))
16.
`[.data.table`(new_stoptimes, a:b, `:=`(speed, 3.6 * (data.table::last(cumdist) - data.table::first(cumdist))/(data.table::last(departure_time) - data.table::first(departure_time))))
15.
new_stoptimes[a:b, `:=`(speed, 3.6 * (data.table::last(cumdist) - data.table::first(cumdist))/(data.table::last(departure_time) - data.table::first(departure_time)))]
14.
FUN(X[[i]], ...)
13.
lapply(X = 1:(L - 1), FUN = update_speeds)
12.
FUN(X[[i]], ...)
11.
lapply(X = all_tripids, FUN = update_dt, new_stoptimes, gtfs_data, all_tripids)
10.
eval(lhs, parent, parent)
9.
eval(lhs, parent, parent)
8.
lapply(X = all_tripids, FUN = update_dt, new_stoptimes, gtfs_data, all_tripids) %>% data.table::rbindlist()
7.
FUN(X[[i]], ...)
6.
lapply(X[Split[[i]]], FUN, ...)
5.
pbapply::pblapply(X = all_shapeids, FUN = corefun)
4.
eval(lhs, parent, parent)
3.
eval(lhs, parent, parent)
2.
pbapply::pblapply(X = all_shapeids, FUN = corefun) %>% data.table::rbindlist()
1.
gtfs2gps(berlin_5, progress = TRUE, spatial_resolution = 150)

Changing filter_day_period(berlin_s, period_start = "04:00", period_end = "05:00") to filter_day_period(berlin_s, period_start = "03:00", period_end = "04:00") leads to no error messages, sadly though I can't tell you why that is.

pedro-andrade-inpe commented 4 years ago

@ahermanski, thanks for your feedback. I've just opened a Pull Request fixing this problem. It was related with trips that start before the starting time or stop after the ending time from filter_day_period(). As soon as it is ok it will be merged into the master and you will be able to use it. Additionally, you can already install it from my fork (https://github.com/pedro-andrade-inpe/gtfs2gps). Any additional feedback will be welcomed!

ahermanski commented 4 years ago

I'm sad to report that I'm still getting the same error. This time it's for a different time period and agency. The initial code now works fine.

berlin_w <- gtfs2gps::filter_week_days(berlin)

berlin_w <- gtfs2gps::filter_by_agency_id(berlin_w, 796)

berlin_w <- gtfs2gps::filter_valid_stop_times(berlin_w)

berlin_w <- filter_day_period(berlin_w, period_start = "12:00", period_end = "13:00")

berlin_gps_w <- gtfs2gps(berlin_w, progress = TRUE, spatial_resolution = 250)

22.
stop(err$message, call. = FALSE)
21.
.checkTypos(e, names_x)
20.
value[[3L]](cond)
19.
tryCatchOne(expr, names, parentenv, handlers[[1L]])
18.
tryCatchList(expr, classes, parentenv, handlers)
17.
tryCatch(eval(.massagei(isub), x, ienv), error = function(e) .checkTypos(e, names_x))
16.
`[.data.table`(new_stoptimes, a:b, `:=`(speed, 3.6 * (data.table::last(cumdist) - data.table::first(cumdist))/(data.table::last(departure_time) - data.table::first(departure_time))))
15.
new_stoptimes[a:b, `:=`(speed, 3.6 * (data.table::last(cumdist) - data.table::first(cumdist))/(data.table::last(departure_time) - data.table::first(departure_time)))]
14.
FUN(X[[i]], ...)
13.
lapply(X = 1:(L - 1), FUN = update_speeds)
12.
FUN(X[[i]], ...)
11.
lapply(X = all_tripids, FUN = update_dt, new_stoptimes, gtfs_data, all_tripids)
10.
eval(lhs, parent, parent)
9.
eval(lhs, parent, parent)
8.
lapply(X = all_tripids, FUN = update_dt, new_stoptimes, gtfs_data, all_tripids) %>% data.table::rbindlist()
7.
FUN(X[[i]], ...)
6.
lapply(X[Split[[i]]], FUN, ...)
5.
pbapply::pblapply(X = all_shapeids, FUN = corefun)
4.
eval(lhs, parent, parent)
3.
eval(lhs, parent, parent)
2.
pbapply::pblapply(X = all_shapeids, FUN = corefun) %>% data.table::rbindlist()
1.
gtfs2gps(berlin_w, progress = TRUE, spatial_resolution = 250)
pedro-andrade-inpe commented 4 years ago

Dear @ahermanski, please test now with the newest gtfs2gps and R 3.6.3 (and updated packages) and tell me if the problem was fixed.

pedro-andrade-inpe commented 4 years ago

Both scripts above run properly using the newest version 1.1-0.

ahermanski commented 4 years ago

Dear @ahermanski, please test now with the newest gtfs2gps and R 3.6.3 (and updated packages) and tell me if the problem was fixed.

Sorry for not getting back to you, I must've missed the notification mail from GitHub. Thanks for fixing the issue.