Display subtypes in search results

Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
Yannik Bloscheck
2026-01-15 11:41:15 +01:00
parent 41919f61a4
commit 34ddffccb8
3 changed files with 20 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
#include "indexer/feature_data.hpp"
#include "indexer/feature_visibility.hpp"
#include "indexer/ftypes_matcher.hpp"
#include "indexer/ftypes_subtypes.hpp"
#include "indexer/scales.hpp"
#include "platform/distance.hpp"
@@ -440,6 +441,19 @@ vector<int8_t> GetDescriptionLangPriority(RegionData const & regionData)
return PrioritizedLanguages(preferredLangs, DefaultLanguage(regionData, preferredLangs));
}
vector<string> GetLocalizedSubtypes(TypesHolder const & types)
{
TypesHolder copiedTypes = types;
copiedTypes.SortBySpec();
auto const & classificator = classif();
auto subtypes = ftypes::Subtypes::Instance();
vector<string> localizedSubtypes;
for (auto const type : copiedTypes)
if (subtypes.IsSubtype(type))
localizedSubtypes.push_back(platform::GetLocalizedTypeName(classificator.GetReadableObjectName(type)));
return localizedSubtypes;
}
vector<string> GetCuisines(TypesHolder const & types)
{
auto const & isCuisine = ftypes::IsCuisineChecker::Instance();

View File

@@ -149,6 +149,9 @@ bool GetPreferredName(StringUtf8Multilang const & src, int8_t deviceLang, std::s
/// - default language code;
std::vector<int8_t> GetDescriptionLangPriority(RegionData const & regionData);
// Returns vector of subtypes localized by platform.
std::vector<std::string> GetLocalizedSubtypes(TypesHolder const & types);
// Returns vector of cuisines readable names from classificator.
std::vector<std::string> GetCuisines(TypesHolder const & types);

View File

@@ -287,6 +287,8 @@ void FillDetails(FeatureType & ft, std::string const & name, Result::Details & d
if (isHotel && strings::to_uint(ft.GetMetadata(feature::Metadata::FMD_STARS), starsCount))
stars = feature::FormatStars(starsCount);
auto const subtypes = strings::JoinStrings(feature::GetLocalizedSubtypes(typesHolder), feature::kFieldsSeparator);
auto const cuisines = feature::GetLocalizedCuisines(typesHolder);
auto const cuisine = strings::JoinStrings(cuisines, feature::kFieldsSeparator);
@@ -318,6 +320,7 @@ void FillDetails(FeatureType & ft, std::string const & name, Result::Details & d
append(elevation);
append(cuisine);
append(recycling);
append(subtypes);
append(fee);
details.m_description = std::move(description);