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

Method MakeResult

libs/search/ranker.cpp:727–791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

725}
726
727Result Ranker::MakeResult(RankerResult const & rankerResult, bool needAddress, bool needHighlighting) const
728{
729 Result res(rankerResult.GetCenter(), rankerResult.m_str);
730
731 if (needAddress)
732 {
733 string address = GetLocalizedRegionInfoForResult(rankerResult);
734
735 // Format full address only for suitable results.
736 if (ftypes::IsAddressObjectChecker::Instance()(rankerResult.GetTypes()))
737 {
738 ReverseGeocoder::Address addr;
739 if (!(rankerResult.GetID().IsValid() && m_reverseGeocoder.GetExactAddress(rankerResult.GetID(), addr)))
740 m_reverseGeocoder.GetNearbyAddress(rankerResult.GetCenter(), addr);
741
742 address = FormatFullAddress(addr, address);
743 }
744
745 res.SetAddress(std::move(address));
746 }
747
748 switch (rankerResult.GetResultType())
749 {
750 case RankerResult::Type::Feature:
751 case RankerResult::Type::Building:
752 res.FromFeature(rankerResult.GetID(), rankerResult.GetBestType(),
753 rankerResult.GetBestType(&m_params.m_preferredTypes), rankerResult.m_details);
754
755 // Extract branch metadata if available
756 if (rankerResult.GetID().IsValid())
757 {
758 m_dataSource.ReadFeature([&](FeatureType & ft)
759 {
760 auto const branch = ft.GetMetadata(feature::Metadata::FMD_BRANCH);
761 if (!branch.empty())
762 res.SetBranch(std::string(branch));
763 }, rankerResult.GetID());
764 }
765 break;
766 case RankerResult::Type::LatLon: res.SetType(Result::Type::LatLon); break;
767 case RankerResult::Type::Postcode: res.SetType(Result::Type::Postcode); break;
768 }
769
770 if (needAddress &&
771 ftypes::IsLocalityChecker::Instance().GetType(rankerResult.GetTypes()) == ftypes::LocalityType::None)
772 {
773 m_localities.GetLocality(res.GetFeatureCenter(), [&](LocalityItem const & item)
774 {
775 std::string const city = item.GetReadableName();
776 if (!city.empty())
777 res.PrependCity(city);
778 });
779 }
780
781 if (needHighlighting)
782 HighlightResult(m_params.m_query.m_tokens, m_params.m_query.m_prefix, res);
783
784 res.SetRankingInfo(rankerResult.m_dbgInfo);

Callers 4

SearchCoordinatesMethod · 0.45
SearchPlusCodeMethod · 0.45
SearchPostcodeMethod · 0.45
EmitResultsFromMwmsMethod · 0.45

Calls 15

FormatFullAddressFunction · 0.85
HighlightResultFunction · 0.85
GetNearbyAddressMethod · 0.80
ReadFeatureMethod · 0.80
SetBranchMethod · 0.80
GetLocalityMethod · 0.80
PrependCityMethod · 0.80
SetProvenanceMethod · 0.80
GetCenterMethod · 0.45
GetTypesMethod · 0.45
IsValidMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected