Exemplo n.º 1
0
inline std::string DebugPrint(Segment const & segment)
{
  std::ostringstream out;
  out << std::boolalpha << "Segment(" << segment.GetMwmId() << ", " << segment.GetFeatureId() << ", "
      << segment.GetSegmentIdx() << ", " << segment.IsForward() << ")";
  return out.str();
}
Exemplo n.º 2
0
void CrossMwmGraph::GetOutgoingEdgeList(Segment const & s, vector<SegmentEdge> & edges)
{
  CHECK(IsTransition(s, false /* isEnter */),
        ("The segment is not a transition segment. IsTransition(", s, ", false) returns false."));
  edges.clear();

  if (TransitGraph::IsTransitSegment(s))
  {
    if (TransitCrossMwmSectionExists(s.GetMwmId()))
      m_crossMwmTransitGraph.GetOutgoingEdgeList(s, edges);
    return;
  }

  if (CrossMwmSectionExists(s.GetMwmId()))
    m_crossMwmIndexGraph.GetOutgoingEdgeList(s, edges);
}
Exemplo n.º 3
0
void CrossMwmGraph::GetTwinFeature(Segment const & segment, bool isOutgoing, vector<Segment> & twins)
{
  std::vector<uint32_t> const & transitSegmentIds =
    m_crossMwmIndexGraph.GetTransitSegmentId(segment.GetMwmId(), segment.GetFeatureId());

  for (auto transitSegmentId : transitSegmentIds)
  {
    Segment const transitSegment(segment.GetMwmId(), segment.GetFeatureId(),
                                 transitSegmentId, segment.IsForward());

    if (!IsTransition(transitSegment, isOutgoing))
      continue;

    GetTwins(transitSegment, isOutgoing, twins);
    break;
  }
}
Exemplo n.º 4
0
void CrossMwmGraph::GetTwins(Segment const & s, bool isOutgoing, vector<Segment> & twins)
{
  CHECK(IsTransition(s, isOutgoing),
        ("The segment", s, "is not a transition segment for isOutgoing ==", isOutgoing));
  // Note. There's an extremely rare case when a segment is ingoing and outgoing at the same time.
  // |twins| is not filled for such cases. For details please see a note in
  // CrossMwmGraph::GetOutgoingEdgeList().
  if (IsTransition(s, !isOutgoing))
    return;

  twins.clear();

  vector<NumMwmId> neighbors;
  bool allNeighborsHaveCrossMwmSection = false;
  GetAllLoadedNeighbors(s.GetMwmId(), neighbors, allNeighborsHaveCrossMwmSection);
  MwmStatus const currentMwmStatus = GetCrossMwmStatus(s.GetMwmId());
  CHECK_NOT_EQUAL(currentMwmStatus, MwmStatus::NotLoaded,
                  ("Current mwm is not loaded. Mwm:", m_numMwmIds->GetFile(s.GetMwmId()),
                   "currentMwmStatus:", currentMwmStatus));

  if (TransitGraph::IsTransitSegment(s) && TransitCrossMwmSectionExists(s.GetMwmId()))
  {
    DeserializeTransitTransitions(neighbors);
    m_crossMwmTransitGraph.GetTwinsByCrossMwmId(s, isOutgoing, neighbors, twins);
  }
  else if (allNeighborsHaveCrossMwmSection && currentMwmStatus == MwmStatus::SectionExists)
  {
    DeserializeTransitions(neighbors);
    m_crossMwmIndexGraph.GetTwinsByCrossMwmId(s, isOutgoing, neighbors, twins);
  }
  else
  {
    // TODO (@gmoryes)
    //  May be we should add ErrorCode about "NeedUpdateMaps" and return it here.
    //  but until we haven't it, lets do nothing.
    return;
  }

  for (Segment const & t : twins)
    CHECK_NOT_EQUAL(s.GetMwmId(), t.GetMwmId(), ());
}