Add a check for non-empty segments in CSV speed files

This commit is contained in:
Michael Krasnyk 2017-08-03 14:56:14 +02:00 committed by Moritz Kobitzsch
parent 1efc527281
commit 4757c96d9a

View File

@ -36,7 +36,19 @@ SegmentLookupTable readSegmentValues(const std::vector<std::string> &paths)
CSVFilesParser<Segment, SpeedSource> parser(
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)