forked from organicmaps/organicmaps
Added support of hidden local ads campaigns
This commit is contained in:
parent
026bb1295b
commit
dc6fa6d3e2
3 changed files with 21 additions and 11 deletions
|
@ -950,7 +950,7 @@ void Framework::FillInfoFromFeatureType(FeatureType & ft, place_page::Info & inf
|
|||
if (m_localAdsManager.IsSupportedType(info.GetTypes()))
|
||||
{
|
||||
info.SetLocalAdsUrl(m_localAdsManager.GetCompanyUrl(ft.GetID()));
|
||||
auto const status = m_localAdsManager.Contains(ft.GetID())
|
||||
auto const status = m_localAdsManager.HasVisualization(ft.GetID())
|
||||
? place_page::LocalAdsStatus::Customer
|
||||
: place_page::LocalAdsStatus::Candidate;
|
||||
info.SetLocalAdsStatus(status);
|
||||
|
@ -1763,7 +1763,7 @@ void Framework::FillSearchResultsMarks(search::Results::ConstIter begin,
|
|||
|
||||
if (r.m_metadata.m_isSponsoredHotel)
|
||||
{
|
||||
mark->SetBookingType(isFeature && m_localAdsManager.Contains(r.GetFeatureID()) /* hasLocalAds */);
|
||||
mark->SetBookingType(isFeature && m_localAdsManager.HasVisualization(r.GetFeatureID()) /* hasLocalAds */);
|
||||
mark->SetRating(r.m_metadata.m_hotelRating);
|
||||
mark->SetPricing(r.m_metadata.m_hotelPricing);
|
||||
}
|
||||
|
@ -1771,7 +1771,7 @@ void Framework::FillSearchResultsMarks(search::Results::ConstIter begin,
|
|||
{
|
||||
auto product = GetProductInfo(r);
|
||||
auto const type = r.GetFeatureType();
|
||||
mark->SetFromType(type, m_localAdsManager.Contains(r.GetFeatureID()));
|
||||
mark->SetFromType(type, m_localAdsManager.HasVisualization(r.GetFeatureID()));
|
||||
if (product.m_ugcRating != search::ProductInfo::kInvalidRating)
|
||||
mark->SetRating(product.m_ugcRating);
|
||||
}
|
||||
|
@ -1857,7 +1857,7 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFac
|
|||
for (auto const & event : events)
|
||||
{
|
||||
auto const & mwmInfo = event.m_feature.m_mwmId.GetInfo();
|
||||
if (!mwmInfo || !m_localAdsManager.Contains(event.m_feature))
|
||||
if (!mwmInfo || !m_localAdsManager.HasAds(event.m_feature))
|
||||
continue;
|
||||
|
||||
statEvents.emplace_back(local_ads::EventType::ShowPoint,
|
||||
|
@ -3591,7 +3591,7 @@ search::ProductInfo Framework::GetProductInfo(search::Result const & result) con
|
|||
|
||||
search::ProductInfo productInfo;
|
||||
|
||||
productInfo.m_isLocalAdsCustomer = m_localAdsManager.Contains(result.GetFeatureID());
|
||||
productInfo.m_isLocalAdsCustomer = m_localAdsManager.HasVisualization(result.GetFeatureID());
|
||||
|
||||
auto const ugc = m_ugcApi->GetLoader().GetUGC(result.GetFeatureID());
|
||||
productInfo.m_ugcRating = ugc.m_totalRating;
|
||||
|
|
|
@ -724,7 +724,7 @@ LocalAdsManager::FeaturesCache LocalAdsManager::ReadCampaignFeatures(CampaignDat
|
|||
|
||||
LocalAdsManager::CacheEntry entry;
|
||||
entry.m_position = feature::GetCenter(ft, scales::GetUpperScale());
|
||||
entry.m_isCustom = it->second != nullptr;
|
||||
entry.m_isVisibleOnMap = it->second != nullptr;
|
||||
if (it->second != nullptr)
|
||||
{
|
||||
it->second->m_position = entry.m_position;
|
||||
|
@ -744,7 +744,7 @@ void LocalAdsManager::UpdateFeaturesCache(FeaturesCache && features)
|
|||
if (!features.empty())
|
||||
m_featuresCache.insert(features.begin(), features.end());
|
||||
for (auto const & entry : m_featuresCache)
|
||||
customFeatures.insert(std::make_pair(entry.first, entry.second.m_isCustom));
|
||||
customFeatures.insert(std::make_pair(entry.first, entry.second.m_isVisibleOnMap));
|
||||
}
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::SetCustomFeatures, std::move(customFeatures));
|
||||
}
|
||||
|
@ -770,12 +770,22 @@ void LocalAdsManager::ClearLocalAdsForMwm(MwmSet::MwmId const & mwmId)
|
|||
DeleteLocalAdsMarks(mwmId);
|
||||
}
|
||||
|
||||
bool LocalAdsManager::Contains(FeatureID const & featureId) const
|
||||
bool LocalAdsManager::HasAds(FeatureID const & featureId) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_featuresCacheMutex);
|
||||
return m_featuresCache.find(featureId) != m_featuresCache.cend();
|
||||
}
|
||||
|
||||
bool LocalAdsManager::HasVisualization(FeatureID const & featureId) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_featuresCacheMutex);
|
||||
auto const it = m_featuresCache.find(featureId);
|
||||
if (it == m_featuresCache.cend())
|
||||
return false;
|
||||
|
||||
return it->second.m_isVisibleOnMap;
|
||||
}
|
||||
|
||||
bool LocalAdsManager::IsSupportedType(feature::TypesHolder const & types) const
|
||||
{
|
||||
return m_supportedTypes.Contains(types);
|
||||
|
|
|
@ -66,7 +66,6 @@ public:
|
|||
|
||||
LocalAdsManager(GetMwmsByRectFn && getMwmsByRectFn, GetMwmIdByNameFn && getMwmIdByName,
|
||||
ReadFeaturesFn && readFeaturesFn, GetMapObjectByIdFn && getMapObjectByIdFn);
|
||||
LocalAdsManager(LocalAdsManager && /* localAdsManager */) = default;
|
||||
|
||||
void Startup(BookmarkManager * bmManager, bool isEnabled);
|
||||
void SetDrapeEngine(ref_ptr<df::DrapeEngine> engine);
|
||||
|
@ -80,7 +79,8 @@ public:
|
|||
local_ads::Statistics & GetStatistics() { return m_statistics; }
|
||||
local_ads::Statistics const & GetStatistics() const { return m_statistics; }
|
||||
|
||||
bool Contains(FeatureID const & featureId) const;
|
||||
bool HasAds(FeatureID const & featureId) const;
|
||||
bool HasVisualization(FeatureID const & featureId) const;
|
||||
bool IsSupportedType(feature::TypesHolder const & types) const;
|
||||
|
||||
std::string GetCompanyUrl(FeatureID const & featureId) const;
|
||||
|
@ -98,7 +98,7 @@ private:
|
|||
|
||||
struct CacheEntry
|
||||
{
|
||||
bool m_isCustom = false;
|
||||
bool m_isVisibleOnMap = false;
|
||||
m2::PointD m_position;
|
||||
};
|
||||
using FeaturesCache = std::map<FeatureID, CacheEntry>;
|
||||
|
|
Loading…
Add table
Reference in a new issue