opentable is added into placepage

This commit is contained in:
Arsentiy Milchakov 2016-10-18 15:12:04 +03:00
parent f179d5cd0d
commit 6837b68533
5 changed files with 49 additions and 19 deletions

View file

@ -476,6 +476,18 @@ IsFoodChecker const & IsFoodChecker::Instance()
return instance;
}
IsOpentableChecker::IsOpentableChecker()
{
Classificator const & c = classif();
m_types.push_back(c.GetTypeByPath({"sponsored", "opentable"}));
}
IsOpentableChecker const & IsOpentableChecker::Instance()
{
static IsOpentableChecker const inst;
return inst;
}
uint32_t GetPopulation(FeatureType const & ft)
{
uint32_t population = ft.GetPopulation();

View file

@ -184,6 +184,14 @@ public:
static IsFoodChecker const & Instance();
};
class IsOpentableChecker : public BaseChecker
{
IsOpentableChecker();
public:
static IsOpentableChecker const & Instance();
};
/// Type of locality (do not change values and order - they have detalization order)
/// COUNTRY < STATE < CITY < ...
enum Type { NONE = -1, COUNTRY = 0, STATE, CITY, TOWN, VILLAGE, LOCALITY_COUNT };

View file

@ -789,17 +789,22 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info
if (ftypes::IsAddressObjectChecker::Instance()(ft))
info.m_address = GetAddressInfoAtPoint(feature::GetCenter(ft)).FormatHouseAndStreet();
info.m_isHotel = ftypes::IsHotelChecker::Instance()(ft);
if (ftypes::IsBookingChecker::Instance()(ft))
{
info.m_isSponsoredHotel = true;
info.m_sponsoredType = SponsoredType::Booking;
string const & baseUrl = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE);
info.m_sponsoredBookingUrl = GetBookingApi().GetBookingUrl(baseUrl);
info.m_sponsoredUrl = GetBookingApi().GetBookingUrl(baseUrl);
info.m_sponsoredDescriptionUrl = GetBookingApi().GetDescriptionUrl(baseUrl);
}
else if (ftypes::IsOpentableChecker::Instance()(ft))
{
info.m_sponsoredType = SponsoredType::Opentable;
info.m_sponsoredUrl = info.GetMetadata().Get(feature::Metadata::FMD_WEBSITE);
}
info.m_canEditOrAdd = featureStatus != osm::Editor::FeatureStatus::Obsolete && CanEditMap() &&
!info.IsSponsoredHotel();
!info.IsSponsored();
info.m_localizedWifiString = m_stringsBundle.GetString("wifi");
info.m_localizedRatingString = m_stringsBundle.GetString("place_page_booking_rating");
@ -1979,7 +1984,7 @@ void Framework::ActivateMapSelection(bool needAnimation, df::SelectionShape::ESe
CallDrapeFunction(bind(&df::DrapeEngine::SelectObject, _1, selectionType, info.GetMercator(), info.GetID(),
needAnimation));
SetDisplacementMode(DisplacementModeManager::SLOT_MAP_SELECTION, info.IsHotel() /* show */);
SetDisplacementMode(DisplacementModeManager::SLOT_MAP_SELECTION, ftypes::IsHotelChecker::Instance()(info.GetTypes()) /* show */);
if (m_activateMapSelectionFn)
m_activateMapSelectionFn(info);
@ -2055,7 +2060,7 @@ void Framework::OnTapEvent(TapEvent const & tapEvent)
// Older version of statistics used "$GetUserMark" event.
alohalytics::Stats::Instance().LogEvent("$SelectMapObject", kv, alohalytics::Location::FromLatLon(ll.lat, ll.lon));
if (info.IsHotel())
if (info.m_sponsoredType == SponsoredType::Booking)
GetPlatform().SendMarketingEvent("Placepage_Hotel_book", {{"provider", "booking.com"}});
}

View file

@ -16,8 +16,7 @@ char const * const Info::kPricingSymbol = "$";
bool Info::IsFeature() const { return m_featureID.IsValid(); }
bool Info::IsBookmark() const { return m_bac.IsValid(); }
bool Info::IsMyPosition() const { return m_isMyPosition; }
bool Info::IsSponsoredHotel() const { return m_isSponsoredHotel; }
bool Info::IsHotel() const { return m_isHotel; }
bool Info::IsSponsored() const { return m_sponsoredType != SponsoredType::None; }
bool Info::ShouldShowAddPlace() const
{
auto const isPointOrBuilding = IsPointType() || IsBuilding();
@ -116,12 +115,12 @@ BookmarkAndCategory Info::GetBookmarkAndCategory() const { return m_bac; }
string Info::GetBookmarkCategoryName() const { return m_bookmarkCategoryName; }
string const & Info::GetApiUrl() const { return m_apiUrl; }
string const & Info::GetSponsoredBookingUrl() const { return m_sponsoredBookingUrl; }
string const & Info::GetSponsoredUrl() const { return m_sponsoredUrl; }
string const & Info::GetSponsoredDescriptionUrl() const {return m_sponsoredDescriptionUrl; }
string Info::GetRatingFormatted() const
{
if (!IsSponsoredHotel())
if (!IsSponsored())
return string();
auto const r = GetMetadata().Get(feature::Metadata::FMD_RATING);
@ -140,7 +139,7 @@ string Info::GetRatingFormatted() const
string Info::GetApproximatePricing() const
{
if (!IsSponsoredHotel())
if (!IsSponsored())
return string();
int pricing;

View file

@ -14,6 +14,14 @@
#include "std/string.hpp"
enum class SponsoredType
{
None,
Booking,
Opentable,
Geochat
};
namespace place_page
{
class Info : public osm::MapObject
@ -28,8 +36,7 @@ public:
bool IsFeature() const;
bool IsBookmark() const;
bool IsMyPosition() const;
bool IsSponsoredHotel() const;
bool IsHotel() const;
bool IsSponsored() const;
bool ShouldShowAddPlace() const;
bool ShouldShowAddBusiness() const;
@ -62,7 +69,7 @@ public:
string GetBookmarkCategoryName() const;
string const & GetApiUrl() const;
string const & GetSponsoredBookingUrl() const;
string const & GetSponsoredUrl() const;
string const & GetSponsoredDescriptionUrl() const;
/// @returns formatted rating string for booking object, or empty if it isn't booking object
@ -90,12 +97,11 @@ public:
string m_apiUrl;
/// Formatted feature address.
string m_address;
/// Feature is a hotel.
bool m_isHotel = false;
/// Feature is a sponsored hotel.
bool m_isSponsoredHotel = false;
/// Sponsored type or None.
SponsoredType m_sponsoredType = SponsoredType::None;
/// Sponsored feature urls.
string m_sponsoredBookingUrl;
string m_sponsoredUrl;
string m_sponsoredDescriptionUrl;
/// Which country this MapObject is in.