diff --git a/CHANGELOG.md b/CHANGELOG.md index 638bec2d767..5050017e469 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 diff --git a/features/car/conditional_restrictions.feature b/features/car/conditional_restrictions.feature index c2311067cea..de547cbf65c 100644 --- a/features/car/conditional_restrictions.feature +++ b/features/car/conditional_restrictions.feature @@ -353,6 +353,28 @@ 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 | + + # 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 Given the extract extra arguments "--parse-conditional-restrictions" diff --git a/src/updater/updater.cpp b/src/updater/updater.cpp index 9301c804b95..e06c159a5d4 100644 --- a/src/updater/updater.cpp +++ b/src/updater/updater.cpp @@ -583,8 +583,17 @@ 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(