UrbanAnalyst / gtfsrouter

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

key not found error in rcpp_traveltimes #67

Closed polettif closed 3 years ago

polettif commented 3 years ago

See #61

gtfs_file = "routing.zip"
download.file("https://github.com/polettif/gtfs-test-feeds/raw/master/zip/routing.zip", gtfs_file)

library(gtfsrouter)
packageVersion("gtfsrouter")
#> [1] '0.0.4.150'
gtfs = gtfs_timetable(extract_gtfs(gtfs_file, T), date = 20181001)

gtfs_traveltimes(gtfs, "One", 7*3600)
#> Error in rcpp_traveltimes(gtfs_cp$timetable, gtfs_cp$transfers, nrow(gtfs_cp$stop_ids), : unordered_map::at: key not found
mpadge commented 3 years ago

Thanks @polettif. That happened because your simplified and date-filtered timetable had arrival_station entries which were not in the departure_stations column. The former code presumed both columns to be complete, which of course they need not be. Fixed now, so all unique values from both columns are used to construct definitive set of stations.

library (gtfsrouter)
packageVersion ("gtfsrouter")
#> [1] '0.0.4.151'
gtfs_file = "routing.zip"
download.file("https://github.com/polettif/gtfs-test-feeds/raw/master/zip/routing.zip", gtfs_file)

gtfs <- gtfs_timetable(extract_gtfs(gtfs_file, T), date = 20181001)

gtfs_traveltimes(gtfs, "One", 7*3600)
#>    duration ntransfers stop_id stop_name stop_lon stop_lat
#> 4  00:04:00          0   stop2       Two  7.39899 46.96230
#> 6  00:11:00          0  stop3a     Three  7.40839 46.96348
#> 7  00:06:00          0  stop3b     Three  7.40844 46.96411
#> 8  00:40:00          0   stop4      Four  7.42447 46.96878
#> 9  00:05:00          0   stop5      Five  7.40168 46.95650
#> 10 00:10:00          0   stop6       Six  7.40852 46.95389
#> 11 00:15:00          0   stop7     Seven  7.41633 46.95744
#> 13 00:12:10          1  stop8a     Eight  7.42396 46.96254
#> 14 00:12:00          0  stop8b     Eight  7.42300 46.96256

Created on 2020-12-16 by the reprex package (v0.3.0)