From f5f3ca2f3ea3fd5f3c296ae860c2982e9068a1a4 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Tue, 30 Aug 2022 15:34:46 +0200 Subject: [PATCH] Support floats for speed value in traffic updates CSV (#6327) --- .github/workflows/osrm-backend.yml | 2 +- CHANGELOG.md | 1 + features/testbot/weight.feature | 6 +++--- include/updater/source.hpp | 4 ++-- src/updater/csv_source.cpp | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index d83046d0ec6..d4b001450e1 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -26,7 +26,7 @@ jobs: continue-on-error: false steps: - uses: actions/checkout@v3 - - run: pip install conan==1.50.0 + - run: pip install conan==1.51.3 - run: conan --version - run: cmake --version - uses: actions/setup-node@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index ecb4109c6a1..1e5dba51137 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - NodeJS: - FIXED: Support `skip_waypoints` in Node bindings [#6060](https://github.com/Project-OSRM/osrm-backend/pull/6060) - Misc: + - ADDED: Support floats for speed value in traffic updates CSV. [#6327](https://github.com/Project-OSRM/osrm-backend/pull/6327) - CHANGED: Use Lua 5.4 in Docker image. [#6346](https://github.com/Project-OSRM/osrm-backend/pull/6346) - CHANGED: Remove redundant nullptr check. [#6326](https://github.com/Project-OSRM/osrm-backend/pull/6326) - CHANGED: missing files list is included in exception message. [#5360](https://github.com/Project-OSRM/osrm-backend/pull/5360) diff --git a/features/testbot/weight.feature b/features/testbot/weight.feature index 04e42b46bb3..b5e4aedc605 100644 --- a/features/testbot/weight.feature +++ b/features/testbot/weight.feature @@ -329,7 +329,7 @@ Feature: Weight tests | ce | And the speed file """ - 1,2,36,42 + 1,2,36.999,42 2,1,36,42 """ And the turn penalty file @@ -341,8 +341,8 @@ Feature: Weight tests When I route I should get | waypoints | route | distance | weights | times | - | a,d | , | 60m | 20.5,0 | 24s,0s | - | a,e | ,, | 60m | 27.2,10,0 | 38.5s,11s,0s | + | a,d | , | 60m | 20.5,0 | 23.9s,0s | + | a,e | ,, | 60m | 27.2,10,0 | 38.4s,11s,0s | | d,e | ,, | 40m | 10,10,0 | 11s,11s,0s | @traffic @speed diff --git a/include/updater/source.hpp b/include/updater/source.hpp index 58a19e0807e..b00d402c9ec 100644 --- a/include/updater/source.hpp +++ b/include/updater/source.hpp @@ -49,8 +49,8 @@ struct Segment final struct SpeedSource final { - SpeedSource() : speed(0), rate() {} - unsigned speed; + SpeedSource() : speed(0.), rate() {} + double speed; boost::optional rate; std::uint8_t source; }; diff --git a/src/updater/csv_source.cpp b/src/updater/csv_source.cpp index a242a0c6631..fe13a7477cf 100644 --- a/src/updater/csv_source.cpp +++ b/src/updater/csv_source.cpp @@ -34,10 +34,11 @@ namespace csv SegmentLookupTable readSegmentValues(const std::vector &paths) { static const auto value_if_blank = std::numeric_limits::quiet_NaN(); + const qi::real_parser> unsigned_double; CSVFilesParser parser( 1, qi::ulong_long >> ',' >> qi::ulong_long, - qi::uint_ >> -(',' >> (qi::double_ | qi::attr(value_if_blank)))); + unsigned_double >> -(',' >> (qi::double_ | qi::attr(value_if_blank)))); // Check consistency of keys in the result lookup table auto result = parser(paths);