Leave feature type as-is even if name is empty.

This commit is contained in:
vng 2015-07-22 15:27:39 +03:00 committed by Alex Zolotarev
parent 2f25caa3e8
commit 1d0179fa98
4 changed files with 15 additions and 22 deletions

View file

@ -75,6 +75,7 @@ namespace feature
inline uint32_t const * begin() const { return m_types; }
inline uint32_t const * end() const { return m_types + m_size; }
/// Assume that m_types is already sorted by SortBySpec function.
inline uint32_t GetBestType() const
{
// 0 - is an empty type.

View file

@ -391,7 +391,7 @@ namespace
TEST_EQUAL(info.m_street, poi.m_street, ());
TEST_EQUAL(info.m_house, poi.m_house, ());
TEST_EQUAL(info.m_types.size(), 1, ());
TEST(strcmp(info.GetBestType(), poi.m_type) == 0, ());
TEST_EQUAL(info.GetBestType(), poi.m_type, ());
}
}

View file

@ -221,10 +221,7 @@ string AddressInfo::GetPinName() const
string AddressInfo::GetPinType() const
{
char const * type = GetBestType();
if (IsEmptyName())
return "";
return (type ? type : "");
return GetBestType();
}
string AddressInfo::FormatPinText() const
@ -232,16 +229,11 @@ string AddressInfo::FormatPinText() const
// select name or house if name is empty
string const & ret = (m_name.empty() ? m_house : m_name);
char const * type = GetBestType();
if (type)
{
if (ret.empty())
return type;
else
return ret + " (" + string(type) + ')';
}
else
string const type = GetBestType();
if (type.empty())
return ret;
return (ret.empty() ? type : (ret + " (" + type + ')'));
}
string AddressInfo::FormatAddress() const
@ -287,14 +279,14 @@ string AddressInfo::FormatNameAndAddress() const
return (m_name.empty() ? addr : m_name + ", " + addr);
}
char const * AddressInfo::GetBestType() const
string AddressInfo::GetBestType() const
{
if (!m_types.empty())
{
ASSERT ( !m_types[0].empty(), () );
return m_types[0].c_str();
}
return 0;
if (m_types.empty())
return string();
/// @todo Probably, we should skip some "common" types here like in TypesHolder::SortBySpec.
ASSERT(!m_types[0].empty(), ());
return m_types[0];
}
void AddressInfo::Clear()

View file

@ -155,7 +155,7 @@ struct AddressInfo
string FormatAddress() const; // 7 vulica Frunze, Belarus
string FormatTypes() const; // clothes shop
string FormatNameAndAddress() const; // Caroline, 7 vulica Frunze, Belarus
char const * GetBestType() const;
string GetBestType() const;
bool IsEmptyName() const;
void Clear();