[omim] Added booking data to place page.

This commit is contained in:
VladiMihaylenko 2016-05-19 18:45:47 +03:00
parent a36f847423
commit 055e930ef3
5 changed files with 47 additions and 7 deletions

View file

@ -66,6 +66,7 @@ void MapObject::SetFromFeatureType(FeatureType const & ft)
m_featureID = ft.GetID();
ASSERT(m_featureID.IsValid(), ());
m_geomType = ft.GetFeatureType();
m_isBookingObject = ftypes::IsBookingChecker::Instance()(ft);
}
FeatureID const & MapObject::GetID() const { return m_featureID; }
@ -189,11 +190,8 @@ string MapObject::GetBuildingLevels() const
}
feature::Metadata const & MapObject::GetMetadata() const { return m_metadata; }
bool MapObject::IsPointType() const { return m_geomType == feature::EGeomType::GEOM_POINT; }
bool MapObject::IsBuilding() const { return ftypes::IsBuildingChecker::Instance()(m_types); }
bool MapObject::IsBookingObject() const { return m_isBookingObject; }
bool MapObject::IsBuilding() const
{
return ftypes::IsBuildingChecker::Instance()(m_types);
}
} // namespace osm

View file

@ -88,7 +88,6 @@ public:
string GetWikipediaLink() const;
string GetFlats() const;
string GetBuildingLevels() const;
//@}
// TODO(Vlad, yunikkk): Use Props enum + getters instead of direct metadata access.
// TODO: Remove this method.
@ -97,6 +96,7 @@ public:
bool IsPointType() const;
/// @returns true if object is of building type.
bool IsBuilding() const;
bool IsBookingObject() const;
protected:
FeatureID m_featureID;
@ -106,6 +106,8 @@ protected:
feature::Metadata m_metadata;
feature::EGeomType m_geomType = feature::EGeomType::GEOM_UNDEFINED;
private:
bool m_isBookingObject;
};
/// Helper to convert internal feature::Metadata::FMD_* enum into a users-visible one.

View file

@ -721,6 +721,7 @@ void Framework::FillInfoFromFeatureType(FeatureType const & ft, place_page::Info
info.m_isEditable = osm::Editor::Instance().GetEditableProperties(ft).IsEditable();
info.m_localizedWifiString = m_stringsBundle.GetString("wifi");
info.m_localizedRatingString = m_stringsBundle.GetString("place_page_booking_rating");
if (ftypes::IsAddressObjectChecker::Instance()(ft))
info.m_address = GetAddressInfoAtPoint(feature::GetCenter(ft)).FormatHouseAndStreet();

View file

@ -9,6 +9,8 @@ namespace place_page
char const * Info::kSubtitleSeparator = "";
char const * Info::kStarSymbol = "";
char const * Info::kMountainSymbol = "";
char const * Info::kEmptyRatingSymbol = "-";
char const * Info::kPricingSymbol = "$";
bool Info::IsFeature() const { return m_featureID.IsValid(); }
bool Info::IsBookmark() const { return m_bac != MakeEmptyBookmarkAndCategory(); }
@ -97,5 +99,33 @@ string Info::GetCustomName() const { return m_customName; }
BookmarkAndCategory Info::GetBookmarkAndCategory() const { return m_bac; }
string Info::GetBookmarkCategoryName() const { return m_bookmarkCategoryName; }
string const & Info::GetApiUrl() const { return m_apiUrl; }
string Info::GetRatingFormatted() const
{
if (!IsBookingObject())
return "";
auto const r = GetMetadata().Get(feature::Metadata::FMD_RATING);
char const * rating = r.empty() ? kEmptyRatingSymbol : r.c_str();
int const sz = snprintf(nullptr, 0, m_localizedRatingString.c_str(), rating);
vector<char> buf(sz + 1);
snprintf(&buf[0], buf.size(), m_localizedRatingString.c_str(), rating);
return string(buf.begin(), buf.end());
}
string Info::GetApproximatelyPricing() const
{
if (!IsBookingObject())
return "";
uint64_t pricing;
strings::to_uint64(GetMetadata().Get(feature::Metadata::FMD_PRICE_RATE), pricing);
string result;
for (auto i = 0; i < pricing; i++)
result.append("$");
return result;
}
void Info::SetMercator(m2::PointD const & mercator) { m_mercator = mercator; }
} // namespace place_page

View file

@ -22,6 +22,8 @@ public:
static char const * kSubtitleSeparator;
static char const * kStarSymbol;
static char const * kMountainSymbol;
static char const * kEmptyRatingSymbol;
static char const * kPricingSymbol;
bool IsFeature() const;
bool IsBookmark() const;
@ -53,6 +55,11 @@ public:
string GetBookmarkCategoryName() const;
string const & GetApiUrl() const;
/// @returns formatted rating string for booking object, or empty if it's doesn't booking object
string GetRatingFormatted() const;
/// @returns string with "$" signs or empty string if it's doesn't booking object
string GetApproximatelyPricing() const;
void SetMercator(m2::PointD const & mercator);
/// Comes from API, shared links etc.
@ -73,11 +80,13 @@ public:
/// Which country this MapObject is in.
/// For a country point it will be set to topmost node for country.
storage::TCountryId m_countryId = storage::kInvalidCountryId;
bool m_isMyPosition = false;
bool m_isEditable = false;
// TODO(AlexZ): Temporary solution. It's better to use a wifi icon in UI instead of text.
string m_localizedWifiString;
/// Booking rating string
string m_localizedRatingString;
};
} // namespace place_page