From 79b536a4cedcaba755600f6eb7e495d5a6657428 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Wed, 14 Feb 2024 21:51:23 +0100 Subject: [PATCH] Skip only the invalid parking lots, not the entire set (#440) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ParkenDD Zürich feed has a few entries without geo coordinates for example, but is otherwise valid. --- modules/parking/src/parkendd.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/parking/src/parkendd.cc b/modules/parking/src/parkendd.cc index 2ec625bac..c121c63c9 100644 --- a/modules/parking/src/parkendd.cc +++ b/modules/parking/src/parkendd.cc @@ -49,7 +49,17 @@ std::vector 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 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) {