| 118 | using CrossBorderIndexes = std::vector<size_t>; |
| 119 | |
| 120 | std::pair<NodePoints, CrossBorderIndexes> GetCrossBorderPoints( |
| 121 | std::vector<uint64_t> const & nodeIds, ankerl::unordered_dense::map<uint64_t, ms::LatLon> const & nodes, |
| 122 | feature::CountriesFilesAffiliation const & mwmMatcher, |
| 123 | ankerl::unordered_dense::map<std::string, NumMwmId> const & regionToIdMap) |
| 124 | { |
| 125 | NodePoints nodePoints; |
| 126 | CrossBorderIndexes crossBorderIndexes; |
| 127 | |
| 128 | std::string prevRegion; |
| 129 | m2::PointD prevPoint; |
| 130 | |
| 131 | for (auto const & nodeId : nodeIds) |
| 132 | { |
| 133 | auto const itNodes = nodes.find(nodeId); |
| 134 | CHECK(itNodes != nodes.end(), (nodeId)); |
| 135 | |
| 136 | m2::PointD const & curPoint = mercator::FromLatLon(itNodes->second); |
| 137 | auto const & regions = mwmMatcher.GetAffiliations(curPoint); |
| 138 | |
| 139 | if (regions.size() > 1) |
| 140 | { |
| 141 | LOG(LWARNING, ("Point", itNodes->second, "belongs to multiple mwms:", regions)); |
| 142 | continue; |
| 143 | } |
| 144 | |
| 145 | if (regions.empty()) |
| 146 | { |
| 147 | LOG(LWARNING, ("Point", itNodes->second, "doesn't belong to any mwm.")); |
| 148 | continue; |
| 149 | } |
| 150 | |
| 151 | auto const & curRegion = regions[0]; |
| 152 | auto const & curMwmId = regionToIdMap.at(curRegion); |
| 153 | nodePoints.emplace_back(curPoint, curMwmId); |
| 154 | |
| 155 | if (curRegion != prevRegion) |
| 156 | { |
| 157 | if (!prevRegion.empty()) |
| 158 | { |
| 159 | CHECK_GREATER(nodePoints.size(), 1, ()); |
| 160 | // We add index of the previous point. |
| 161 | crossBorderIndexes.push_back(nodePoints.size() - 2); |
| 162 | } |
| 163 | |
| 164 | prevRegion = curRegion; |
| 165 | } |
| 166 | |
| 167 | prevPoint = curPoint; |
| 168 | } |
| 169 | |
| 170 | return std::make_pair(nodePoints, crossBorderIndexes); |
| 171 | } |
| 172 | |
| 173 | std::optional<std::pair<m2::PointD, double>> GetPointInMwm(NodePoints const & points, size_t index, bool forward) |
| 174 | { |
no test coverage detected