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

Method SearchPostcode

libs/search/processor.cpp:736–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

734}
735
736void Processor::SearchPostcode()
737{
738 // Create a copy of the query to trim it in-place.
739 string_view query(m_query.m_query);
740 strings::Trim(query);
741
742 /// @todo So, "G4 " now doesn't match UK (Glasgow) postcodes as prefix :)
743 if (!LooksLikePostcode(query, !m_query.m_prefix.empty()))
744 return;
745
746 vector<shared_ptr<MwmInfo>> infos;
747 m_dataSource.GetMwmsInfo(infos);
748
749 auto const normQuery = NormalizeAndSimplifyString(query);
750 for (auto const & info : infos)
751 {
752 auto handle = m_dataSource.GetMwmHandleById(MwmSet::MwmId(info));
753 if (!handle.IsAlive())
754 continue;
755 auto & value = *handle.GetValue();
756 if (!value.m_cont.IsExist(POSTCODE_POINTS_FILE_TAG))
757 continue;
758
759 /// @todo Well, ok for now, but we do only full or "prefix-rect" match w/o possible errors, with only one result.
760 PostcodePoints postcodes(value);
761 vector<m2::PointD> points;
762 postcodes.Get(normQuery, points);
763 if (points.empty())
764 continue;
765
766 m2::RectD r;
767 for (auto const & p : points)
768 r.Add(p);
769
770 m_emitter.AddResultNoChecks(
771 m_ranker.MakeResult(RankerResult(r.Center(), query), true /* needAddress */, true /* needHighlighting */));
772 m_emitter.Emit();
773
774 return;
775 }
776}
777
778void Processor::SearchBookmarks(bookmarks::GroupId const & groupId)
779{

Callers

nothing calls this directly

Calls 15

TrimFunction · 0.85
LooksLikePostcodeFunction · 0.85
MwmIdClass · 0.85
RankerResultClass · 0.85
GetMwmsInfoMethod · 0.80
IsExistMethod · 0.80
emptyMethod · 0.45
GetMwmHandleByIdMethod · 0.45
IsAliveMethod · 0.45
GetValueMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected