Framework::GetAddressInfo - add feature type (category) strings.

This commit is contained in:
vng 2012-05-11 10:27:56 +03:00 committed by Alex Zolotarev
parent b24f4e6e00
commit 41903e7360
5 changed files with 28 additions and 2 deletions

View file

@ -3,6 +3,8 @@
#include "../indexer/classificator.hpp"
#include "../indexer/feature_visibility.hpp"
#include "../platform/preferred_languages.hpp"
namespace
{
@ -305,8 +307,10 @@ namespace
m_cont.clear();
}
void FillAddress(Framework::AddressInfo & info)
void FillAddress(search::Engine const * eng, Framework::AddressInfo & info)
{
int8_t const lang = StringUtf8Multilang::GetLangIndex(languages::CurrentLanguage());
SortResults();
for (size_t i = 0; i < m_cont.size(); ++i)
@ -322,7 +326,17 @@ namespace
if (info.m_name.empty())
{
if (m_cont[i].m_types.GetGeoType() != feature::GEOM_LINE)
{
info.m_name = m_cont[i].m_name;
// add types for POI
size_t const count = m_cont[i].m_types.Size();
info.m_types.resize(count);
for (size_t j = 0; j < count; ++j)
{
eng->GetNameByType(m_cont[i].m_types[j], lang, info.m_types[j]);
}
}
}
if (!(info.m_street.empty() || info.m_name.empty()))
@ -374,7 +388,7 @@ void Framework::GetAddressInfo(m2::PointD const & pt, AddressInfo & info) const
m_model.ForEachFeature(
MercatorBounds::RectByCenterXYAndSizeInMeters(pt, addressR), getAddress, scale);
getAddress.FillAddress(info);
getAddress.FillAddress(GetSearchEngine(), info);
}
// now - get the locality

View file

@ -219,6 +219,7 @@ public:
struct AddressInfo
{
string m_country, m_city, m_street, m_house, m_name;
vector<string> m_types;
};
/// Get address information for point on map.

View file

@ -133,4 +133,8 @@ UNIT_TEST(Bookmarks_AddressInfo)
TEST_EQUAL(info.m_street, "ул. Карла Маркса", ());
TEST_EQUAL(info.m_house, "10", ());
TEST_EQUAL(info.m_name, "Библос", ());
TEST_EQUAL(info.m_types.size(), 1, ());
// assume that developers have English or Russian system language :)
TEST(info.m_types[0] == "cafe" || info.m_types[0] == "кафе", (info.m_types[0]));
}

View file

@ -290,6 +290,11 @@ string Engine::GetCountryName(m2::PointD const & pt)
return info.m_name;
}
bool Engine::GetNameByType(uint32_t type, int8_t lang, string & name) const
{
return m_pData->m_categories.GetNameByType(type, lang, name);
}
void Engine::ClearCaches()
{
/// @todo Add m_pData->m_infoGetter clearing routine.

View file

@ -44,6 +44,8 @@ public:
string GetCountryCode(m2::PointD const & pt);
string GetCountryName(m2::PointD const & pt);
bool GetNameByType(uint32_t type, int8_t lang, string & name) const;
void ClearCaches();
private: