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

Method EmitResultsFromMwms

libs/search/processor.cpp:933–963  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

931
932template <class FnT>
933void Processor::EmitResultsFromMwms(std::vector<std::shared_ptr<MwmInfo>> const & infos, FnT const & fn)
934{
935 // Don't pay attention on possible overhead here, this function is used for debug purpose only.
936 std::vector<std::tuple<double, std::string, std::unique_ptr<FeatureType>>> results;
937 std::vector<std::unique_ptr<FeaturesLoaderGuard>> guards;
938
939 for (auto const & info : infos)
940 {
941 auto guard = std::make_unique<FeaturesLoaderGuard>(m_dataSource, MwmSet::MwmId(info));
942
943 fn(*guard, [&](std::unique_ptr<FeatureType> ft)
944 {
945 // Distance needed for sorting.
946 auto const center = feature::GetCenter(*ft, FeatureType::WORST_GEOMETRY);
947 double const dist = center.SquaredLength(m_viewport.Center());
948 results.emplace_back(dist, guard->GetCountryFileName(), std::move(ft));
949 });
950
951 guards.push_back(std::move(guard));
952 }
953
954 std::sort(results.begin(), results.end());
955
956 for (auto const & [_, country, ft] : results)
957 {
958 m_emitter.AddResultNoChecks(
959 m_ranker.MakeResult(RankerResult(*ft, country), true /* needAddress */, true /* needHighlighting */));
960 }
961
962 m_emitter.Emit();
963}
964} // namespace search

Callers

nothing calls this directly

Calls 13

MwmIdClass · 0.85
GetCenterFunction · 0.85
RankerResultClass · 0.85
SquaredLengthMethod · 0.80
GetCountryFileNameMethod · 0.80
CenterMethod · 0.45
emplace_backMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
AddResultNoChecksMethod · 0.45
MakeResultMethod · 0.45

Tested by

no test coverage detected