gtfs2gps function changing input parameter by reference
Joaobazzo opened this issue · 1 comments
Joaobazzo commented
gtfs2gps::gtfs2gps()
is changing the arrival_time
and departure_time
by
reference, which then changes the input file
See reprex below
gtfs_file <- system.file("extdata/poa.zip", package = "gtfs2gps")
gtfs <- gtfstools::read_gtfs(gtfs_file)
gtfs_small <- gtfstools::filter_by_trip_id(gtfs, trip_id ="T2-1@1#520")
Check class()
before
str(gtfs_small$stop_times[,c("arrival_time","departure_time")])
#> Classes 'data.table' and 'data.frame': 62 obs. of 2 variables:
#> $ arrival_time : chr "05:20:00" "" "" "" ...
#> $ departure_time: chr "05:20:00" "" "" "" ...
#> - attr(*, ".internal.selfref")=<externalptr>
Apply function
a <- gtfs2gps::gtfs2gps(gtfs_small)
#> Converting shapes to sf objects
#> Using 3 CPU cores
#> Processing the data
#> 9 'speed' values are NA for shape_id 'T2-1'.
#> Some 'speed' values are NA in the returned data.
Check class()
after
str(gtfs_small$stop_times[,c("arrival_time","departure_time")])
#> Classes 'data.table' and 'data.frame': 62 obs. of 2 variables:
#> $ arrival_time : int 19200 NA NA NA NA NA NA NA NA NA ...
#> $ departure_time: int 19200 NA NA NA NA NA NA NA NA NA ...
#> - attr(*, ".internal.selfref")=<externalptr>
Notice that the function does note work anymore
when the gtfs_small
is applied again
a <- gtfs2gps::gtfs2gps(gtfs_small)
#> Error in string_to_seconds(departure_time): Assertion on 'string' failed: Must be of type 'character', not 'integer'.
Created on 2022-07-01 by the reprex package (v2.0.1)
rafapereirabr commented
Fixed with a37b34d