| 2232 | } |
| 2233 | |
| 2234 | void Storage::GetTopmostNodesFor(CountryId const & countryId, CountriesVec & nodes, size_t level) const |
| 2235 | { |
| 2236 | nodes.clear(); |
| 2237 | |
| 2238 | CountryTree::NodesBufferT treeNodes; |
| 2239 | m_countries.Find(countryId, treeNodes); |
| 2240 | if (treeNodes.empty()) |
| 2241 | { |
| 2242 | LOG(LWARNING, ("CountryId =", countryId, "not found in m_countries.")); |
| 2243 | return; |
| 2244 | } |
| 2245 | |
| 2246 | nodes.resize(treeNodes.size()); |
| 2247 | for (size_t i = 0; i < treeNodes.size(); ++i) |
| 2248 | { |
| 2249 | nodes[i] = countryId; |
| 2250 | CountriesVec path; |
| 2251 | ForEachAncestorExceptForTheRoot( |
| 2252 | {treeNodes[i]}, [&path](CountryId const & id, CountryTree::Node const &) { path.emplace_back(id); }); |
| 2253 | if (!path.empty() && level < path.size()) |
| 2254 | nodes[i] = path[path.size() - 1 - level]; |
| 2255 | } |
| 2256 | } |
| 2257 | |
| 2258 | CountryId const Storage::GetParentIdFor(CountryId const & countryId) const |
| 2259 | { |