[omim] Review fixes.

This commit is contained in:
VladiMihaylenko 2016-05-19 18:57:12 +03:00
parent 055e930ef3
commit 6dbaf99573
4 changed files with 33 additions and 30 deletions

View file

@ -66,7 +66,6 @@ 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; }
@ -192,6 +191,5 @@ 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; }
} // namespace osm

View file

@ -96,7 +96,6 @@ public:
bool IsPointType() const;
/// @returns true if object is of building type.
bool IsBuilding() const;
bool IsBookingObject() const;
protected:
FeatureID m_featureID;
@ -106,8 +105,6 @@ 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

@ -6,11 +6,11 @@
namespace place_page
{
char const * Info::kSubtitleSeparator = "";
char const * Info::kStarSymbol = "";
char const * Info::kMountainSymbol = "";
char const * Info::kEmptyRatingSymbol = "-";
char const * Info::kPricingSymbol = "$";
char const * const Info::kSubtitleSeparator = "";
char const * const Info::kStarSymbol = "";
char const * const Info::kMountainSymbol = "";
char const * const Info::kEmptyRatingSymbol = "-";
char const * const Info::kPricingSymbol = "$";
bool Info::IsFeature() const { return m_featureID.IsValid(); }
bool Info::IsBookmark() const { return m_bac != MakeEmptyBookmarkAndCategory(); }
@ -18,7 +18,8 @@ bool Info::IsMyPosition() const { return m_isMyPosition; }
bool Info::HasApiUrl() const { return !m_apiUrl.empty(); }
bool Info::IsEditable() const { return m_isEditable; }
bool Info::HasWifi() const { return GetInternet() == osm::Internet::Wlan; }
bool Info::ShouldShowAddPlace() const { return !IsFeature() || (!IsPointType() && !IsBuilding()); }
bool Info::ShouldShowAddPlace() const { return !IsSponsoredHotel() && (!IsFeature() || (!IsPointType() && !IsBuilding())); }
bool Info::IsSponsoredHotel() const { return m_isSponsoredHotel; }
string Info::FormatNewBookmarkName() const
{
@ -102,27 +103,33 @@ string const & Info::GetApiUrl() const { return m_apiUrl; }
string Info::GetRatingFormatted() const
{
if (!IsBookingObject())
return "";
if (!IsSponsoredHotel())
return string();
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);
int const size = snprintf(nullptr, 0, m_localizedRatingString.c_str(), rating);
if (size < 0)
{
LOG(LERROR, ("Incorrect size for string:", m_localizedRatingString, ", rating:", rating));
return string();
}
vector<char> buf(sz + 1);
snprintf(&buf[0], buf.size(), m_localizedRatingString.c_str(), rating);
vector<char> buf(size + 1);
snprintf(buf.data(), buf.size(), m_localizedRatingString.c_str(), rating);
return string(buf.begin(), buf.end());
}
string Info::GetApproximatelyPricing() const
string Info::GetApproximatePricing() const
{
if (!IsBookingObject())
return "";
uint64_t pricing;
strings::to_uint64(GetMetadata().Get(feature::Metadata::FMD_PRICE_RATE), pricing);
if (!IsSponsoredHotel())
return string();
int pricing;
strings::to_int(GetMetadata().Get(feature::Metadata::FMD_PRICE_RATE), pricing);
string result;
for (auto i = 0; i < pricing; i++)
result.append("$");
result.append(kPricingSymbol);
return result;
}

View file

@ -19,16 +19,17 @@ namespace place_page
class Info : public osm::MapObject
{
public:
static char const * kSubtitleSeparator;
static char const * kStarSymbol;
static char const * kMountainSymbol;
static char const * kEmptyRatingSymbol;
static char const * kPricingSymbol;
static char const * const kSubtitleSeparator;
static char const * const kStarSymbol;
static char const * const kMountainSymbol;
static char const * const kEmptyRatingSymbol;
static char const * const kPricingSymbol;
bool IsFeature() const;
bool IsBookmark() const;
bool IsMyPosition() const;
bool ShouldShowAddPlace() const;
bool IsSponsoredHotel() const;
/// @returns true if Back API button should be displayed.
bool HasApiUrl() const;
/// @returns true if Edit Place button should be displayed.
@ -55,10 +56,10 @@ public:
string GetBookmarkCategoryName() const;
string const & GetApiUrl() const;
/// @returns formatted rating string for booking object, or empty if it's doesn't booking object
/// @returns formatted rating string for booking object, or empty if it isn't booking object
string GetRatingFormatted() const;
/// @returns string with "$" signs or empty string if it's doesn't booking object
string GetApproximatelyPricing() const;
/// @returns string with |kPricingSymbol| signs or empty string if it isn't booking object
string GetApproximatePricing() const;
void SetMercator(m2::PointD const & mercator);