Closed mpadge closed 4 years ago
From tests/testthat/test-route.R
:
library(gtfsrouter)
berlin_gtfs_to_zip ()
f <- file.path (tempdir (), "vbb.zip")
g <- extract_gtfs (f, quiet = TRUE)
from <- c ("Schonlein", "Innsbrucker Platz")
to <- c ("Berlin Hauptbahnhof", "Alexanderplatz")
start_time <- 12 * 3600 + 120 # 12:02
route <- gtfs_route (g, from = from, to = to,
start_time = start_time,
day = 3)
route
#> $`Schonlein --> Berlin Hauptbahnhof`
#> route_name trip_name stop_name arrival_time
#> 1 U8 U Paracelsus-Bad U Schonleinstr. (Berlin) 12:04:00
#> 2 U8 U Paracelsus-Bad U Kottbusser Tor (Berlin) 12:06:00
#> 3 U8 U Paracelsus-Bad U Moritzplatz (Berlin) 12:08:00
#> 4 U8 U Paracelsus-Bad U Heinrich-Heine-Str. (Berlin) 12:09:30
#> 5 U8 U Paracelsus-Bad S+U Jannowitzbrucke (Berlin) 12:10:30
#> 6 S5 S Westkreuz S+U Jannowitzbrucke (Berlin) 12:15:24
#> 7 S5 S Westkreuz S+U Alexanderplatz Bhf (Berlin) 12:17:24
#> 8 S5 S Westkreuz S Hackescher Markt (Berlin) 12:19:24
#> 9 S5 S Westkreuz S+U Friedrichstr. Bhf (Berlin) 12:21:24
#> 10 S5 S Westkreuz S+U Berlin Hauptbahnhof 12:24:06
#> departure_time
#> 1 12:04:00
#> 2 12:06:00
#> 3 12:08:00
#> 4 12:09:30
#> 5 12:10:30
#> 6 12:15:54
#> 7 12:18:12
#> 8 12:19:54
#> 9 12:22:12
#> 10 12:24:42
#>
#> $`Innsbrucker Platz --> Alexanderplatz`
#> route_name trip_name stop_name
#> 1 U4 U Nollendorfplatz S+U Innsbrucker Platz (Berlin)
#> 2 U4 U Nollendorfplatz U Rathaus Schoneberg (Berlin)
#> 3 U4 U Nollendorfplatz U Bayerischer Platz (Berlin)
#> 4 U4 U Nollendorfplatz U Viktoria-Luise-Platz (Berlin)
#> 5 U4 U Nollendorfplatz U Nollendorfplatz (Berlin)
#> 6 U2 S+U Pankow U Nollendorfplatz (Berlin)
#> 7 U2 S+U Pankow U Bulowstr. (Berlin)
#> 8 U2 S+U Pankow U Gleisdreieck (Berlin)
#> 9 U2 S+U Pankow U Mendelssohn-Bartholdy-Park (Berlin)
#> 10 U2 S+U Pankow S+U Potsdamer Platz (Bln) [U2]
#> 11 U2 S+U Pankow U Mohrenstr. (Berlin)
#> 12 U2 S+U Pankow Berlin, U Stadtmitte U2
#> 13 U2 S+U Pankow U Hausvogteiplatz (Berlin)
#> 14 U2 S+U Pankow U Spittelmarkt (Berlin)
#> 15 U2 S+U Pankow U Markisches Museum (Berlin)
#> 16 U2 S+U Pankow U Klosterstr. (Berlin)
#> 17 U2 S+U Pankow S+U Alexanderplatz (Berlin) [U2]
#> arrival_time departure_time
#> 1 12:06:00 12:06:00
#> 2 12:07:00 12:07:00
#> 3 12:08:30 12:08:30
#> 4 12:10:00 12:10:00
#> 5 12:12:00 12:12:00
#> 6 12:17:00 12:17:00
#> 7 12:18:30 12:18:30
#> 8 12:20:30 12:20:30
#> 9 12:22:00 12:22:00
#> 10 12:23:30 12:23:30
#> 11 12:25:00 12:25:00
#> 12 12:26:00 12:26:00
#> 13 12:27:30 12:27:30
#> 14 12:29:00 12:29:00
#> 15 12:30:00 12:30:00
#> 16 12:31:30 12:31:30
#> 17 12:33:30 12:33:30
Created on 2020-08-19 by the reprex package (v0.3.0)
Multiple from
and to
values return a list of routes, each element holding the route between from[i]
and to[i]
.
Thank you for opening this topic. I have got to this:
gtfs <- gtfs_timetable (gtfs) # A pre-processing step to speed up queries
r <- gtfsrouter::gtfs_route (gtfs, include_ids = FALSE, from = "Burwood Station", to ="Gordon Station", start_time = 12 * 3600 + 120, day = 2) # 12:02 in seconds This is GTFS Sydney, Australia. The next step is how to read multiple origins and destinations in stops.txt and save from, to stops into the gtfs_route table like below:
route_name trip_name stop_name arrival_time departure_time from_stop_id to_stop_id
Thank you!