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.sourceforge.net/
13
// Copyright (C) 2001-2013 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
(
SVCFreeForAll
);
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_PUBLIC_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_PUBLIC_TRANSPORT
139
if
(classS[5] ==
'1'
) {
140
e.
allowVehicleClass
(-1,
SVC_PUBLIC_TRANSPORT
);
141
e.
allowVehicleClass
(-1,
SVC_BUS
);
142
}
143
// Delivery Truck -- becomes SVC_DELIVERY
144
if
(classS[6] ==
'1'
) {
145
e.
allowVehicleClass
(-1,
SVC_DELIVERY
);
146
}
147
// Transport Truck -- becomes SVC_TRANSPORT
148
if
(classS[7] ==
'1'
) {
149
e.
allowVehicleClass
(-1,
SVC_TRANSPORT
);
150
}
151
// Bicycle -- becomes SVC_BICYCLE
152
if
(classS[8] ==
'1'
) {
153
e.
allowVehicleClass
(-1,
SVC_BICYCLE
);
154
}
155
// Pedestrian -- becomes SVC_PEDESTRIAN
156
if
(classS[9] ==
'1'
) {
157
e.
allowVehicleClass
(-1,
SVC_PEDESTRIAN
);
158
}
159
}
160
161
162
void
163
NINavTeqHelper::addVehicleClassesV6
(
NBEdge
& e,
const
std::string& oclassS) {
164
std::string classS =
"0000000000"
+ oclassS;
165
classS = classS.substr(classS.length() - 12);
166
// 0: allow all vehicle types
167
if
(classS[0] ==
'1'
) {
168
e.
setPermissions
(
SVCFreeForAll
);
169
return
;
170
}
171
// we have some restrictions. disallow all and then add classes indiviually
172
e.
setPermissions
(0);
173
// Passenger cars -- becomes SVC_PASSENGER
174
if
(classS[1] ==
'1'
) {
175
e.
allowVehicleClass
(-1,
SVC_PASSENGER
);
176
}
177
// Residential Vehicle -- becomes SVC_PASSENGER
178
if
(classS[2] ==
'1'
) {
179
e.
allowVehicleClass
(-1,
SVC_PASSENGER
);
180
}
181
// High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
182
if
(classS[3] ==
'1'
) {
183
e.
allowVehicleClass
(-1,
SVC_HOV
);
184
e.
allowVehicleClass
(-1,
SVC_PASSENGER
);
185
}
186
// Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
187
if
(classS[4] ==
'1'
) {
188
e.
allowVehicleClass
(-1,
SVC_PUBLIC_EMERGENCY
);
189
}
190
// Taxi -- becomes SVC_TAXI
191
if
(classS[5] ==
'1'
) {
192
e.
allowVehicleClass
(-1,
SVC_TAXI
);
193
}
194
// Public Bus -- becomes SVC_BUS|SVC_PUBLIC_TRANSPORT
195
if
(classS[6] ==
'1'
) {
196
e.
allowVehicleClass
(-1,
SVC_PUBLIC_TRANSPORT
);
197
e.
allowVehicleClass
(-1,
SVC_BUS
);
198
}
199
// Delivery Truck -- becomes SVC_DELIVERY
200
if
(classS[7] ==
'1'
) {
201
e.
allowVehicleClass
(-1,
SVC_DELIVERY
);
202
}
203
// Transport Truck -- becomes SVC_TRANSPORT
204
if
(classS[8] ==
'1'
) {
205
e.
allowVehicleClass
(-1,
SVC_TRANSPORT
);
206
}
207
// Motorcycle -- becomes SVC_MOTORCYCLE
208
if
(classS[9] ==
'1'
) {
209
e.
allowVehicleClass
(-1,
SVC_MOTORCYCLE
);
210
}
211
// Bicycle -- becomes SVC_BICYCLE
212
if
(classS[10] ==
'1'
) {
213
e.
allowVehicleClass
(-1,
SVC_BICYCLE
);
214
}
215
// Pedestrian -- becomes SVC_PEDESTRIAN
216
if
(classS[11] ==
'1'
) {
217
e.
allowVehicleClass
(-1,
SVC_PEDESTRIAN
);
218
}
219
}
220
/****************************************************************************/
221
build
buildd
sumo-0.17.1~dfsg
src
netimport
NINavTeqHelper.cpp
Generated on Sun Jun 16 2013 17:30:18 for SUMO - Simulation of Urban MObility by
1.8.3.1