Skip to content

Commit

Permalink
Add a check for non-empty segments in CSV speed files
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase authored and Moritz Kobitzsch committed Aug 4, 2017
1 parent 1efc527 commit 4757c96
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/updater/csv_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4757c96

Please sign in to comment.