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

Method SearchPlusCode

libs/search/processor.cpp:693–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

691}
692
693void Processor::SearchPlusCode()
694{
695 // Create a copy of the query to trim it in-place.
696 string query(m_query.m_query);
697 strings::Trim(query);
698
699 if (openlocationcode::IsFull(query))
700 {
701 openlocationcode::CodeArea const area = openlocationcode::Decode(query);
702 m_emitter.AddResultNoChecks(m_ranker.MakeResult(RankerResult(area.GetCenter().latitude, area.GetCenter().longitude),
703 true /* needAddress */, false /* needHighlighting */));
704 }
705 else if (openlocationcode::IsShort(query))
706 {
707 string codeFromPos;
708
709 if (m_position)
710 {
711 ms::LatLon const latLonFromPos = mercator::ToLatLon(*m_position);
712 codeFromPos = openlocationcode::RecoverNearest(query, {latLonFromPos.m_lat, latLonFromPos.m_lon});
713 openlocationcode::CodeArea const areaFromPos = openlocationcode::Decode(codeFromPos);
714
715 m_emitter.AddResultNoChecks(
716 m_ranker.MakeResult(RankerResult(areaFromPos.GetCenter().latitude, areaFromPos.GetCenter().longitude),
717 true /* needAddress */, false /* needHighlighting */));
718 }
719
720 ms::LatLon const latLonFromView = mercator::ToLatLon(m_viewport.Center());
721 string codeFromView = openlocationcode::RecoverNearest(query, {latLonFromView.m_lat, latLonFromView.m_lon});
722
723 if (codeFromView != codeFromPos)
724 {
725 openlocationcode::CodeArea const areaFromView = openlocationcode::Decode(codeFromView);
726
727 m_emitter.AddResultNoChecks(
728 m_ranker.MakeResult(RankerResult(areaFromView.GetCenter().latitude, areaFromView.GetCenter().longitude),
729 true /* needAddress */, false /* needHighlighting */));
730 }
731 }
732
733 m_emitter.Emit();
734}
735
736void Processor::SearchPostcode()
737{

Callers

nothing calls this directly

Calls 12

TrimFunction · 0.85
IsFullFunction · 0.85
RankerResultClass · 0.85
IsShortFunction · 0.85
RecoverNearestFunction · 0.85
DecodeFunction · 0.50
ToLatLonFunction · 0.50
AddResultNoChecksMethod · 0.45
MakeResultMethod · 0.45
GetCenterMethod · 0.45
CenterMethod · 0.45
EmitMethod · 0.45

Tested by

no test coverage detected