diff --git a/gtfs2ntfs/src/main.rs b/gtfs2ntfs/src/main.rs index 08eb8b1f9..65876fb51 100644 --- a/gtfs2ntfs/src/main.rs +++ b/gtfs2ntfs/src/main.rs @@ -94,6 +94,10 @@ struct Opt { /// Waiting time at stop in seconds. #[arg(long, short = 't', default_value = transit_model::TRANSFER_WAITING_TIME)] waiting_time: u32, + + /// Don't compute transfers even the transfers of the stop point to itself (max_distance = 0.0) + #[arg(long)] + ignore_transfers: bool, } fn run(opt: Opt) -> Result<()> { @@ -119,13 +123,17 @@ fn run(opt: Opt) -> Result<()> { let model = transit_model::gtfs::Reader::new(configuration).parse(opt.input)?; - let model = generates_transfers( - model, - opt.max_distance, - opt.walking_speed, - opt.waiting_time, - None, - )?; + let model = if opt.ignore_transfers { + model + } else { + generates_transfers( + model, + opt.max_distance, + opt.walking_speed, + opt.waiting_time, + None, + )? + }; match opt.output.extension() { Some(ext) if ext == "zip" => { diff --git a/gtfs2ntfs/tests/gtfs2ntfs.rs b/gtfs2ntfs/tests/gtfs2ntfs.rs index f7b076cc8..c317594f7 100644 --- a/gtfs2ntfs/tests/gtfs2ntfs.rs +++ b/gtfs2ntfs/tests/gtfs2ntfs.rs @@ -16,6 +16,8 @@ fn test_gtfs2ntfs() { .assert() .success(); assert!(output_dir.path().join("feed_infos.txt").is_file()); + let collections = transit_model::ntfs::read(output_dir).unwrap(); + assert_eq!(81, collections.transfers.len()); } #[test] @@ -70,3 +72,22 @@ fn test_gtfs2ntfs_create_not_zip_extension() { .success(); assert!(ntfs_foobar.join("feed_infos.txt").is_file()); } + +#[test] +fn test_gtfs2ntfs_without_transfers() { + let output_dir = TempDir::new().expect("create temp dir failed"); + Command::cargo_bin("gtfs2ntfs") + .expect("Failed to find binary 'gtfs2ntfs'") + .arg("--input") + .arg("../tests/fixtures/gtfs2ntfs/minimal/input") + .arg("--output") + .arg(output_dir.path().to_str().unwrap()) + .arg("--current-datetime") + .arg("2019-04-03T17:19:00Z") + .arg("--ignore-transfers") + .assert() + .success(); + assert!(output_dir.path().join("feed_infos.txt").is_file()); + let collections = transit_model::ntfs::read(output_dir).unwrap(); + assert_eq!(0, collections.transfers.len()); +}