From e578ff0326ff9d69ee7bc9b58397902c35b71a4b Mon Sep 17 00:00:00 2001 From: vng Date: Fri, 5 Jul 2013 20:12:30 +0300 Subject: [PATCH] Get most readable name for users in AddressInfo. --- indexer/feature.cpp | 17 +++++++++++++++++ indexer/feature.hpp | 2 ++ map/address_finder.cpp | 17 +++++++++-------- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/indexer/feature.cpp b/indexer/feature.cpp index ab6032ec27..b42d456a82 100644 --- a/indexer/feature.cpp +++ b/indexer/feature.cpp @@ -264,6 +264,23 @@ void FeatureType::GetPreferredNames(string & defaultName, string & intName) cons } } +void FeatureType::GetReadableName(string & name) const +{ + ParseCommon(); + + BestMatchedLangNames matcher; + ForEachNameRef(matcher); + + if (!matcher.m_nativeName.empty()) + name.swap(matcher.m_nativeName); + else if (!matcher.m_defaultName.empty()) + name.swap(matcher.m_defaultName); + else if (!matcher.m_intName.empty()) + name.swap(matcher.m_intName); + else + name.swap(matcher.m_englishName); +} + string FeatureType::GetHouseNumber() const { ParseCommon(); diff --git a/indexer/feature.hpp b/indexer/feature.hpp index 37ab4366d7..f0a038c34e 100644 --- a/indexer/feature.hpp +++ b/indexer/feature.hpp @@ -236,6 +236,8 @@ public: //@{ /// Just get feature names. void GetPreferredNames(string & defaultName, string & intName) const; + /// Get one most suitable name for user. + void GetReadableName(string & name) const; bool GetName(int8_t lang, string & name) const; //@} diff --git a/map/address_finder.cpp b/map/address_finder.cpp index d507816908..046af7cf15 100644 --- a/map/address_finder.cpp +++ b/map/address_finder.cpp @@ -98,13 +98,13 @@ namespace if (IsInclude(d, types)) { - string name, house; - f.GetPreferredNames(name, house /*dummy parameter*/); - house = f.GetHouseNumber(); + string name; + f.GetReadableName(name); + string house = f.GetHouseNumber(); // if geom type is not GEOM_POINT, result center point doesn't matter in future use - m2::PointD const pt = (types.GetGeoType() == feature::GEOM_POINT) ? - f.GetCenter() : m2::PointD(); + m2::PointD const pt = + (types.GetGeoType() == feature::GEOM_POINT) ? f.GetCenter() : m2::PointD(); // name, house are assigned like move semantics m_cont.push_back(FeatureInfoT(GetResultDistance(d, types), types, name, house, pt)); @@ -495,9 +495,10 @@ void Framework::GetAddressInfoForGlobalPoint(m2::PointD const & pt, search::Addr DoGetAddressInfo getAddress(pt, scale, GetChecker(), addressR); m_model.ForEachFeature(rect, getAddress, scale); - getAddress.FillAddress(GetSearchEngine(), info); - GetLocality(pt, info); + + /// @todo Temporarily commented - it's slow and not used in UI + //GetLocality(pt, info); } void Framework::GetAddressInfo(FeatureType const & ft, m2::PointD const & pt, search::AddressInfo & info) const @@ -519,7 +520,7 @@ void Framework::GetAddressInfo(FeatureType const & ft, m2::PointD const & pt, se getAddress(ft); getAddress.FillAddress(GetSearchEngine(), info); - // @TODO Temporarily commented - it's slow and not used in UI + /// @todo Temporarily commented - it's slow and not used in UI //GetLocality(pt, info); }