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

cross_mwm_ids.hpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 90dc966eca5bddb1e2c6159e3cbc7f1ed41b8154 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once

#include "transit/transit_types.hpp"

#include "base/geo_object_id.hpp"
#include "base/newtype.hpp"
#include "base/visitor.hpp"

#include <cstdint>
#include <functional>

namespace routing
{
namespace connector
{
// Identifier to find a border edge in neighbouring mwm while cross mwm transition
// for transit routing.
struct TransitId
{
  DECLARE_VISITOR_AND_DEBUG_PRINT(TransitId, visitor(m_stop1Id, "stop1_id"),
                                  visitor(m_stop2Id, "stop2_id"), visitor(m_lineId, "line_id"))

  TransitId() = default;
  TransitId(transit::StopId stop1Id, transit::StopId stop2Id, transit::LineId lineId)
    : m_stop1Id(stop1Id), m_stop2Id(stop2Id), m_lineId(lineId)
  {
  }

  bool operator==(TransitId const & rhs) const
  {
    return m_stop1Id == rhs.m_stop1Id && m_stop2Id == rhs.m_stop2Id && m_lineId == rhs.m_lineId;
  }

  bool operator!=(TransitId const & rhs) const { return !(rhs == *this); }

  bool operator<(TransitId const & rhs) const
  {
    if (m_stop1Id != rhs.m_stop1Id)
      return m_stop1Id < rhs.m_stop1Id;
    if (m_stop2Id != rhs.m_stop2Id)
      return m_stop2Id < rhs.m_stop2Id;
    return m_lineId < rhs.m_lineId;
  }

  bool operator>(TransitId const & rhs) const { return rhs < *this; }
  bool operator<=(TransitId const & rhs) const { return !(rhs < *this); }
  bool operator>=(TransitId const & rhs) const { return !(*this < rhs); }

  transit::StopId m_stop1Id = transit::kInvalidStopId;
  transit::StopId m_stop2Id = transit::kInvalidStopId;
  transit::LineId m_lineId = transit::kInvalidLineId;
};

struct HashKey
{
  size_t operator()(base::GeoObjectId const & key) const { return std::hash<base::GeoObjectId>()(key); }

  size_t operator()(TransitId const & key) const
  {
    return std::hash<uint64_t>()(key.m_stop1Id ^ key.m_stop2Id ^
                                 static_cast<uint64_t>(key.m_lineId));
  }
};
}  // namespace connector
}  // namespace routing