Support floats for speed value in traffic updates CSV (#6327)

This commit is contained in:
Siarhei Fedartsou 2022-08-30 15:34:46 +02:00 committed by GitHub
parent b17cbb4c47
commit 2cf957148b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 7 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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;
};

View File

@ -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);