Add a check for non-empty segments in CSV speed files
This commit is contained in:
parent
1efc527281
commit
4757c96d9a
@ -36,7 +36,19 @@ SegmentLookupTable readSegmentValues(const std::vector<std::string> &paths)
|
|||||||
CSVFilesParser<Segment, SpeedSource> parser(
|
CSVFilesParser<Segment, SpeedSource> parser(
|
||||||
1, qi::ulong_long >> ',' >> qi::ulong_long, qi::uint_ >> -(',' >> qi::double_));
|
1, qi::ulong_long >> ',' >> qi::ulong_long, qi::uint_ >> -(',' >> qi::double_));
|
||||||
|
|
||||||
return parser(paths);
|
// Check consistency of keys in the result lookup table
|
||||||
|
auto result = parser(paths);
|
||||||
|
const auto found_inconsistency =
|
||||||
|
std::find_if(std::begin(result.lookup), std::end(result.lookup), [](const auto &entry) {
|
||||||
|
return entry.first.from == entry.first.to;
|
||||||
|
});
|
||||||
|
if (found_inconsistency != std::end(result.lookup))
|
||||||
|
{
|
||||||
|
throw util::exception("empty segment in CSV with node " +
|
||||||
|
std::to_string(found_inconsistency->first.from) + " " + SOURCE_REF);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::move(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TurnLookupTable readTurnValues(const std::vector<std::string> &paths)
|
TurnLookupTable readTurnValues(const std::vector<std::string> &paths)
|
||||||
|
Loading…
Reference in New Issue
Block a user