| 388 | } |
| 389 | |
| 390 | uint32_t Router::GetReverseBearing(Vertex const & u, Links const & links) const |
| 391 | { |
| 392 | m2::PointD const a = u.m_junction.GetPoint(); |
| 393 | m2::PointD b = m2::PointD::Zero(); |
| 394 | |
| 395 | Vertex curr = u; |
| 396 | double passed = 0; |
| 397 | bool found = false; |
| 398 | while (true) |
| 399 | { |
| 400 | auto const it = links.find(curr); |
| 401 | if (it == links.end()) |
| 402 | break; |
| 403 | |
| 404 | auto const & p = it->second; |
| 405 | auto const & prev = p.first; |
| 406 | auto const & edge = p.second.m_raw; |
| 407 | |
| 408 | if (prev.m_stage != curr.m_stage) |
| 409 | break; |
| 410 | |
| 411 | double const weight = GetWeight(edge); |
| 412 | |
| 413 | if (passed + weight >= kBearingDist) |
| 414 | { |
| 415 | double const delta = kBearingDist - passed; |
| 416 | b = PointAtSegment(edge.GetEndJunction().GetPoint(), edge.GetStartJunction().GetPoint(), delta); |
| 417 | found = true; |
| 418 | break; |
| 419 | } |
| 420 | |
| 421 | passed += weight; |
| 422 | curr = prev; |
| 423 | } |
| 424 | if (!found) |
| 425 | b = curr.m_junction.GetPoint(); |
| 426 | return Bearing(a, b); |
| 427 | } |
| 428 | |
| 429 | template <typename Fn> |
| 430 | void Router::ForEachEdge(Vertex const & u, bool outgoing, FunctionalRoadClass restriction, Fn && fn) |