From f41e6ea733b643a99791ad5f3731a5147df347a6 Mon Sep 17 00:00:00 2001 From: Michael Kutzner <174690291+MichaelKutzner@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:08:27 +0100 Subject: [PATCH] Rename variable --- include/nigiri/routing/search.h | 2 +- include/nigiri/routing/transfer_time_settings.h | 10 +++++----- test/routing/transfer_time_settings_test.cc | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/nigiri/routing/search.h b/include/nigiri/routing/search.h index e4116d33..cb87d928 100644 --- a/include/nigiri/routing/search.h +++ b/include/nigiri/routing/search.h @@ -87,7 +87,7 @@ struct search { tts.factor_ = std::max(tts.factor_, 1.0F); if (tts.factor_ == 1.0F && tts.min_transfer_time_ == 0_minutes && - tts.disposable_time_ == 0_minutes) { + tts.additional_time_ == 0_minutes) { tts.default_ = true; } diff --git a/include/nigiri/routing/transfer_time_settings.h b/include/nigiri/routing/transfer_time_settings.h index 8daf540a..271f0254 100644 --- a/include/nigiri/routing/transfer_time_settings.h +++ b/include/nigiri/routing/transfer_time_settings.h @@ -7,13 +7,13 @@ namespace nigiri::routing { struct transfer_time_settings { bool operator==(transfer_time_settings const& o) const { return default_ == o.default_ || - std::tie(min_transfer_time_, disposable_time_, factor_) == - std::tie(o.min_transfer_time_, disposable_time_, o.factor_); + std::tie(min_transfer_time_, additional_time_, factor_) == + std::tie(o.min_transfer_time_, additional_time_, o.factor_); } bool default_{true}; duration_t min_transfer_time_{0}; - duration_t disposable_time_{0}; + duration_t additional_time_{0}; float factor_{1.0F}; }; @@ -23,7 +23,7 @@ inline T adjusted_transfer_time(transfer_time_settings const& settings, if (settings.default_) { return duration; } else { - return static_cast(settings.disposable_time_.count()) + + return static_cast(settings.additional_time_.count()) + std::max( static_cast(settings.min_transfer_time_.count()), static_cast(static_cast(duration) * settings.factor_)); @@ -38,7 +38,7 @@ inline std::chrono::duration> adjusted_transfer_time( return duration; } else { return std::chrono::duration>{ - static_cast(settings.disposable_time_.count()) + + static_cast(settings.additional_time_.count()) + std::max(static_cast(settings.min_transfer_time_.count()), static_cast(static_cast(duration.count()) * settings.factor_))}; diff --git a/test/routing/transfer_time_settings_test.cc b/test/routing/transfer_time_settings_test.cc index 0b13179e..250a7eb3 100644 --- a/test/routing/transfer_time_settings_test.cc +++ b/test/routing/transfer_time_settings_test.cc @@ -216,35 +216,35 @@ TEST(routing, transfer_time_settings_test) { EXPECT_EQ(expected_A_C_f20, results_to_str(results, tt)); } { - // A -> C, default transfer time, 2 min disposable (= 4 min) + // A -> C, default transfer time, 2 min additional (= 4 min) auto const results = search(tt, nullptr, "A", "C", tt.date_range_, dir, - {.default_ = false, .disposable_time_ = duration_t{2}}); + {.default_ = false, .additional_time_ = duration_t{2}}); EXPECT_EQ(expected_A_C_f20, results_to_str(results, tt)); } { - // A -> C, 1.5x transfer time, 1 min disposable (= 4 min) + // A -> C, 1.5x transfer time, 1 min additional (= 4 min) auto const results = search(tt, nullptr, "A", "C", tt.date_range_, dir, {.default_ = false, - .disposable_time_ = duration_t{1}, + .additional_time_ = duration_t{1}, .factor_ = 1.5F}); EXPECT_EQ(expected_A_C_f20, results_to_str(results, tt)); } { - // A -> C, min 3 min transfer time, 1 min disposable (= 4 min) + // A -> C, min 3 min transfer time, 1 min additional (= 4 min) auto const results = search(tt, nullptr, "A", "C", tt.date_range_, dir, {.default_ = false, .min_transfer_time_ = duration_t{3}, - .disposable_time_ = duration_t{1}}); + .additional_time_ = duration_t{1}}); EXPECT_EQ(expected_A_C_f20, results_to_str(results, tt)); } { - // A -> C, min 3 min transfer time, 2.5x transfer time, 5 min disposable + // A -> C, min 3 min transfer time, 2.5x transfer time, 5 min additional // (= 10 min) auto const results = search(tt, nullptr, "A", "C", tt.date_range_, dir, {.default_ = false, .min_transfer_time_ = duration_t{3}, - .disposable_time_ = duration_t{5}, + .additional_time_ = duration_t{5}, .factor_ = 2.5F}); EXPECT_EQ(expected_A_C_min10, results_to_str(results, tt)); }