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

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

#include "routing/segment.hpp"
#include "routing/vehicle_mask.hpp"

#include "base/assert.hpp"

#include <cstdint>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

namespace routing
{
// This class provides information about road access classes.
// One instance of RoadAccess holds information about one
// mwm and one router type (also known as VehicleType).
class RoadAccess final
{
public:
  // The road access types are selected by analyzing the most
  // popular tags used when mapping roads in OSM.
  enum class Type : uint8_t
  {
    // Moving through the road is prohibited.
    No,

    // Moving through the road requires a special permission.
    Private,

    // No pass through the road is allowed; however, it can
    // be used if it is close enough to the destination point
    // of the route.
    Destination,

    // No restrictions, as in "access=yes".
    Yes,

    // The number of different road types.
    Count
  };

  std::unordered_map<uint32_t, RoadAccess::Type> const & GetFeatureTypes() const
  {
    return m_featureTypes;
  }

  std::unordered_map<RoadPoint, RoadAccess::Type, RoadPoint::Hash> const & GetPointTypes() const
  {
    return m_pointTypes;
  }

  Type GetFeatureType(uint32_t featureId) const;
  Type GetPointType(RoadPoint const & point) const;

  template <typename MF, typename MP>
  void SetAccessTypes(MF && mf, MP && mp)
  {
    m_featureTypes = std::forward<MF>(mf);
    m_pointTypes = std::forward<MP>(mp);
  }

  void Clear();

  void Swap(RoadAccess & rhs);

  bool operator==(RoadAccess const & rhs) const;

  template <typename MF>
  void SetFeatureTypesForTests(MF && mf)
  {
    m_featureTypes = std::forward<MF>(mf);
  }

private:
  // If segmentIdx of a key in this map is 0, it means the
  // entire feature has the corresponding access type.
  // Otherwise, the information is about the segment with number (segmentIdx-1).
  std::unordered_map<uint32_t, RoadAccess::Type> m_featureTypes;
  std::unordered_map<RoadPoint, RoadAccess::Type, RoadPoint::Hash> m_pointTypes;
};

std::string ToString(RoadAccess::Type type);
void FromString(std::string const & s, RoadAccess::Type & result);

std::string DebugPrint(RoadAccess::Type type);
std::string DebugPrint(RoadAccess const & r);
}  // namespace routing