forked from organicmaps/organicmaps
[geocoder] Ignore KV with "building":null
This commit is contained in:
parent
8f0823e16f
commit
3db49eb1d7
2 changed files with 19 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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|.
|
||||
|
|
Loading…
Add table
Reference in a new issue