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

bicycle_directions.hpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a95d79898ece4beb64ea0bc1db58b8624b9b1476 (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
#pragma once

#include "routing/directions_engine.hpp"
#include "routing/loaded_path_segment.hpp"
#include "routing/segment.hpp"
#include "routing/turn_candidate.hpp"

#include "routing_common/num_mwm_id.hpp"

#include "editor/editable_data_source.hpp"

#include <map>
#include <memory>

namespace routing
{
class BicycleDirectionsEngine : public IDirectionsEngine
{
public:
  struct AdjacentEdges
  {
    explicit AdjacentEdges(size_t ingoingTurnsCount = 0) : m_ingoingTurnsCount(ingoingTurnsCount) {}
    bool IsAlmostEqual(AdjacentEdges const & rhs) const;

    turns::TurnCandidates m_outgoingTurns;
    size_t m_ingoingTurnsCount;
  };

  using AdjacentEdgesMap = std::map<SegmentRange, AdjacentEdges>;

  BicycleDirectionsEngine(DataSourceBase const & dataSource, std::shared_ptr<NumMwmIds> numMwmIds);

  // IDirectionsEngine override:
  bool Generate(IndexRoadGraph const & graph, vector<Junction> const & path,
                base::Cancellable const & cancellable, Route::TTurns & turns,
                Route::TStreets & streetNames, vector<Junction> & routeGeometry,
                vector<Segment> & segments) override;

private:
  EditableDataSource::FeaturesLoaderGuard & GetLoader(MwmSet::MwmId const & id);
  void LoadPathAttributes(FeatureID const & featureId, LoadedPathSegment & pathSegment);
  void GetSegmentRangeAndAdjacentEdges(IRoadGraph::TEdgeVector const & outgoingEdges,
                                       Edge const & inEdge, uint32_t startSegId, uint32_t endSegId,
                                       SegmentRange & segmentRange,
                                       turns::TurnCandidates & outgoingTurns);
  /// \brief The method gathers sequence of segments according to IsJoint() method
  /// and fills |m_adjacentEdges| and |m_pathSegments|.
  void FillPathSegmentsAndAdjacentEdgesMap(IndexRoadGraph const & graph,
                                           std::vector<Junction> const & path,
                                           IRoadGraph::TEdgeVector const & routeEdges,
                                           base::Cancellable const & cancellable);

  void GetEdges(RoadGraphBase const & graph, Junction const & currJunction,
                bool isCurrJunctionFinish, IRoadGraph::TEdgeVector & outgoing,
                IRoadGraph::TEdgeVector & ingoing);

  AdjacentEdgesMap m_adjacentEdges;
  TUnpackedPathSegments m_pathSegments;
  DataSourceBase const & m_dataSource;
  std::shared_ptr<NumMwmIds> m_numMwmIds;
  std::unique_ptr<EditableDataSource::FeaturesLoaderGuard> m_loader;
};
}  // namespace routing