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

transit_world_graph.hpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 97860b8e71032c4dc8ec3d94fd53ce3a700ae3ff (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once

#include "routing/cross_mwm_graph.hpp"
#include "routing/edge_estimator.hpp"
#include "routing/geometry.hpp"
#include "routing/index_graph_loader.hpp"
#include "routing/road_graph.hpp"
#include "routing/route.hpp"
#include "routing/segment.hpp"
#include "routing/transit_graph_loader.hpp"
#include "routing/transit_info.hpp"
#include "routing/world_graph.hpp"

#include "routing_common/num_mwm_id.hpp"

#include "transit/transit_types.hpp"

#include "geometry/point2d.hpp"

#include <memory>
#include <vector>

namespace routing
{
// WorldGraph for transit + pedestrian routing
class TransitWorldGraph final : public WorldGraph
{
public:
  TransitWorldGraph(std::unique_ptr<CrossMwmGraph> crossMwmGraph,
                    std::unique_ptr<IndexGraphLoader> indexLoader,
                    std::unique_ptr<TransitGraphLoader> transitLoader,
                    std::shared_ptr<EdgeEstimator> estimator);

  // WorldGraph overrides:
  ~TransitWorldGraph() override = default;

  void GetEdgeList(Segment const & segment, bool isOutgoing,
                   std::vector<SegmentEdge> & edges) override;
  bool CheckLength(RouteWeight const & weight, double startToFinishDistanceM) const override
  {
    return weight.GetWeight() - weight.GetTransitTime() <=
           MaxPedestrianTimeSec(startToFinishDistanceM);
  }
  Junction const & GetJunction(Segment const & segment, bool front) override;
  m2::PointD const & GetPoint(Segment const & segment, bool front) override;
  // All transit features are oneway.
  bool IsOneWay(NumMwmId mwmId, uint32_t featureId) override;
  // All transit features are allowed for through passage.
  bool IsPassThroughAllowed(NumMwmId mwmId, uint32_t featureId) override;
  void ClearCachedGraphs() override;
  void SetMode(WorldGraphMode mode) override { m_mode = mode; }
  WorldGraphMode GetMode() const override { return m_mode; }
  void GetOutgoingEdgesList(Segment const & segment, std::vector<SegmentEdge> & edges) override;
  void GetIngoingEdgesList(Segment const & segment, std::vector<SegmentEdge> & edges) override;
  RouteWeight HeuristicCostEstimate(Segment const & from, Segment const & to) override;
  RouteWeight HeuristicCostEstimate(m2::PointD const & from, m2::PointD const & to) override;
  RouteWeight HeuristicCostEstimate(Segment const & from, m2::PointD const & to) override;
  RouteWeight CalcSegmentWeight(Segment const & segment) override;
  RouteWeight CalcLeapWeight(m2::PointD const & from, m2::PointD const & to) const override;
  RouteWeight CalcOffroadWeight(m2::PointD const & from, m2::PointD const & to) const override;
  double CalcSegmentETA(Segment const & segment) override;
  std::unique_ptr<TransitInfo> GetTransitInfo(Segment const & segment) override;

  void GetEdgeList(Segment const & segment, bool isOutgoing,
                   std::vector<JointEdge> & edges,
                   std::vector<RouteWeight> & parentWeights) override;

  IndexGraph & GetIndexGraph(NumMwmId numMwmId) override
  {
    return m_indexLoader->GetIndexGraph(numMwmId);
  }

private:
  // WorldGraph overrides:
  void GetTwinsInner(Segment const & s, bool isOutgoing, std::vector<Segment> & twins) override;

  static double MaxPedestrianTimeSec(double startToFinishDistanceM)
  {
    // @todo(bykoianko) test and adjust constants.
    // 50 min + 3 additional minutes per 1 km for now.
    return 50 * 60 + (startToFinishDistanceM / 1000) * 3 * 60;
  }

  RoadGeometry const & GetRealRoadGeometry(NumMwmId mwmId, uint32_t featureId);
  void AddRealEdges(Segment const & segment, bool isOutgoing, vector<SegmentEdge> & edges);
  TransitGraph & GetTransitGraph(NumMwmId mwmId);

  std::unique_ptr<CrossMwmGraph> m_crossMwmGraph;
  std::unique_ptr<IndexGraphLoader> m_indexLoader;
  std::unique_ptr<TransitGraphLoader> m_transitLoader;
  std::shared_ptr<EdgeEstimator> m_estimator;
  WorldGraphMode m_mode = WorldGraphMode::NoLeaps;
};
}  // namespace routing