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

Method Get

libs/search/postcode_points.cpp:63–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void PostcodePoints::Get(UniString const & postcode, bool recursive, vector<m2::PointD> & points) const
64{
65 if (!m_root || !m_points || !m_trieSubReader || !m_pointsSubReader || postcode.empty())
66 return;
67
68 auto postcodeIt = postcode.begin();
69 auto trieIt = m_root->Clone();
70
71 while (postcodeIt != postcode.end())
72 {
73 auto it = find_if(trieIt->m_edges.begin(), trieIt->m_edges.end(), [&](auto const & edge)
74 { return StartsWith(postcodeIt, postcode.end(), edge.m_label.begin(), edge.m_label.end()); });
75 if (it == trieIt->m_edges.end())
76 return;
77
78 postcodeIt += it->m_label.size();
79 trieIt = trieIt->GoToEdge(distance(trieIt->m_edges.begin(), it));
80 }
81
82 if (postcodeIt != postcode.end())
83 return;
84
85 vector<uint32_t> indexes;
86 trieIt->m_values.ForEach([&indexes](auto const & v)
87 { indexes.push_back(base::asserted_cast<uint32_t>(v.m_featureId)); });
88
89 if (recursive)
90 {
91 trie::ForEachRef(*trieIt, [&indexes](auto const & /* s */, auto const & v)
92 { indexes.push_back(base::asserted_cast<uint32_t>(v.m_featureId)); }, UniString{});
93 }
94
95 points.resize(indexes.size());
96 for (size_t i = 0; i < indexes.size(); ++i)
97 CHECK(m_points->Get(indexes[i], points[i]), ());
98}
99
100void PostcodePoints::Get(UniString const & postcode, vector<m2::PointD> & points) const
101{

Callers

nothing calls this directly

Calls 14

distanceFunction · 0.85
ForEachRefFunction · 0.85
GetFunction · 0.85
StartsWithFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
CloneMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
GoToEdgeMethod · 0.45
ForEachMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected