Skip to content

Commit

Permalink
Skip only the invalid parking lots, not the entire set (#440)
Browse files Browse the repository at this point in the history
The ParkenDD Zürich feed has a few entries without geo coordinates for
example, but is otherwise valid.
  • Loading branch information
vkrause authored Feb 14, 2024
1 parent 8b6cbec commit 79b536a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/parking/src/parkendd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,17 @@ std::vector<api_parking_lot> parse(std::string const& json) {

utl::verify(doc.IsObject(), "no root object");
auto const& lots = get_array(doc, "lots");
return utl::to_vec(lots, [](auto const& lot) { return parse_lot(lot); });

std::vector<api_parking_lot> result;
result.reserve(lots.Size());
for (auto const& lot : lots) {
try {
result.push_back(parse_lot(lot));
} catch (...) {
continue;
}
}
return result;
}

parking_lot to_parking_lot(api_parking_lot const& apl) {
Expand Down

0 comments on commit 79b536a

Please sign in to comment.