UrbanAnalyst / gtfsrouter

Routing and analysis engine for GTFS (General Transit Feed Specification) data
https://urbananalyst.github.io/gtfsrouter/
84 stars 17 forks source link

gtfs_route does not add terminal transfers #72

Closed mpadge closed 3 years ago

mpadge commented 3 years ago

So gives results like this:

library (gtfsrouter)
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$transfers <- readRDS ("vbb-transfers.Rds")
gtfs <- gtfs_timetable(gtfs, day = "tuesday")

from <- "Berlin Hauptbahnhof"
start_time <- 8 * 3600
to <- "Berlin, Elsenstr."
gtfs_route (gtfs, from, to, start_time)
#>    route_name         trip_name                       stop_name arrival_time
#> 1          S5 S Strausberg Nord         S+U Berlin Hauptbahnhof     08:00:30
#> 2          S5 S Strausberg Nord  S+U Friedrichstr. Bhf (Berlin)     08:03:06
#> 3          S5 S Strausberg Nord     S Hackescher Markt (Berlin)     08:05:24
#> 4          S5 S Strausberg Nord S+U Alexanderplatz Bhf (Berlin)     08:07:06
#> 5          S5 S Strausberg Nord    S+U Jannowitzbrücke (Berlin)     08:09:24
#> 6          S5 S Strausberg Nord           S Ostbahnhof (Berlin)     08:11:36
#> 7          S5 S Strausberg Nord    S+U Warschauer Str. (Berlin)     08:14:06
#> 8          S5 S Strausberg Nord         S Ostkreuz Bhf (Berlin)     08:16:24
#> 9         S85          S Grünau         S Ostkreuz Bhf (Berlin)     08:18:00
#> 10        S85          S Grünau       S Treptower Park (Berlin)     08:20:18
#>    departure_time
#> 1        08:01:12
#> 2        08:03:54
#> 3        08:05:54
#> 4        08:07:54
#> 5        08:09:54
#> 6        08:12:24
#> 7        08:14:42
#> 8        08:17:12
#> 9        08:18:36
#> 10       08:20:48

Created on 2021-01-22 by the reprex package (v0.3.0)

The specified to station of "Berlin, Elsenstr." is then connected from Treptower Park by a transfer. These terminal transfer stages need to be appended to the route.

mpadge commented 3 years ago

That commit gives this:

library (gtfsrouter)
packageVersion ("gtfsrouter")
#> [1] '0.0.4.155'
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$transfers <- readRDS ("vbb-transfers.Rds")
gtfs <- gtfs_timetable(gtfs, day = "tuesday")

from <- "Berlin Hauptbahnhof"
start_time <- 8 * 3600
to <- "Berlin, Elsenstr."
gtfs_route (gtfs, from, to, start_time)
#>   route_name                  trip_name                          stop_name
#> 1         S9 Flughafen BER Terminal 1-2            S+U Berlin Hauptbahnhof
#> 2         S9 Flughafen BER Terminal 1-2     S+U Friedrichstr. Bhf (Berlin)
#> 3         S9 Flughafen BER Terminal 1-2        S Hackescher Markt (Berlin)
#> 4         S9 Flughafen BER Terminal 1-2    S+U Alexanderplatz Bhf (Berlin)
#> 5         S9 Flughafen BER Terminal 1-2       S+U Jannowitzbrücke (Berlin)
#> 6         S9 Flughafen BER Terminal 1-2              S Ostbahnhof (Berlin)
#> 7         S9 Flughafen BER Terminal 1-2       S+U Warschauer Str. (Berlin)
#> 8         S9 Flughafen BER Terminal 1-2          S Treptower Park (Berlin)
#> 9       <NA>                 (transfer) Berlin, Elsenstr./S Treptower Park
#>   arrival_time departure_time
#> 1     08:05:00       08:05:42
#> 2     08:07:36       08:08:24
#> 3     08:09:54       08:10:24
#> 4     08:11:36       08:12:24
#> 5     08:13:54       08:14:24
#> 6     08:16:06       08:17:24
#> 7     08:19:06       08:19:42
#> 8     08:22:12       08:23:12
#> 9     08:24:20           <NA>

Created on 2021-01-22 by the reprex package (v0.3.0)