Transliteration allowability parameter added.

This commit is contained in:
Daria Volvenkova 2017-03-28 19:27:59 +03:00
parent 8c3d4f78c7
commit 965d71afc3
10 changed files with 16 additions and 17 deletions

View file

@ -23,6 +23,5 @@ public:
private:
Transliteration() = default;
struct TransliteratorWrapper;
std::map<std::string, std::unique_ptr<icu::Transliterator>> m_transliterators;
};

View file

@ -229,9 +229,9 @@ void CaptionDescription::Init(FeatureType const & f,
bool const auxCaptionExists)
{
if (auxCaptionExists || type == feature::GEOM_LINE)
f.GetPreferredNames(m_mainText, m_auxText);
f.GetPreferredNames(true /* allowTranslit */, m_mainText, m_auxText);
else
f.GetReadableName(m_mainText);
f.GetReadableName(true /* allowTranslit */, m_mainText);
m_roadNumber = f.GetRoadNumber();
m_houseNumber = f.GetHouseNumber();

View file

@ -75,7 +75,7 @@ FeatureStyler::FeatureStyler(FeatureType const & f,
m_geometryType = type.first;
m_isCoastline = type.second;
f.GetPreferredNames(m_primaryText, m_secondaryText);
f.GetPreferredNames(false /* allowTranslit */, m_primaryText, m_secondaryText);
// Draw only one text for features on the World zoom level in user's native language.
if (zoom <= scales::GetUpperWorldScale() && !m_secondaryText.empty())
@ -215,7 +215,7 @@ FeatureStyler::FeatureStyler(FeatureType const & f,
// User's language name is better if we don't have secondary text draw rule.
if (!hasSecondaryText && !m_secondaryText.empty() && (m_geometryType != feature::GEOM_LINE))
{
f.GetReadableName(m_primaryText);
f.GetReadableName(false /* allowTranslit */, m_primaryText);
if (m_primaryText == m_secondaryText)
m_secondaryText.clear();
}

View file

@ -192,7 +192,7 @@ public:
string const & mwmName = f.GetID().GetMwmName();
string name, secondary;
f.GetPreferredNames(name, secondary);
f.GetPreferredNames(false /* allowTranslit */, name, secondary);
string const & uid = BuildUniqueId(ll, name);
string const & lat = strings::to_string_with_digits_after_comma(ll.lat, 6);
string const & lon = strings::to_string_with_digits_after_comma(ll.lon, 6);

View file

@ -70,7 +70,7 @@ namespace feature
{
++m_totalCount;
string s1, s2;
f.GetPreferredNames(s1, s2);
f.GetPreferredNames(false /* allowTranslit */, s1, s2);
if (!s1.empty())
++m_namesCount;

View file

@ -106,7 +106,7 @@ bool GetPopulation(FeatureType const & ft, uint64_t & population)
// Feature tag value evaluator for tag 'name'
bool GetName(FeatureType const & ft, string & name)
{
ft.GetReadableName(name);
ft.GetReadableName(false /* allowTranslit */, name);
return true;
}

View file

@ -491,7 +491,7 @@ FeatureType::geom_stat_t FeatureType::GetTrianglesSize(int scale) const
return geom_stat_t(sz, m_triangles.size());
}
void FeatureType::GetPreferredNames(string & primary, string & secondary) const
void FeatureType::GetPreferredNames(bool allowTranslit, string & primary, string & secondary) const
{
if (!HasName())
return;
@ -503,11 +503,11 @@ void FeatureType::GetPreferredNames(string & primary, string & secondary) const
ParseCommon();
auto const deviceLang = StringUtf8Multilang::GetLangIndex(languages::GetCurrentNorm());
::GetPreferredNames(mwmInfo->GetRegionData(), GetNames(), deviceLang, true /* allowTranslit */,
::GetPreferredNames(mwmInfo->GetRegionData(), GetNames(), deviceLang, allowTranslit,
primary, secondary);
}
void FeatureType::GetReadableName(string & name) const
void FeatureType::GetReadableName(bool allowTranslit, string & name) const
{
if (!HasName())
return;
@ -519,7 +519,7 @@ void FeatureType::GetReadableName(string & name) const
ParseCommon();
auto const deviceLang = StringUtf8Multilang::GetLangIndex(languages::GetCurrentNorm());
::GetReadableName(mwmInfo->GetRegionData(), GetNames(), deviceLang, true /* allowTranslit */, name);
::GetReadableName(mwmInfo->GetRegionData(), GetNames(), deviceLang, allowTranslit, name);
}
string FeatureType::GetHouseNumber() const

View file

@ -285,9 +285,9 @@ public:
/// @param[out] intName optionally choosen from tags "name:<lang_code>" by the algorithm
//@{
/// Just get feature names.
void GetPreferredNames(string & defaultName, string & intName) const;
void GetPreferredNames(bool allowTranslit, string & defaultName, string & intName) const;
/// Get one most suitable name for user.
void GetReadableName(string & name) const;
void GetReadableName(bool allowTranslit, string & name) const;
static int8_t const DEFAULT_LANG = StringUtf8Multilang::kDefaultCode;
bool GetName(int8_t lang, string & name) const;

View file

@ -502,7 +502,7 @@ search::AddressInfo Framework::GetFeatureAddressInfo(FeatureType & ft) const
// TODO(vng): Why AddressInfo is responsible for types and names? Refactor out.
string defaultName, intName;
ft.GetPreferredNames(defaultName, intName);
ft.GetPreferredNames(false /* allowTranslit */, defaultName, intName);
info.m_name = defaultName.empty() ? intName : defaultName;
info.m_types = GetPrintableFeatureTypes(ft);

View file

@ -2975,7 +2975,7 @@ bool Framework::ParseEditorDebugCommand(search::SearchParams const & params)
}
string name;
ft.GetReadableName(name);
ft.GetReadableName(false /* allowTranslit */, name);
feature::TypesHolder const types(ft);
search::Result::Metadata smd;
results.AddResultNoChecks(search::Result(fid, feature::GetCenter(ft), name, edit.second,
@ -3006,7 +3006,7 @@ WARN_UNUSED_RESULT bool LocalizeStreet(Index const & index, FeatureID const & fi
return false;
ft.GetName(StringUtf8Multilang::kDefaultCode, result.m_defaultName);
ft.GetReadableName(result.m_localizedName);
ft.GetReadableName(false /* allowTranslit */, result.m_localizedName);
if (result.m_localizedName == result.m_defaultName)
result.m_localizedName.clear();
return true;