Skip to content

Commit

Permalink
Support floats for speed value in traffic updates CSV (Project-OSRM#6327
Browse files Browse the repository at this point in the history
)
  • Loading branch information
SiarheiFedartsou authored and mattwigway committed Jul 20, 2023
1 parent a2c1ac9 commit f5f3ca2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/osrm-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions features/testbot/weight.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions include/updater/source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ struct Segment final

struct SpeedSource final
{
SpeedSource() : speed(0), rate() {}
unsigned speed;
SpeedSource() : speed(0.), rate() {}
double speed;
boost::optional<double> rate;
std::uint8_t source;
};
Expand Down
3 changes: 2 additions & 1 deletion src/updater/csv_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ namespace csv
SegmentLookupTable readSegmentValues(const std::vector<std::string> &paths)
{
static const auto value_if_blank = std::numeric_limits<double>::quiet_NaN();
const qi::real_parser<double, qi::ureal_policies<double>> unsigned_double;
CSVFilesParser<Segment, SpeedSource> 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);
Expand Down

0 comments on commit f5f3ca2

Please sign in to comment.