Closed AlexandraKapp closed 3 years ago
Thanks @AlexandraKapp, you were right that those weren't being excluded. This is now the result, using what I think is the same feed, taken from here. Before this fix I saw the same result you pasted above, and with the above commit now see this:
library (gtfsrouter)
packageVersion ("gtfsrouter")
#>[1] '0.0.4.177'
gtfs <- extract_gtfs("stuttgart.zip")
#> ▶ Unzipping GTFS archive
#> Warning in utils::unzip(filename, exdir = tempdir()): error -1 in extracting
#> from zip file
#> ✔ Unzipped GTFS archive
#> ▶ Extracting GTFS feed
#> Warning in data.table::fread(flist[f], integer64 = "character",
#> showProgress = FALSE, : Discarded single-line footer: <<"51.T0.80-627-
#> j21-1.20.R","14:42:00","14:42:00","de:08115:4761:1:3","2","","0>>
#> ✔ Extracted GTFS feed
#> ▶ Converting stop times to seconds✔ Converted stop times to seconds
#> ▶ Converting transfer times to seconds✔ Converted transfer times to seconds
ttable <- gtfs_timetable(gtfs, day = "tuesday")
gtfs_route(ttable, "Rohr Bf", "Metzstr", start_time = 8*3600)
#> route_name trip_name stop_name arrival_time
#> 1 81 Büsnauer Platz Rohr Bf 08:03:00
#> 2 81 Büsnauer Platz Rohr Mitte 08:04:00
#> 3 81 Büsnauer Platz Hegel-Gymnasium 08:06:00
#> 4 81 Büsnauer Platz Waldburgstraße 08:07:00
#> 5 81 Büsnauer Platz Vaihingen ZOB 08:08:00
#> 6 81 Büsnauer Platz Fanny-Leicht-Straße 08:10:00
#> 7 U3 Vaihingen Bf Jurastraße 08:15:00
#> 8 U3 Vaihingen Bf Vaihingen Bf 08:17:00
#> 9 U1 Fellbach Lutherkirche Vaihingen Bf 08:20:00
#> 10 U1 Fellbach Lutherkirche Vaihingen Schillerplatz 08:21:00
#> 11 U1 Fellbach Lutherkirche Fauststraße 08:22:00
#> 12 U1 Fellbach Lutherkirche Vaihingen Viadukt 08:23:00
#> 13 U1 Fellbach Lutherkirche Engelboldstraße 08:24:00
#> 14 U1 Fellbach Lutherkirche Kaltental 08:25:00
#> 15 U1 Fellbach Lutherkirche Waldeck 08:26:00
#> 16 U1 Fellbach Lutherkirche Heslach Vogelrain 08:28:00
#> 17 U1 Fellbach Lutherkirche Südheimer Platz 08:29:00
#> 18 U1 Fellbach Lutherkirche Bihlplatz 08:31:00
#> 19 U1 Fellbach Lutherkirche Erwin-Schoettle-Platz 08:33:00
#> 20 U1 Fellbach Lutherkirche Marienplatz 08:34:00
#> 21 U1 Fellbach Lutherkirche Österreichischer Platz 08:36:00
#> 22 U1 Fellbach Lutherkirche Rathaus 08:37:00
#> 23 U1 Fellbach Lutherkirche Charlottenplatz 08:39:00
#> 24 U1 Fellbach Lutherkirche Staatsgalerie 08:41:00
#> 25 U1 Fellbach Lutherkirche Neckartor 08:42:00
#> 26 U1 Fellbach Lutherkirche Stöckach 08:43:00
#> 27 U1 Fellbach Lutherkirche Metzstraße 08:45:00
#> departure_time
#> 1 08:04:00
#> 2 08:05:00
#> 3 08:06:00
#> 4 08:07:00
#> 5 08:09:00
#> 6 08:10:00
#> 7 08:15:00
#> 8 08:17:00
#> 9 08:20:00
#> 10 08:21:00
#> 11 08:22:00
#> 12 08:23:00
#> 13 08:24:00
#> 14 08:25:00
#> 15 08:26:00
#> 16 08:28:00
#> 17 08:29:00
#> 18 08:31:00
#> 19 08:33:00
#> 20 08:35:00
#> 21 08:36:00
#> 22 08:38:00
#> 23 08:40:00
#> 24 08:41:00
#> 25 08:42:00
#> 26 08:44:00
#> 27 08:45:00
Created on 2021-02-10 by the reprex package (v1.0.0)
The only difficulty was working out exactly where to filter out the transfer_type == 3
values. I think I've done that in the best place, which is as part of the gtfs_timetable()
call. That is the final function used to transform feeds prior to calling any of the actual routing functions, so should ensure that no matter what is done to the transfer table in the meantime, the filtering will always be applied. Other code is also necessary to check the general sanity of the transfer table, mostly to ensure that transfer_type = 3
values are only ever applied to single unique pairs of stops. The final function is here.
I was wondering, why some travel times (for
gtfs_traveltime
as well asgtfs_route
) are so fast in Stuttgart and then realized, that there are some transfers that do not seem possible. E.g. in the example below to transfer from Hauptbahnhof to Staatsgalerie in 0 minutes. Looking into thetransfers.txt
reveals, that those transfers are actually listed there with 0 min travel time. BUT itstransfer_type = 3
"3 - Transfers are not possible between routes at the location." (https://developers.google.com/transit/gtfs/reference#transferstxt)I assume those transfers are not excluded?
Created on 2021-02-09 by the reprex package (v0.3.0)