rb countries fix

This commit is contained in:
Arsentiy Milchakov 2017-04-04 19:05:58 +03:00 committed by Vladimir Byko-Ianko
parent a985b98b74
commit d346795e89
6 changed files with 34 additions and 18 deletions

View file

@ -2241,6 +2241,7 @@ void Framework::UpdatePlacePageInfoForCurrentSelection()
df::SelectionShape::ESelectedObject const obj = OnTapEventImpl(*m_lastTapEvent, info);
info.m_countryId = m_infoGetter->GetRegionCountryId(info.GetMercator());
GetStorage().GetTopmostNodesFor(info.m_countryId, info.m_topmostCountryIds);
if (obj != df::SelectionShape::OBJECT_EMPTY)
ActivateMapSelection(false, obj, info);
}
@ -2295,6 +2296,7 @@ void Framework::OnTapEvent(TapEvent const & tapEvent)
if (info.m_countryId.empty())
info.m_countryId = m_infoGetter->GetRegionCountryId(info.GetMercator());
GetStorage().GetTopmostNodesFor(info.m_countryId, info.m_topmostCountryIds);
ActivateMapSelection(true, selection, info);
}

View file

@ -181,7 +181,7 @@ bool Info::HasBanner() const
if (IsMyPosition())
return false;
return m_adsEngine->HasBanner(m_types, m_countryId);
return m_adsEngine->HasBanner(m_types, m_topmostCountryIds);
}
vector<ads::Banner> Info::GetBanners() const
@ -189,7 +189,7 @@ vector<ads::Banner> Info::GetBanners() const
if (!m_adsEngine)
return {};
return m_adsEngine->GetBanners(m_types, m_countryId);
return m_adsEngine->GetBanners(m_types, m_topmostCountryIds);
}
bool Info::IsReachableByTaxi() const

View file

@ -124,9 +124,14 @@ public:
string m_sponsoredDescriptionUrl;
string m_sponsoredReviewUrl;
/// Which country this MapObject is in.
/// For a country point it will be set to topmost node for country.
/// Which mwm this MapObject is in.
/// Exception: for a country-name point it will be set to the topmost node for the mwm.
/// TODO(@a): use m_topmostCountryIds in exceptional case.
storage::TCountryId m_countryId = storage::kInvalidCountryId;
/// The topmost downloader nodes this MapObject is in, i.e.
/// the country name for an object whose mwm represents only
/// one part of the country (or several countries for disputed territories).
storage::TCountriesVec m_topmostCountryIds;
bool m_isMyPosition = false;
/// True if editing of a selected point is allowed by basic logic.

View file

@ -18,23 +18,32 @@ Engine::Engine()
}
bool Engine::HasBanner(feature::TypesHolder const & types,
storage::TCountryId const & countryId) const
storage::TCountriesVec const & countryIds) const
{
return std::any_of(m_containers.cbegin(), m_containers.cend(),
[&types, &countryId](ContainerItem const & item) {
return item.m_container->HasBanner(types, countryId);
});
for (auto const & countryId : countryIds)
{
for (auto const & item : m_containers)
{
if (item.m_container->HasBanner(types, countryId))
return true;
}
}
return false;
}
std::vector<Banner> Engine::GetBanners(feature::TypesHolder const & types,
storage::TCountryId const & countryId) const
storage::TCountriesVec const & countryIds) const
{
std::vector<Banner> banners;
for (auto const & item : m_containers)
for (auto const & countryId : countryIds)
{
auto const bannerId = item.m_container->GetBannerId(types, countryId);
if (!bannerId.empty())
banners.emplace_back(item.m_type, bannerId);
for (auto const & item : m_containers)
{
auto const bannerId = item.m_container->GetBannerId(types, countryId);
if (!bannerId.empty())
banners.emplace_back(item.m_type, bannerId);
}
}
return banners;

View file

@ -19,9 +19,9 @@ class Engine
public:
Engine();
bool HasBanner(feature::TypesHolder const & types, storage::TCountryId const & countryId) const;
bool HasBanner(feature::TypesHolder const & types, storage::TCountriesVec const & countryIds) const;
std::vector<Banner> GetBanners(feature::TypesHolder const & types,
storage::TCountryId const & countryId) const;
storage::TCountriesVec const & countryIds) const;
private:
using ContainerPtr = std::unique_ptr<ContainerBase>;

View file

@ -17,13 +17,13 @@ auto const kBannerIdForOtherTypes = "14";
std::vector<storage::TCountryId> const kSupportedCountries =
{
"Azerbaijan",
"Azerbaijan Region",
"Armenia",
"Belarus",
"Kazakhstan",
"Kyrgyzstan",
"Moldova",
"Russia",
"Russian Federation",
"Tajikistan",
"Turkmenistan",
"Uzbekistan",