From 9fd452f6af8653f8cb61a621ad14e8b0102b9671 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Tue, 11 Oct 2022 23:04:20 +0200 Subject: [PATCH 1/4] Always use original weights when handling --parse-conditionals-from-now --- features/car/conditional_restrictions.feature | 12 ++++++++++++ src/updater/updater.cpp | 11 +++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/features/car/conditional_restrictions.feature b/features/car/conditional_restrictions.feature index c2311067c..deb5178f0 100644 --- a/features/car/conditional_restrictions.feature +++ b/features/car/conditional_restrictions.feature @@ -353,6 +353,18 @@ Feature: Car - Turn restrictions | b | a | bj,jc,jc,aj,aj | | b | d | bj,jd,jd | + # here we check that conditional restrictions can be updated via re-run of `contract`/`customize` with updated `--parse-conditionals-from-now` + # 10am utc, sat + When I run "osrm-contract {osm_file} --time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1494064800" + When I run "osrm-customize {osm_file} --time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1494064800" + + When I route I should get + | from | to | route | + | b | c | bj,jc,jc | + | b | a | bj,aj,aj | + | b | d | bj,jd,jd | + + @no_turning @conditionals Scenario: Car - Conditional restriction with multiple time windows Given the extract extra arguments "--parse-conditional-restrictions" diff --git a/src/updater/updater.cpp b/src/updater/updater.cpp index 9301c804b..e24468fe7 100644 --- a/src/updater/updater.cpp +++ b/src/updater/updater.cpp @@ -583,8 +583,15 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector &e [&] { extractor::files::readNodeData(config.GetPath(".osrm.ebg_nodes"), node_data); }, [&] { - extractor::files::readTurnWeightPenalty( - config.GetPath(".osrm.turn_weight_penalties"), turn_weight_penalties); + // we are going to overwrite this `.turn_weight_penalties` afterwards, + // so here we backup the original turn penalties if we didn't do that yet in order to + // guarantee that subsequent runs of this code will work on top of original weights + auto path = config.GetPath(".osrm.turn_weight_penalties").string() + ".original"; + if (!boost::filesystem::exists(path)) + { + boost::filesystem::copy_file(config.GetPath(".osrm.turn_weight_penalties"), path); + } + extractor::files::readTurnWeightPenalty(path, turn_weight_penalties); }, [&] { extractor::files::readTurnDurationPenalty( From db82cecce49be3665a9f4008ff2b4ccdda3ac12f Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Tue, 11 Oct 2022 23:09:09 +0200 Subject: [PATCH 2/4] Always use original weights when handling --parse-conditionals-from-now --- src/updater/updater.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/updater/updater.cpp b/src/updater/updater.cpp index e24468fe7..e06c159a5 100644 --- a/src/updater/updater.cpp +++ b/src/updater/updater.cpp @@ -584,12 +584,14 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector &e [&] { // we are going to overwrite this `.turn_weight_penalties` afterwards, - // so here we backup the original turn penalties if we didn't do that yet in order to - // guarantee that subsequent runs of this code will work on top of original weights + // so here we backup the original turn penalties if we didn't do that yet in order + // to guarantee that subsequent runs of this code will work on top of original + // weights auto path = config.GetPath(".osrm.turn_weight_penalties").string() + ".original"; if (!boost::filesystem::exists(path)) { - boost::filesystem::copy_file(config.GetPath(".osrm.turn_weight_penalties"), path); + boost::filesystem::copy_file(config.GetPath(".osrm.turn_weight_penalties"), + path); } extractor::files::readTurnWeightPenalty(path, turn_weight_penalties); }, From 4f10b155133dc83cf8755117e14e5e5d35e78df2 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Tue, 11 Oct 2022 23:21:39 +0200 Subject: [PATCH 3/4] Always use original weights when handling --parse-conditionals-from-now --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 638bec2d7..5050017e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - Changes from 5.27.0 - Routing: - CHANGED: Add support for surface=metal,grass_paver,woodchips in bicyle profile. [#6395](https://github.com/Project-OSRM/osrm-backend/pull/6395) + - Tools: + - FIXED: Always use original weights when handling `--parse-conditionals-from-now` option. [#6399](https://github.com/Project-OSRM/osrm-backend/pull/6399) # 5.27.0 - Changes from 5.26.0 From dc27a0751f755a4957cd2fdd27c45935508f5b1d Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Tue, 11 Oct 2022 23:35:42 +0200 Subject: [PATCH 4/4] Always use original weights when handling --parse-conditionals-from-now --- features/car/conditional_restrictions.feature | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/features/car/conditional_restrictions.feature b/features/car/conditional_restrictions.feature index deb5178f0..de547cbf6 100644 --- a/features/car/conditional_restrictions.feature +++ b/features/car/conditional_restrictions.feature @@ -364,6 +364,16 @@ Feature: Car - Turn restrictions | b | a | bj,aj,aj | | b | d | bj,jd,jd | + # 10am utc, wed + When I run "osrm-contract {osm_file} --time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493805600" + When I run "osrm-customize {osm_file} --time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493805600" + + When I route I should get + | from | to | route | + | b | c | bj,jc,jc | + | b | a | bj,jc,jc,aj,aj | + | b | d | bj,jd,jd | + @no_turning @conditionals Scenario: Car - Conditional restriction with multiple time windows