Welcome to mirror list, hosted at ThFree Co, Russian Federation.

world_graph.cpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3f87783131d730807bce46f8236a912740f1d091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "routing/world_graph.hpp"

namespace routing
{
using namespace std;

void WorldGraph::GetTwins(Segment const & segment, bool isOutgoing, vector<SegmentEdge> & edges)
{
  vector<Segment> twins;
  GetTwinsInner(segment, isOutgoing, twins);

  if (GetMode() == Mode::LeapsOnly)
  {
    // Ingoing edges listing is not supported in LeapsOnly mode because we do not have enough
    // information to calculate |segment| weight. See https://jira.mail.ru/browse/MAPSME-5743 for details.
    CHECK(isOutgoing, ("Ingoing edges listing is not supported in LeapsOnly mode."));
    // We need both enter to mwm and exit from mwm in LeapsOnly mode to reconstruct leap.
    // That's why we need to duplicate twin segment here and than remove duplicate
    // while processing leaps.
    for (Segment const & twin : twins)
    {
      m2::PointD const & from = GetPoint(segment, isOutgoing /* front */);
      m2::PointD const & to = GetPoint(twin, isOutgoing /* front */);
      // Weight is usually zero because twins correspond the same feature
      // in different mwms. But if we have mwms with different versions and a feature
      // was moved in one of them the weight is greater than zero.
      edges.emplace_back(twin, HeuristicCostEstimate(from, to));
    }
    return;
  }

  auto prevMode = GetMode();
  SetMode(Mode::SingleMwm);

  for (Segment const & twin : twins)
    GetEdgeList(twin, isOutgoing, edges);

  SetMode(prevMode);
}

string DebugPrint(WorldGraph::Mode mode)
{
  switch (mode)
  {
  case WorldGraph::Mode::LeapsOnly: return "LeapsOnly";
  case WorldGraph::Mode::NoLeaps: return "NoLeaps";
  case WorldGraph::Mode::SingleMwm: return "SingleMwm";
  }
  ASSERT(false, ("Unknown mode:", static_cast<size_t>(mode)));
  return "Unknown mode";
}
}  // namespace routing