diff options
author | Anatoly Serdtcev <serdtcev@maps.me> | 2018-12-26 18:48:08 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2018-12-27 17:13:03 +0300 |
commit | 3db49eb1d727c37aa9b9baf414f05eb9bbc775c7 (patch) | |
tree | 8ad11ed6a4e889ac2ed2ce3f09a59a041babaf6d /geocoder | |
parent | 8f0823e16ff063b14eb5adfdfa14f493e4a7c9d1 (diff) |
[geocoder] Ignore KV with "building":null
Diffstat (limited to 'geocoder')
-rw-r--r-- | geocoder/hierarchy.cpp | 22 | ||||
-rw-r--r-- | geocoder/hierarchy.hpp | 2 |
2 files changed, 19 insertions, 5 deletions
diff --git a/geocoder/hierarchy.cpp b/geocoder/hierarchy.cpp index b814027ffc..009c41f835 100644 --- a/geocoder/hierarchy.cpp +++ b/geocoder/hierarchy.cpp @@ -49,8 +49,7 @@ bool Hierarchy::Entry::DeserializeFromJSON(string const & jsonStr, ParsingStats try { base::Json root(jsonStr.c_str()); - DeserializeFromJSONImpl(root.get(), jsonStr, stats); - return true; + return DeserializeFromJSONImpl(root.get(), jsonStr, stats); } catch (base::Json::Exception const & e) { @@ -60,7 +59,7 @@ bool Hierarchy::Entry::DeserializeFromJSON(string const & jsonStr, ParsingStats } // todo(@m) Factor out to geojson.hpp? Add geojson to myjansson? -void Hierarchy::Entry::DeserializeFromJSONImpl(json_t * const root, string const & jsonStr, +bool Hierarchy::Entry::DeserializeFromJSONImpl(json_t * const root, string const & jsonStr, ParsingStats & stats) { if (!json_is_object(root)) @@ -77,8 +76,21 @@ void Hierarchy::Entry::DeserializeFromJSONImpl(json_t * const root, string const { Type const type = static_cast<Type>(i); string const & levelKey = ToString(type); + auto* levelJson = base::GetJSONOptionalField(address, levelKey); + if (!levelJson) + continue; + + if (json_is_null(levelJson)) + { + // Ignore buildings with out full address. + if (Type::Building == type) + return false; + + continue; + } + string levelValue; - FromJSONObjectOptionalField(address, levelKey, levelValue); + FromJSON(levelJson, levelValue); if (levelValue.empty()) continue; @@ -113,6 +125,8 @@ void Hierarchy::Entry::DeserializeFromJSONImpl(json_t * const root, string const { ++stats.m_mismatchedNames; } + + return true; } bool Hierarchy::Entry::IsParentTo(Hierarchy::Entry const & e) const diff --git a/geocoder/hierarchy.hpp b/geocoder/hierarchy.hpp index 6bf1535843..bae7d2fc38 100644 --- a/geocoder/hierarchy.hpp +++ b/geocoder/hierarchy.hpp @@ -54,7 +54,7 @@ public: { bool DeserializeFromJSON(std::string const & jsonStr, ParsingStats & stats); - void DeserializeFromJSONImpl(json_t * const root, std::string const & jsonStr, + bool DeserializeFromJSONImpl(json_t * const root, std::string const & jsonStr, ParsingStats & stats); // Checks whether this entry is a parent of |e|. |