From 8a783373818ec6a94a74315415bc9cab292081fe Mon Sep 17 00:00:00 2001 From: LaGrunge Date: Thu, 11 Jul 2019 13:54:09 +0300 Subject: [PATCH] Address buildings fix --- 3party/jansson/myjansson.hpp | 14 ++++++++++++++ generator/geo_objects/geo_objects.cpp | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/3party/jansson/myjansson.hpp b/3party/jansson/myjansson.hpp index 0a4565cc11..7d328abf8a 100644 --- a/3party/jansson/myjansson.hpp +++ b/3party/jansson/myjansson.hpp @@ -93,6 +93,20 @@ inline json_t const * GetJSONObligatoryFieldByPath(json_t const * root, First && return GetJSONObligatoryFieldByPath(newRoot, std::forward(paths)...); } +template +inline json_t * GetJSONObligatoryFieldByPath(json_t * root, First && path) +{ + return GetJSONObligatoryField(root, std::forward(path)); +} + +template +inline json_t * GetJSONObligatoryFieldByPath(json_t * root, First && path, + Paths &&... paths) +{ + json_t * newRoot = GetJSONObligatoryFieldByPath(root, std::forward(path)); + return GetJSONObligatoryFieldByPath(newRoot, std::forward(paths)...); +} + bool JSONIsNull(json_t const * root); } // namespace base diff --git a/generator/geo_objects/geo_objects.cpp b/generator/geo_objects/geo_objects.cpp index 1444fd7220..bd310fc9b7 100644 --- a/generator/geo_objects/geo_objects.cpp +++ b/generator/geo_objects/geo_objects.cpp @@ -70,8 +70,8 @@ base::JSONPtr AddAddress(FeatureBuilder const & fb, KeyValue const & regionKeyVa auto result = regionKeyValue.second->MakeDeepCopyJson(); int const kHouseOrPoiRank = 30; UpdateCoordinates(fb.GetKeyPoint(), result); - auto properties = json_object_get(result.get(), "properties"); - auto address = json_object_get(properties, "address"); + auto properties = base::GetJSONObligatoryField(result.get(), "properties"); + auto address = base::GetJSONObligatoryFieldByPath(properties, "locales", "default", "address"); ToJSONObject(*properties, "rank", kHouseOrPoiRank); auto const street = fb.GetParams().GetStreet(); if (!street.empty())