Closed AlexandraKapp closed 3 years ago
The function now returns start times as well (from idea in #75), which gives these results:
library (gtfsrouter)
packageVersion ("gtfsrouter")
#> [1] '0.0.4.178'
gtfs <- extract_gtfs("vbb.zip")
#> ▶ Unzipping GTFS archive
#> ✔ Unzipped GTFS archive
#> ▶ Extracting GTFS feed✔ Extracted GTFS feed
#> ▶ Converting stop times to seconds✔ Converted stop times to seconds
#> ▶ Converting transfer times to seconds✔ Converted transfer times to seconds
gtfs <- gtfs_timetable(gtfs, day = "tuesday")
from <- "Berlin Hauptbahnhof"
#to <- "S+U Gesundbrunnen Bhf (Berlin)"
to <- c ("060007102724", "000008011102")
iso0 <- gtfs_traveltimes (gtfs, from = from, start_time = 8 * 3600)
iso0 [iso0$stop_id %in% to, ]
#> start_time duration ntransfers stop_id
#> 13724 08:09:00 00:12:42 1 060007102724
#> 19367 08:09:00 00:17:42 2 000008011102
#> stop_name stop_lon stop_lat
#> 13724 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
#> 19367 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
iso1 <- gtfs_traveltimes (gtfs, from = from, start_time = 8 * 3600 + 5 * 60)
iso1 [iso1$stop_id %in% to, ]
#> start_time duration ntransfers stop_id
#> 13724 08:09:00 00:09:42 1 060007102724
#> 19367 08:09:00 00:14:42 2 000008011102
#> stop_name stop_lon stop_lat
#> 13724 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
#> 19367 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
iso2 <- gtfs_traveltimes (gtfs, from = from, start_time = 8 * 3600 + 15 * 60)
iso2 [iso2$stop_id %in% to, ]
#> start_time duration ntransfers stop_id
#> 13724 08:27:00 00:08:00 1 060007102724
#> 19367 08:27:00 00:03:00 0 000008011102
#> stop_name stop_lon stop_lat
#> 13724 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
#> 19367 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
Created on 2021-02-12 by the reprex package (v1.0.0)
I'll report back on further reasons why these differences might actually arise.
I think that has resolved the major problem, which was related to transfers. Normal connections could be joined if they arrived at an arrival station prior to the listed departure time of a given timetable line, but that check was not implemented in the same way for transfers, which meant that some transfers were being connected which transferred to a departure station at a later time than the listed departure. That's now fixed and gives this for the first two of the above results:
library (gtfsrouter)
packageVersion ("gtfsrouter")
#> [1] '0.0.4.184'
gtfs <- extract_gtfs("vbb.zip")
#> ▶ Unzipping GTFS archive
#> ✔ Unzipped GTFS archive
#> ▶ Extracting GTFS feed✔ Extracted GTFS feed
#> ▶ Converting stop times to seconds✔ Converted stop times to seconds
#> ▶ Converting transfer times to seconds✔ Converted transfer times to seconds
gtfs <- gtfs_timetable(gtfs, day = "tuesday")
from <- "Berlin Hauptbahnhof"
#to <- "S+U Gesundbrunnen Bhf (Berlin)"
to <- c ("060007102724", "000008011102")
iso0 <- gtfs_traveltimes (gtfs, from = from, start_time = 8 * 3600)
iso0 [iso0$stop_id %in% to, ]
#> start_time duration ntransfers stop_id
#> 13724 08:09:00 00:12:42 1 060007102724
#> 19367 08:09:00 00:17:42 2 000008011102
#> stop_name stop_lon stop_lat
#> 13724 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
#> 19367 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
iso1 <- gtfs_traveltimes (gtfs, from = from, start_time = 8 * 3600 + 5 * 60)
iso1 [iso1$stop_id %in% to, ]
#> start_time duration ntransfers stop_id
#> 13724 08:09:00 00:12:42 1 060007102724
#> 19367 08:09:00 00:17:42 2 000008011102
#> stop_name stop_lon stop_lat
#> 13724 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
#> 19367 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
The final one is still different, so I'll re-open again until that has been resolved:
iso2 <- gtfs_traveltimes (gtfs, from = from, start_time = 8 * 3600 + 15 * 60)
iso2 [iso2$stop_id %in% to, ]
#> start_time duration ntransfers stop_id
#> 13724 08:27:00 00:08:00 1 060007102724
#> 19367 08:27:00 00:03:00 0 000008011102
#> stop_name stop_lon stop_lat
#> 13724 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
#> 19367 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
Created on 2021-03-03 by the reprex package (v1.0.0)
There we go:
library (gtfsrouter)
packageVersion ("gtfsrouter")
#> [1] '0.0.4.186'
gtfs <- extract_gtfs("vbb.zip")
#> ▶ Unzipping GTFS archive
#> ✔ Unzipped GTFS archive
#> ▶ Extracting GTFS feed✔ Extracted GTFS feed
#> ▶ Converting stop times to seconds✔ Converted stop times to seconds
#> ▶ Converting transfer times to seconds✔ Converted transfer times to seconds
gtfs <- gtfs_timetable(gtfs, day = "tuesday")
from <- "Berlin Hauptbahnhof"
#to <- "S+U Gesundbrunnen Bhf (Berlin)"
to <- c ("060007102724", "000008011102")
iso0 <- gtfs_traveltimes (gtfs, from = from, start_time = 8 * 3600)
iso0 [iso0$stop_id %in% to, ]
#> start_time duration ntransfers stop_id
#> 13724 08:09:00 00:12:42 1 060007102724
#> 19367 08:27:00 00:03:00 0 000008011102
#> stop_name stop_lon stop_lat
#> 13724 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
#> 19367 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
iso1 <- gtfs_traveltimes (gtfs, from = from, start_time = 8 * 3600 + 5 * 60)
iso1 [iso1$stop_id %in% to, ]
#> start_time duration ntransfers stop_id
#> 13724 08:09:00 00:12:42 1 060007102724
#> 19367 08:27:00 00:03:00 0 000008011102
#> stop_name stop_lon stop_lat
#> 13724 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
#> 19367 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
iso2 <- gtfs_traveltimes (gtfs, from = from, start_time = 8 * 3600 + 15 * 60)
iso2 [iso2$stop_id %in% to, ]
#> start_time duration ntransfers stop_id
#> 13724 08:19:00 00:12:42 1 060007102724
#> 19367 08:27:00 00:03:00 0 000008011102
#> stop_name stop_lon stop_lat
#> 13724 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
#> 19367 S+U Gesundbrunnen Bhf (Berlin) 13.38837 52.54864
Created on 2021-03-03 by the reprex package (v1.0.0)
How far is the timetable searched to find the best route?
with this example, Hbf - Gesundbrunnen setting start_time to 8:00, 8:05 or 8:15, when does it stop searching the timetable for better connections? The RE that takes 3min leaves at 8:32 just to understand, why the 8:15 query finds the RE even though there are also earlier connections and the 8:00 does not find the RE even though its the fastest connection (but of course half an hour later)
Created on 2021-02-11 by the reprex package (v0.3.0)