| 61 | } |
| 62 | |
| 63 | void 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 | |
| 100 | void PostcodePoints::Get(UniString const & postcode, vector<m2::PointD> & points) const |
| 101 | { |
nothing calls this directly
no test coverage detected