SUMO - Simulation of Urban MObility
NINavTeqHelper.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // Some parser methods shared around several formats containing NavTeq-Nets
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "NINavTeqHelper.h"
37 #include <netbuild/NBEdge.h>
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
43 double
44 NINavTeqHelper::getSpeed(const std::string& id, const std::string& speedClassS) {
45  try {
46  int speedClass = TplConvert::_2int(speedClassS.c_str());
47  switch (speedClass) {
48  case -1:
49  return (double) 1.0 / (double) 3.6;
50  case 1:
51  return (double) 200 / (double) 3.6; //> 130 KPH / > 80 MPH
52  case 2:
53  return (double) 120 / (double) 3.6; //101-130 KPH / 65-80 MPH
54  case 3:
55  return (double) 100 / (double) 3.6; // 91-100 KPH / 55-64 MPH
56  case 4:
57  return (double) 80 / (double) 3.6; // 71-90 KPH / 41-54 MPH
58  case 5:
59  return (double) 70 / (double) 3.6; // 51-70 KPH / 31-40 MPH
60  case 6:
61  return (double) 50 / (double) 3.6; // 31-50 KPH / 21-30 MPH
62  case 7:
63  return (double) 30 / (double) 3.6; // 11-30 KPH / 6-20 MPH
64  case 8:
65  return (double) 5 / (double) 3.6; //< 11 KPH / < 6 MPH
66  default:
67  throw ProcessError("Invalid speed code (edge '" + id + "').");
68  }
69  } catch (NumberFormatException&) {
70  throw ProcessError("Non-numerical value for an edge's speed type occured (edge '" + id + "').");
71  }
72 }
73 
74 
75 int
76 NINavTeqHelper::getLaneNumber(const std::string& id, const std::string& laneNoS, double speed) {
77  try {
78  int nolanes = TplConvert::_2int(laneNoS.c_str());
79  if (nolanes < 0) {
80  return 1;
81  } else if (nolanes / 10 > 0) {
82  return nolanes / 10;
83  } else {
84  switch (nolanes % 10) {
85  case 1:
86  return 1;
87  case 2:
88  nolanes = 2;
89  if (speed > 78.0 / 3.6) {
90  nolanes = 3;
91  }
92  return nolanes;
93  case 3:
94  return 4;
95  default:
96  throw ProcessError("Invalid lane number (edge '" + id + "').");
97  }
98  }
99  } catch (NumberFormatException&) {
100  throw ProcessError("Non-numerical value for an edge's lane number occured (edge '" + id + "'.");
101  }
102 }
103 
104 
105 void
106 NINavTeqHelper::addVehicleClasses(NBEdge& e, const std::string& oclassS) {
107  std::string classS = "0000000000" + oclassS;
108  classS = classS.substr(classS.length() - 10);
109  // 0: allow all vehicle types
110  if (classS[0] == '1') {
112  return;
113  }
114  // we have some restrictions. disallow all and then add classes indiviually
115  e.setPermissions(0);
116  // Passenger cars -- becomes SVC_PASSENGER
117  if (classS[1] == '1') {
119  }
120  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
121  if (classS[2] == '1') {
122  e.allowVehicleClass(-1, SVC_HOV);
124  }
125  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
126  if (classS[3] == '1') {
128  }
129  // Taxi -- becomes SVC_TAXI
130  if (classS[4] == '1') {
132  }
133  // Public Bus -- becomes SVC_BUS|SVC_COACH
134  if (classS[5] == '1') {
135  e.allowVehicleClass(-1, SVC_BUS);
137  }
138  // Delivery Truck -- becomes SVC_DELIVERY
139  if (classS[6] == '1') {
141  }
142  // Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
143  if (classS[7] == '1') {
146  }
147  // Bicycle -- becomes SVC_BICYCLE
148  if (classS[8] == '1') {
150  }
151  // Pedestrian -- becomes SVC_PEDESTRIAN
152  if (classS[9] == '1') {
154  }
155 }
156 
157 
158 void
159 NINavTeqHelper::addVehicleClassesV6(NBEdge& e, const std::string& oclassS) {
160  std::string classS = "0000000000" + oclassS;
161  classS = classS.substr(classS.length() - 12);
162  // 0: allow all vehicle types
163  if (classS[0] == '1') {
165  return;
166  }
167  // we have some restrictions. disallow all and then add classes indiviually
168  e.setPermissions(0);
169  // Passenger cars -- becomes SVC_PASSENGER
170  if (classS[1] == '1') {
172  }
173  // Residential Vehicle -- becomes SVC_PASSENGER
174  if (classS[2] == '1') {
176  }
177  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
178  if (classS[3] == '1') {
179  e.allowVehicleClass(-1, SVC_HOV);
181  }
182  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
183  if (classS[4] == '1') {
185  }
186  // Taxi -- becomes SVC_TAXI
187  if (classS[5] == '1') {
189  }
190  // Public Bus -- becomes SVC_BUS|SVC_COACH
191  if (classS[6] == '1') {
192  e.allowVehicleClass(-1, SVC_BUS);
194  }
195  // Delivery Truck -- becomes SVC_DELIVERY
196  if (classS[7] == '1') {
198  }
199  // Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
200  if (classS[8] == '1') {
203  }
204  // Motorcycle -- becomes SVC_MOTORCYCLE
205  if (classS[9] == '1') {
207  }
208  // Bicycle -- becomes SVC_BICYCLE
209  if (classS[10] == '1') {
211  }
212  // Pedestrian -- becomes SVC_PEDESTRIAN
213  if (classS[11] == '1') {
215  }
216 }
217 /****************************************************************************/
218 
vehicle is a motorcycle
vehicle is a coach
is a pedestrian
static double getSpeed(const std::string &id, const std::string &speedClassS)
Returns the speed evaluating the given Navteq-description.
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:2997
const SVCPermissions SVCAll
all VClasses are allowed
vehicle is a HOV
vehicle is a large transport vehicle
vehicle is a passenger car (a "normal" car)
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)
converts a char-type array into the integer value described by it
Definition: TplConvert.h:155
vehicle is a large transport vehicle
static int getLaneNumber(const std::string &id, const std::string &laneNoS, double speed)
Returns the lane number evaluating the given Navteq-description.
void allowVehicleClass(int lane, SUMOVehicleClass vclass)
set allowed class for the given lane or for all lanes if -1 is given
Definition: NBEdge.cpp:2872
public emergency vehicles