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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
#include "routing_common/car_model.hpp"
#include "base/macros.hpp"
#include "indexer/classificator.hpp"
#include <vector>
using namespace std;
using namespace routing;
namespace
{
// See model specifics in different countries here:
// http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions
// See road types here:
// http://wiki.openstreetmap.org/wiki/Key:highway
double constexpr kSpeedMotorwayKMpH = 115.37;
double constexpr kSpeedMotorwayLinkKMpH = 75.0;
double constexpr kSpeedTrunkKMpH = 93.89;
double constexpr kSpeedTrunkLinkKMpH = 70.0;
double constexpr kSpeedPrimaryKMpH = 84.29;
double constexpr kSpeedPrimaryLinkKMpH = 60.0;
double constexpr kSpeedSecondaryKMpH = 72.23;
double constexpr kSpeedSecondaryLinkKMpH = 50.0;
double constexpr kSpeedTertiaryKMpH = 62.63;
double constexpr kSpeedTertiaryLinkKMpH = 30.0;
double constexpr kSpeedResidentialKMpH = 25.0;
double constexpr kSpeedUnclassifiedKMpH = 51.09;
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;
double constexpr kSpeedPierKMpH = 10.0;
VehicleModel::InitListT const g_carLimitsDefault =
{
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true /* isTransitAllowed */ },
{{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true},
{{"highway", "trunk"}, kSpeedTrunkKMpH, true},
{{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true},
{{"highway", "primary"}, kSpeedPrimaryKMpH, true},
{{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true},
{{"highway", "secondary"}, kSpeedSecondaryKMpH, true},
{{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true},
{{"highway", "tertiary"}, kSpeedTertiaryKMpH, true},
{{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true},
{{"highway", "residential"}, kSpeedResidentialKMpH, true},
{{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true},
{{"highway", "service"}, kSpeedServiceKMpH, true},
{{"highway", "living_street"}, kSpeedLivingStreetKMpH, true},
{{"highway", "road"}, kSpeedRoadKMpH, true},
{{"highway", "track"}, kSpeedTrackKMpH, true},
/// @todo: Add to classificator
//{ {"highway", "shuttle_train"}, 10 },
//{ {"highway", "ferry"}, 5 },
//{ {"highway", "default"}, 10 },
/// @todo: Check type
//{ {"highway", "construction"}, 40 },
};
VehicleModel::InitListT const g_carLimitsNoLivingStreetTransit =
{
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true},
{{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true},
{{"highway", "trunk"}, kSpeedTrunkKMpH, true},
{{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true},
{{"highway", "primary"}, kSpeedPrimaryKMpH, true},
{{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true},
{{"highway", "secondary"}, kSpeedSecondaryKMpH, true},
{{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true},
{{"highway", "tertiary"}, kSpeedTertiaryKMpH, true},
{{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true},
{{"highway", "residential"}, kSpeedResidentialKMpH, true},
{{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true},
{{"highway", "service"}, kSpeedServiceKMpH, true},
{{"highway", "living_street"}, kSpeedLivingStreetKMpH, false},
{{"highway", "road"}, kSpeedRoadKMpH, true},
{{"highway", "track"}, kSpeedTrackKMpH, true},
};
VehicleModel::InitListT const g_carLimitsNoLivingStreetAndServiceTransit =
{
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true},
{{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true},
{{"highway", "trunk"}, kSpeedTrunkKMpH, true},
{{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true},
{{"highway", "primary"}, kSpeedPrimaryKMpH, true},
{{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true},
{{"highway", "secondary"}, kSpeedSecondaryKMpH, true},
{{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true},
{{"highway", "tertiary"}, kSpeedTertiaryKMpH, true},
{{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true},
{{"highway", "residential"}, kSpeedResidentialKMpH, true},
{{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true},
{{"highway", "service"}, kSpeedServiceKMpH, false},
{{"highway", "living_street"}, kSpeedLivingStreetKMpH, false},
{{"highway", "road"}, kSpeedRoadKMpH, true},
{{"highway", "track"}, kSpeedTrackKMpH, true},
};
VehicleModel::InitListT const g_carLimitsAustralia = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsAustria = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsBelarus = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsBelgium = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsBrazil = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsDenmark =
{
// No track
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true},
{{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true},
{{"highway", "trunk"}, kSpeedTrunkKMpH, true},
{{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true},
{{"highway", "primary"}, kSpeedPrimaryKMpH, true},
{{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true},
{{"highway", "secondary"}, kSpeedSecondaryKMpH, true},
{{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true},
{{"highway", "tertiary"}, kSpeedTertiaryKMpH, true},
{{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true},
{{"highway", "residential"}, kSpeedResidentialKMpH, true},
{{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true},
{{"highway", "service"}, kSpeedServiceKMpH, true},
{{"highway", "living_street"}, kSpeedLivingStreetKMpH, true},
{{"highway", "road"}, kSpeedRoadKMpH, true},
};
VehicleModel::InitListT const g_carLimitsFrance = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsFinland = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsGermany =
{
// No transit for track
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true},
{{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true},
{{"highway", "trunk"}, kSpeedTrunkKMpH, true},
{{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true},
{{"highway", "primary"}, kSpeedPrimaryKMpH, true},
{{"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true},
{{"highway", "secondary"}, kSpeedSecondaryKMpH, true},
{{"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH, true},
{{"highway", "tertiary"}, kSpeedTertiaryKMpH, true},
{{"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH, true},
{{"highway", "residential"}, kSpeedResidentialKMpH, true},
{{"highway", "unclassified"}, kSpeedUnclassifiedKMpH, true},
{{"highway", "service"}, kSpeedServiceKMpH, true},
{{"highway", "living_street"}, kSpeedLivingStreetKMpH, true},
{{"highway", "road"}, kSpeedRoadKMpH, true},
{{"highway", "track"}, kSpeedTrackKMpH, false},
};
VehicleModel::InitListT const g_carLimitsHungary = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsIceland = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsNetherlands = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsNorway = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsOman = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsPoland = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsRomania = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsRussia = g_carLimitsNoLivingStreetAndServiceTransit;
VehicleModel::InitListT const g_carLimitsSlovakia = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsSpain = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsSwitzerland = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsTurkey = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsUkraine = g_carLimitsNoLivingStreetAndServiceTransit;
VehicleModel::InitListT const g_carLimitsUK = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsUS = g_carLimitsDefault;
vector<VehicleModel::AdditionalRoadTags> const kAdditionalTags = {
{{"route", "ferry", "motorcar"}, kSpeedFerryMotorcarKMpH},
{{"route", "ferry", "motor_vehicle"}, kSpeedFerryMotorcarVehicleKMpH},
{{"railway", "rail", "motor_vehicle"}, kSpeedRailMotorcarVehicleKMpH},
{{"route", "shuttle_train"}, kSpeedShuttleTrainKMpH},
{{"route", "ferry"}, kSpeedFerryMotorcarKMpH},
{{"man_made", "pier"}, kSpeedPierKMpH},
};
} // namespace
namespace routing
{
CarModel::CarModel()
: VehicleModel(classif(), g_carLimitsDefault)
{
InitAdditionalRoadTypes();
}
CarModel::CarModel(VehicleModel::InitListT const & roadLimits)
: VehicleModel(classif(), roadLimits)
{
InitAdditionalRoadTypes();
}
void CarModel::InitAdditionalRoadTypes()
{
SetAdditionalRoadTypes(classif(), kAdditionalTags);
}
// static
CarModel const & CarModel::AllLimitsInstance()
{
static CarModel const instance;
return instance;
}
// static
routing::VehicleModel::InitListT const & CarModel::GetLimits() { return g_carLimitsDefault; }
// static
vector<routing::VehicleModel::AdditionalRoadTags> const & CarModel::GetAdditionalTags()
{
return kAdditionalTags;
}
CarModelFactory::CarModelFactory(CountryParentNameGetterFn const & countryParentNameGetterFn)
: VehicleModelFactory(countryParentNameGetterFn)
{
// Names must be the same with country names from countries.txt
m_models[""] = make_shared<CarModel>(g_carLimitsDefault);
m_models["Australia"] = make_shared<CarModel>(g_carLimitsAustralia);
m_models["Austria"] = make_shared<CarModel>(g_carLimitsAustria);
m_models["Belarus"] = make_shared<CarModel>(g_carLimitsBelarus);
m_models["Belgium"] = make_shared<CarModel>(g_carLimitsBelgium);
m_models["Brazil"] = make_shared<CarModel>(g_carLimitsBrazil);
m_models["Denmark"] = make_shared<CarModel>(g_carLimitsDenmark);
m_models["France"] = make_shared<CarModel>(g_carLimitsFrance);
m_models["Finland"] = make_shared<CarModel>(g_carLimitsFinland);
m_models["Germany"] = make_shared<CarModel>(g_carLimitsGermany);
m_models["Hungary"] = make_shared<CarModel>(g_carLimitsHungary);
m_models["Iceland"] = make_shared<CarModel>(g_carLimitsIceland);
m_models["Netherlands"] = make_shared<CarModel>(g_carLimitsNetherlands);
m_models["Norway"] = make_shared<CarModel>(g_carLimitsNorway);
m_models["Oman"] = make_shared<CarModel>(g_carLimitsOman);
m_models["Poland"] = make_shared<CarModel>(g_carLimitsPoland);
m_models["Romania"] = make_shared<CarModel>(g_carLimitsRomania);
m_models["Russian Federation"] = make_shared<CarModel>(g_carLimitsRussia);
m_models["Slovakia"] = make_shared<CarModel>(g_carLimitsSlovakia);
m_models["Spain"] = make_shared<CarModel>(g_carLimitsSpain);
m_models["Switzerland"] = make_shared<CarModel>(g_carLimitsSwitzerland);
m_models["Turkey"] = make_shared<CarModel>(g_carLimitsTurkey);
m_models["Ukraine"] = make_shared<CarModel>(g_carLimitsUkraine);
m_models["United Kingdom"] = make_shared<CarModel>(g_carLimitsUK);
m_models["United States of America"] = make_shared<CarModel>(g_carLimitsUS);
}
} // namespace routing
|