MCPcopy Create free account
hub / github.com/comaps/comaps / FillDetails

Function FillDetails

libs/search/intermediate_result.cpp:250–328  ·  view source on GitHub ↗

Functions ---------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

248
249// Functions ---------------------------------------------------------------------------------------
250void FillDetails(FeatureType & ft, std::string const & name, Result::Details & details)
251{
252 if (details.m_isInitialized)
253 return;
254
255 std::string_view airportIata = ft.GetMetadata(feature::Metadata::FMD_AIRPORT_IATA);
256
257 std::string brand{ft.GetMetadata(feature::Metadata::FMD_BRAND)};
258 if (!brand.empty())
259 {
260 brand = localisation::TranslatedBrand(brand);
261
262 if (name.find(brand) != std::string::npos)
263 brand.clear();
264 }
265
266 /// @todo Avoid temporary string when OpeningHours (boost::spirit) will allow string_view.
267 std::string const openHours(ft.GetMetadata(feature::Metadata::FMD_OPEN_HOURS));
268 if (!openHours.empty())
269 {
270 using namespace osmoh;
271 OpeningHours const oh((std::string(openHours)));
272 if (oh.IsValid())
273 {
274 /// @todo We should check closed/open time for specific feature's timezone.
275 time_t const now = time(nullptr);
276 auto const info = oh.GetInfo(now);
277 if (info.state != RuleState::Unknown)
278 {
279 // In else case value is osm::Unknown, it's set in preview's constructor.
280 details.m_isOpenNow = (info.state == RuleState::Open) ? osm::Yes : osm::No;
281
282 details.m_minutesUntilOpen = (info.nextTimeOpen - now) / 60;
283 details.m_minutesUntilClosed = (info.nextTimeClosed - now) / 60;
284 }
285 }
286 }
287
288 feature::TypesHolder typesHolder(ft);
289 typesHolder.SortBySpec();
290
291 std::string stars;
292 uint8_t starsCount = 0;
293 bool const isHotel = ftypes::IsHotelChecker::Instance()(typesHolder);
294 if (isHotel && strings::to_uint(ft.GetMetadata(feature::Metadata::FMD_STARS), starsCount))
295 stars = feature::FormatStars(starsCount);
296
297 auto const subtypes = strings::JoinStrings(feature::GetLocalizedSubtypes(typesHolder), feature::kFieldsSeparator);
298
299 auto const roadShields = ftypes::GetRoadShieldsNames(ft);
300 auto const roadShield = strings::JoinStrings(roadShields, feature::kFieldsSeparator);
301
302 auto const fee = feature::GetLocalizedFeeType(typesHolder);
303
304 auto const elevation = feature::FormatElevation(ft.GetMetadata(feature::Metadata::FMD_ELE));
305
306 std::string description;
307

Callers 1

RankerResultMethod · 0.85

Calls 15

TranslatedBrandFunction · 0.85
to_uintFunction · 0.85
FormatStarsFunction · 0.85
JoinStringsFunction · 0.85
GetLocalizedSubtypesFunction · 0.85
GetRoadShieldsNamesFunction · 0.85
GetLocalizedFeeTypeFunction · 0.85
FormatElevationFunction · 0.85
SortBySpecMethod · 0.80
GetMetadataMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected