diff --git a/indexer/map_object.cpp b/indexer/map_object.cpp index 927ff1f987..039eac80f9 100644 --- a/indexer/map_object.cpp +++ b/indexer/map_object.cpp @@ -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 diff --git a/indexer/map_object.hpp b/indexer/map_object.hpp index 4929efe00a..dc75cd0a9f 100644 --- a/indexer/map_object.hpp +++ b/indexer/map_object.hpp @@ -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. diff --git a/map/framework.cpp b/map/framework.cpp index 288a20955e..5a31e80d8c 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -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(); diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 24e10b0ec9..1ec175fcdb 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -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 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 diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index 887d92b656..b83148230d 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -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