| 725 | } |
| 726 | |
| 727 | Result 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); |
no test coverage detected