SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
NINavTeqHelper.cpp
Go to the documentation of this file.
1
/****************************************************************************/
10
// Some parser methods shared around several formats containing NavTeq-Nets
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13
// Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
14
/****************************************************************************/
15
//
16
// This file is part of SUMO.
17
// SUMO is free software: you can redistribute it and/or modify
18
// it under the terms of the GNU General Public License as published by
19
// the Free Software Foundation, either version 3 of the License, or
20
// (at your option) any later version.
21
//
22
/****************************************************************************/
23
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include "
NINavTeqHelper.h
"
35
#include <
utils/common/TplConvert.h
>
36
#include <
utils/common/MsgHandler.h
>
37
#include <
utils/common/UtilExceptions.h
>
38
#include <
netbuild/NBEdge.h
>
39
40
#ifdef CHECK_MEMORY_LEAKS
41
#include <
foreign/nvwa/debug_new.h
>
42
#endif // CHECK_MEMORY_LEAKS
43
44
45
// ===========================================================================
46
// method definitions
47
// ===========================================================================
48
SUMOReal
49
NINavTeqHelper::getSpeed
(
const
std::string&
id
,
const
std::string& speedClassS) {
50
try
{
51
int
speedClass =
TplConvert::_2int
(speedClassS.c_str());
52
switch
(speedClass) {
53
case
-1:
54
return
(
SUMOReal
) 1.0 / (
SUMOReal
) 3.6;
55
case
1:
56
return
(
SUMOReal
) 200 / (
SUMOReal
) 3.6;
//> 130 KPH / > 80 MPH
57
case
2:
58
return
(
SUMOReal
) 120 / (
SUMOReal
) 3.6;
//101-130 KPH / 65-80 MPH
59
case
3:
60
return
(
SUMOReal
) 100 / (
SUMOReal
) 3.6;
// 91-100 KPH / 55-64 MPH
61
case
4:
62
return
(
SUMOReal
) 80 / (
SUMOReal
) 3.6;
// 71-90 KPH / 41-54 MPH
63
case
5:
64
return
(
SUMOReal
) 70 / (
SUMOReal
) 3.6;
// 51-70 KPH / 31-40 MPH
65
case
6:
66
return
(
SUMOReal
) 50 / (
SUMOReal
) 3.6;
// 31-50 KPH / 21-30 MPH
67
case
7:
68
return
(
SUMOReal
) 30 / (
SUMOReal
) 3.6;
// 11-30 KPH / 6-20 MPH
69
case
8:
70
return
(
SUMOReal
) 5 / (
SUMOReal
) 3.6;
//< 11 KPH / < 6 MPH
71
default
:
72
throw
ProcessError
(
"Invalid speed code (edge '"
+
id
+
"')."
);
73
}
74
}
catch
(
NumberFormatException
&) {
75
throw
ProcessError
(
"Non-numerical value for an edge's speed type occured (edge '"
+
id
+
"')."
);
76
}
77
}
78
79
80
unsigned
int
81
NINavTeqHelper::getLaneNumber
(
const
std::string&
id
,
const
std::string& laneNoS,
SUMOReal
speed) {
82
try
{
83
int
nolanes =
TplConvert::_2int
(laneNoS.c_str());
84
if
(nolanes < 0) {
85
return
1;
86
}
else
if
(nolanes / 10 > 0) {
87
return
nolanes / 10;
88
}
else
{
89
switch
(nolanes % 10) {
90
case
1:
91
return
1;
92
case
2:
93
nolanes = 2;
94
if
(speed > 78.0 / 3.6) {
95
nolanes = 3;
96
}
97
return
nolanes;
98
case
3:
99
return
4;
100
default
:
101
throw
ProcessError
(
"Invalid lane number (edge '"
+
id
+
"')."
);
102
}
103
}
104
}
catch
(
NumberFormatException
&) {
105
throw
ProcessError
(
"Non-numerical value for an edge's lane number occured (edge '"
+
id
+
"'."
);
106
}
107
}
108
109
110
void
111
NINavTeqHelper::addVehicleClasses
(
NBEdge
& e,
const
std::string& oclassS) {
112
std::string classS =
"0000000000"
+ oclassS;
113
classS = classS.substr(classS.length() - 10);
114
// 0: allow all vehicle types
115
if
(classS[0] ==
'1'
) {
116
e.
setPermissions
(
SVCAll
);
117
return
;
118
}
119
// we have some restrictions. disallow all and then add classes indiviually
120
e.
setPermissions
(0);
121
// Passenger cars -- becomes SVC_PASSENGER
122
if
(classS[1] ==
'1'
) {
123
e.
allowVehicleClass
(-1,
SVC_PASSENGER
);
124
}
125
// High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
126
if
(classS[2] ==
'1'
) {
127
e.
allowVehicleClass
(-1,
SVC_HOV
);
128
e.
allowVehicleClass
(-1,
SVC_PASSENGER
);
129
}
130
// Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
131
if
(classS[3] ==
'1'
) {
132
e.
allowVehicleClass
(-1,
SVC_EMERGENCY
);
133
}
134
// Taxi -- becomes SVC_TAXI
135
if
(classS[4] ==
'1'
) {
136
e.
allowVehicleClass
(-1,
SVC_TAXI
);
137
}
138
// Public Bus -- becomes SVC_BUS|SVC_COACH
139
if
(classS[5] ==
'1'
) {
140
e.
allowVehicleClass
(-1,
SVC_BUS
);
141
e.
allowVehicleClass
(-1,
SVC_COACH
);
142
}
143
// Delivery Truck -- becomes SVC_DELIVERY
144
if
(classS[6] ==
'1'
) {
145
e.
allowVehicleClass
(-1,
SVC_DELIVERY
);
146
}
147
// Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
148
if
(classS[7] ==
'1'
) {
149
e.
allowVehicleClass
(-1,
SVC_TRUCK
);
150
e.
allowVehicleClass
(-1,
SVC_TRAILER
);
151
}
152
// Bicycle -- becomes SVC_BICYCLE
153
if
(classS[8] ==
'1'
) {
154
e.
allowVehicleClass
(-1,
SVC_BICYCLE
);
155
}
156
// Pedestrian -- becomes SVC_PEDESTRIAN
157
if
(classS[9] ==
'1'
) {
158
e.
allowVehicleClass
(-1,
SVC_PEDESTRIAN
);
159
}
160
}
161
162
163
void
164
NINavTeqHelper::addVehicleClassesV6
(
NBEdge
& e,
const
std::string& oclassS) {
165
std::string classS =
"0000000000"
+ oclassS;
166
classS = classS.substr(classS.length() - 12);
167
// 0: allow all vehicle types
168
if
(classS[0] ==
'1'
) {
169
e.
setPermissions
(
SVCAll
);
170
return
;
171
}
172
// we have some restrictions. disallow all and then add classes indiviually
173
e.
setPermissions
(0);
174
// Passenger cars -- becomes SVC_PASSENGER
175
if
(classS[1] ==
'1'
) {
176
e.
allowVehicleClass
(-1,
SVC_PASSENGER
);
177
}
178
// Residential Vehicle -- becomes SVC_PASSENGER
179
if
(classS[2] ==
'1'
) {
180
e.
allowVehicleClass
(-1,
SVC_PASSENGER
);
181
}
182
// High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
183
if
(classS[3] ==
'1'
) {
184
e.
allowVehicleClass
(-1,
SVC_HOV
);
185
e.
allowVehicleClass
(-1,
SVC_PASSENGER
);
186
}
187
// Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
188
if
(classS[4] ==
'1'
) {
189
e.
allowVehicleClass
(-1,
SVC_EMERGENCY
);
190
}
191
// Taxi -- becomes SVC_TAXI
192
if
(classS[5] ==
'1'
) {
193
e.
allowVehicleClass
(-1,
SVC_TAXI
);
194
}
195
// Public Bus -- becomes SVC_BUS|SVC_COACH
196
if
(classS[6] ==
'1'
) {
197
e.
allowVehicleClass
(-1,
SVC_BUS
);
198
e.
allowVehicleClass
(-1,
SVC_COACH
);
199
}
200
// Delivery Truck -- becomes SVC_DELIVERY
201
if
(classS[7] ==
'1'
) {
202
e.
allowVehicleClass
(-1,
SVC_DELIVERY
);
203
}
204
// Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
205
if
(classS[8] ==
'1'
) {
206
e.
allowVehicleClass
(-1,
SVC_TRUCK
);
207
e.
allowVehicleClass
(-1,
SVC_TRAILER
);
208
}
209
// Motorcycle -- becomes SVC_MOTORCYCLE
210
if
(classS[9] ==
'1'
) {
211
e.
allowVehicleClass
(-1,
SVC_MOTORCYCLE
);
212
}
213
// Bicycle -- becomes SVC_BICYCLE
214
if
(classS[10] ==
'1'
) {
215
e.
allowVehicleClass
(-1,
SVC_BICYCLE
);
216
}
217
// Pedestrian -- becomes SVC_PEDESTRIAN
218
if
(classS[11] ==
'1'
) {
219
e.
allowVehicleClass
(-1,
SVC_PEDESTRIAN
);
220
}
221
}
222
/****************************************************************************/
223
tmp
buildd
sumo-0.21.0+dfsg
src
netimport
NINavTeqHelper.cpp
Generated on Thu Nov 20 2014 19:49:57 for SUMO - Simulation of Urban MObility by
1.8.1.2