[search] Added hotel rating and hotel pricing to result metadata.
This commit is contained in:
parent
bc98ef2a67
commit
203b634334
2 changed files with 26 additions and 5 deletions
|
@ -26,7 +26,8 @@ namespace search
|
|||
/// All constants in meters.
|
||||
double const DIST_EQUAL_RESULTS = 100.0;
|
||||
double const DIST_SAME_STREET = 5000.0;
|
||||
|
||||
char const * const kEmptyRatingSymbol = "-";
|
||||
char const * const kPricingSymbol = "$";
|
||||
|
||||
void ProcessMetadata(FeatureType const & ft, Result::Metadata & meta)
|
||||
{
|
||||
|
@ -52,9 +53,26 @@ void ProcessMetadata(FeatureType const & ft, Result::Metadata & meta)
|
|||
meta.m_stars = my::clamp(meta.m_stars, 0, 5);
|
||||
else
|
||||
meta.m_stars = 0;
|
||||
|
||||
meta.m_isSponsoredHotel = ftypes::IsBookingChecker::Instance()(ft);
|
||||
|
||||
|
||||
bool const isSponsoredHotel = ftypes::IsBookingChecker::Instance()(ft);
|
||||
meta.m_isSponsoredHotel = isSponsoredHotel;
|
||||
|
||||
if (isSponsoredHotel)
|
||||
{
|
||||
auto const r = src.Get(feature::Metadata::FMD_RATING);
|
||||
char const * const rating = r.empty() ? kEmptyRatingSymbol : r.c_str();
|
||||
meta.m_hotelRating = rating;
|
||||
|
||||
int pricing;
|
||||
strings::to_int(src.Get(feature::Metadata::FMD_PRICE_RATE), pricing);
|
||||
string pricingStr;
|
||||
CHECK_GREATER_OR_EQUAL(pricing, 0, ("Pricing must be positive!"));
|
||||
for (auto i = 0; i < pricing; i++)
|
||||
pricingStr.append(kPricingSymbol);
|
||||
|
||||
meta.m_hotelApproximatePricing = pricingStr;
|
||||
}
|
||||
|
||||
meta.m_isInitialized = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ public:
|
|||
int m_stars = 0; // Valid only if not 0. Used for hotels.
|
||||
bool m_isSponsoredHotel = false; // Used for hotels.
|
||||
osm::YesNoUnknown m_isOpenNow = osm::Unknown; // Valid for any result.
|
||||
|
||||
string m_hotelApproximatePricing;
|
||||
string m_hotelRating;
|
||||
/// True if the struct is already assigned or need to be calculated otherwise.
|
||||
bool m_isInitialized = false;
|
||||
};
|
||||
|
@ -59,6 +60,8 @@ public:
|
|||
string const & GetAddress() const { return m_address; }
|
||||
string const & GetFeatureType() const { return m_type; }
|
||||
string const & GetCuisine() const { return m_metadata.m_cuisine; }
|
||||
string const & GetHotelRating() const { return m_metadata.m_hotelRating; }
|
||||
string const & GetHotelApproximatePricing() const { return m_metadata.m_hotelApproximatePricing; }
|
||||
//@}
|
||||
|
||||
osm::YesNoUnknown IsOpenNow() const { return m_metadata.m_isOpenNow; }
|
||||
|
|
Reference in a new issue