SUMO - Simulation of Urban MObility
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.dlr.de/
13 // Copyright (C) 2001-2015 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"
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 // ===========================================================================
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') {
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') {
124  }
125  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
126  if (classS[2] == '1') {
127  e.allowVehicleClass(-1, SVC_HOV);
129  }
130  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
131  if (classS[3] == '1') {
133  }
134  // Taxi -- becomes SVC_TAXI
135  if (classS[4] == '1') {
137  }
138  // Public Bus -- becomes SVC_BUS|SVC_COACH
139  if (classS[5] == '1') {
140  e.allowVehicleClass(-1, SVC_BUS);
142  }
143  // Delivery Truck -- becomes SVC_DELIVERY
144  if (classS[6] == '1') {
146  }
147  // Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
148  if (classS[7] == '1') {
151  }
152  // Bicycle -- becomes SVC_BICYCLE
153  if (classS[8] == '1') {
155  }
156  // Pedestrian -- becomes SVC_PEDESTRIAN
157  if (classS[9] == '1') {
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') {
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') {
177  }
178  // Residential Vehicle -- becomes SVC_PASSENGER
179  if (classS[2] == '1') {
181  }
182  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
183  if (classS[3] == '1') {
184  e.allowVehicleClass(-1, SVC_HOV);
186  }
187  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
188  if (classS[4] == '1') {
190  }
191  // Taxi -- becomes SVC_TAXI
192  if (classS[5] == '1') {
194  }
195  // Public Bus -- becomes SVC_BUS|SVC_COACH
196  if (classS[6] == '1') {
197  e.allowVehicleClass(-1, SVC_BUS);
199  }
200  // Delivery Truck -- becomes SVC_DELIVERY
201  if (classS[7] == '1') {
203  }
204  // Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
205  if (classS[8] == '1') {
208  }
209  // Motorcycle -- becomes SVC_MOTORCYCLE
210  if (classS[9] == '1') {
212  }
213  // Bicycle -- becomes SVC_BICYCLE
214  if (classS[10] == '1') {
216  }
217  // Pedestrian -- becomes SVC_PEDESTRIAN
218  if (classS[11] == '1') {
220  }
221 }
222 /****************************************************************************/
223 
vehicle is a motorcycle
vehicle is a coach
is a pedestrian
vehicle is a bicycle
The representation of a single edge during network building.
Definition: NBEdge.h:70
vehicle is a small delivery vehicle
static void addVehicleClasses(NBEdge &e, const std::string &classS)
Adds vehicle classes parsing the given list of allowed vehicles.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
Definition: NBEdge.cpp:2334
const SVCPermissions SVCAll
vehicle is a HOV
vehicle is a large transport vehicle
vehicle is a passenger car (a "normal" car)
static unsigned int getLaneNumber(const std::string &id, const std::string &laneNoS, SUMOReal speed)
Returns the lane number evaluating the given Navteq-description.
static SUMOReal getSpeed(const std::string &id, const std::string &speedClassS)
Returns the speed evaluating the given Navteq-description.
vehicle is a taxi
static void addVehicleClassesV6(NBEdge &e, const std::string &classS)
same as addVehicleClasses but for version 6+
vehicle is a bus
static int _2int(const E *const data)
Definition: TplConvert.h:114
vehicle is a large transport vehicle
#define SUMOReal
Definition: config.h:214
void allowVehicleClass(int lane, SUMOVehicleClass vclass)
set allowed class for the given lane or for all lanes if -1 is given
Definition: NBEdge.cpp:2224
public emergency vehicles