Skip to content

Commit

Permalink
Merge pull request #944 from hove-io/feature/ntfs2ntfs_ability_to_dis…
Browse files Browse the repository at this point in the history
…able_tranfers_computing

[feature] ntfs2ntfs ability to disable tranfers computing
  • Loading branch information
patochectp authored Mar 13, 2024
2 parents e7bbf0a + 7a59d82 commit 46e04e4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Hove <[email protected]>", "Guillaume Pinot <[email protected]>"]
name = "transit_model"
version = "0.62.1"
version = "0.62.2"
license = "AGPL-3.0-only"
description = "Transit data management"
repository = "https://github.com/hove-io/transit_model"
Expand Down
22 changes: 15 additions & 7 deletions ntfs2ntfs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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 init_logger() {
Expand All @@ -89,13 +93,17 @@ fn run(opt: Opt) -> Result<()> {
info!("Launching ntfs2ntfs...");

let model = transit_model::ntfs::read(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,
)?
};

if let Some(output) = opt.output {
match output.extension() {
Expand Down
19 changes: 19 additions & 0 deletions ntfs2ntfs/tests/ntfs2ntfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,22 @@ fn test_ntfs2ntfs_create_foobar() {
.success();
assert!(ntfs_foobar.join("feed_infos.txt").is_file());
}

#[test]
fn test_ntfs2ntfs_without_transfers() {
let output_dir = TempDir::new().expect("create temp dir failed");
Command::cargo_bin("ntfs2ntfs")
.expect("Failed to find binary 'ntfs2ntfs'")
.arg("--input")
.arg("../tests/fixtures/minimal_ntfs/")
.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());
}

0 comments on commit 46e04e4

Please sign in to comment.