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

car_model.cpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 75b78b93c8fe215fc7c3f09267e31c49ecdc41b8 (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
#include "car_model.hpp"

#include "base/macros.hpp"

#include "indexer/classificator.hpp"

#include "std/vector.hpp"

namespace
{
double constexpr kSpeedMotorwayKMpH = 90.0;
double constexpr kSpeedMotorwayLinkKMpH = 75.0;
double constexpr kSpeedTrunkKMpH = 85.0;
double constexpr kSpeedTrunkLinkKMpH = 70.0;
double constexpr kSpeedPrimaryKMpH = 65.0;
double constexpr kSpeedPrimaryLinkKMpH = 60.0;
double constexpr kSpeedSecondaryKMpH = 55.0;
double constexpr kSpeedSecondaryLinkKMpH = 50.0;
double constexpr kSpeedTertiaryKMpH = 40.0;
double constexpr kSpeedTertiaryLinkKMpH = 30.0;
double constexpr kSpeedResidentialKMpH = 25.0;
double constexpr kSpeedPedestrianKMpH = 25.0;
double constexpr kSpeedUnclassifiedKMpH = 25.0;
double constexpr kSpeedServiceKMpH = 15.0;
double constexpr kSpeedLivingStreetKMpH = 10.0;
double constexpr kSpeedRoadKMpH = 10.0;
double constexpr kSpeedTrackKMpH = 5.0;
double constexpr kSpeedFerryMotorcarKMpH = 15.0;
double constexpr kSpeedFerryMotorcarVehicleKMpH = 15.0;
double constexpr kSpeedRailMotorcarVehicleKMpH = 25.0;
double constexpr kSpeedShuttleTrainKMpH = 25.0;

routing::VehicleModel::InitListT const s_carLimits = {
    {{"highway", "motorway"}, kSpeedMotorwayKMpH},
    {{"highway", "trunk"}, kSpeedTrunkKMpH},
    {{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH},
    {{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH},
    {{"highway", "primary"}, kSpeedPrimaryKMpH},
    {{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH},
    {{"highway", "secondary"}, kSpeedSecondaryKMpH},
    {{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH},
    {{"highway", "tertiary"}, kSpeedTertiaryKMpH},
    {{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH},
    {{"highway", "residential"}, kSpeedResidentialKMpH},
    {{"highway", "pedestrian"}, kSpeedPedestrianKMpH},
    {{"highway", "unclassified"}, kSpeedUnclassifiedKMpH},
    {{"highway", "service"}, kSpeedServiceKMpH},
    {{"highway", "living_street"}, kSpeedLivingStreetKMpH},
    {{"highway", "road"}, kSpeedRoadKMpH},
    {{"highway", "track"}, kSpeedTrackKMpH},
    /// @todo: Add to classificator
    //{ {"highway", "shuttle_train"},  10 },
    //{ {"highway", "ferry"},          5  },
    //{ {"highway", "default"},        10 },
    /// @todo: Check type
    //{ {"highway", "construction"},   40 },
};

}  // namespace

namespace routing
{

CarModel::CarModel()
  : VehicleModel(classif(), s_carLimits)
{
  vector<AdditionalRoadTags> const additionalTags = {
      {{"route", "ferry", "motorcar"}, kSpeedFerryMotorcarKMpH},
      {{"route", "ferry", "motor_vehicle"}, kSpeedFerryMotorcarVehicleKMpH},
      {{"railway", "rail", "motor_vehicle"}, kSpeedRailMotorcarVehicleKMpH},
      {{"route", "shuttle_train"}, kSpeedShuttleTrainKMpH},
  };

  SetAdditionalRoadTypes(classif(), additionalTags);
}

// static
CarModel const & CarModel::AllLimitsInstance()
{
  static CarModel const instance;
  return instance;
}

CarModelFactory::CarModelFactory() { m_model = make_shared<CarModel>(); }
shared_ptr<IVehicleModel> CarModelFactory::GetVehicleModel() const { return m_model; }
shared_ptr<IVehicleModel> CarModelFactory::GetVehicleModelForCountry(
    string const & /* country */) const
{
  // @TODO(bykoianko) Different vehicle model for different country should be supported
  // according to http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions.
  // See pedestrian_model.cpp and bicycle_model.cpp for example.
  return m_model;
}
}  // namespace routing