| 202 | } |
| 203 | |
| 204 | bool FillCrossBorderGraph(CrossBorderGraph & graph, RegionSegmentId & curSegmentId, |
| 205 | std::vector<uint64_t> const & nodeIds, |
| 206 | ankerl::unordered_dense::map<uint64_t, ms::LatLon> const & nodes, |
| 207 | feature::CountriesFilesAffiliation const & mwmMatcher, |
| 208 | ankerl::unordered_dense::map<std::string, NumMwmId> const & regionToIdMap) |
| 209 | { |
| 210 | auto const & [nodePoints, crossBorderIndexes] = GetCrossBorderPoints(nodeIds, nodes, mwmMatcher, regionToIdMap); |
| 211 | |
| 212 | bool insertedRoad = false; |
| 213 | |
| 214 | for (auto i : crossBorderIndexes) |
| 215 | { |
| 216 | auto const & p1 = nodePoints[i]; |
| 217 | auto const & p2 = nodePoints[i + 1]; |
| 218 | |
| 219 | if (MwmRoadsAreFilled(p1.m_mwm, p2.m_mwm, graph)) |
| 220 | continue; |
| 221 | |
| 222 | auto const pMwm1 = GetPointInMwm(nodePoints, i, false /* forward */); |
| 223 | if (!pMwm1) |
| 224 | continue; |
| 225 | |
| 226 | auto const pMwm2 = GetPointInMwm(nodePoints, i + 1, true /* forward */); |
| 227 | if (!pMwm2) |
| 228 | continue; |
| 229 | |
| 230 | double const d = mercator::DistanceOnEarth(p1.m_point, p2.m_point); |
| 231 | |
| 232 | CrossBorderSegment seg; |
| 233 | seg.m_weight = pMwm1->second + d + pMwm2->second; |
| 234 | seg.m_start = CrossBorderSegmentEnding(pMwm1->first /* point */, p1.m_mwm); |
| 235 | seg.m_end = CrossBorderSegmentEnding(pMwm2->first /* point */, p2.m_mwm); |
| 236 | graph.AddCrossBorderSegment(curSegmentId++, seg); |
| 237 | insertedRoad = true; |
| 238 | } |
| 239 | |
| 240 | return insertedRoad; |
| 241 | } |
| 242 | |
| 243 | bool WriteGraphToFile(CrossBorderGraph const & graph, std::string const & path, bool overwrite) |
| 244 | { |
no test coverage detected