Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Some parser methods shared around several formats containing NavTeq-Nets
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include "NINavTeqHelper.h"
31 #include <netbuild/NBEdge.h>
32 
33 
34 // ===========================================================================
35 // method definitions
36 // ===========================================================================
37 double
38 NINavTeqHelper::getSpeed(const std::string& id, const std::string& speedClassS) {
39  try {
40  int speedClass = StringUtils::toInt(speedClassS);
41  switch (speedClass) {
42  case -1:
43  return (double) 1.0 / (double) 3.6;
44  case 1:
45  return (double) 200 / (double) 3.6; //> 130 KPH / > 80 MPH
46  case 2:
47  return (double) 120 / (double) 3.6; //101-130 KPH / 65-80 MPH
48  case 3:
49  return (double) 100 / (double) 3.6; // 91-100 KPH / 55-64 MPH
50  case 4:
51  return (double) 80 / (double) 3.6; // 71-90 KPH / 41-54 MPH
52  case 5:
53  return (double) 70 / (double) 3.6; // 51-70 KPH / 31-40 MPH
54  case 6:
55  return (double) 50 / (double) 3.6; // 31-50 KPH / 21-30 MPH
56  case 7:
57  return (double) 30 / (double) 3.6; // 11-30 KPH / 6-20 MPH
58  case 8:
59  return (double) 5 / (double) 3.6; //< 11 KPH / < 6 MPH
60  default:
61  throw ProcessError("Invalid speed code (edge '" + id + "').");
62  }
63  } catch (NumberFormatException&) {
64  throw ProcessError("Non-numerical value for an edge's speed type occurred (edge '" + id + "').");
65  }
66 }
67 
68 
69 int
70 NINavTeqHelper::getLaneNumber(const std::string& id, const std::string& laneNoS, double speed) {
71  try {
72  int nolanes = StringUtils::toInt(laneNoS);
73  if (nolanes < 0) {
74  return 1;
75  } else if (nolanes / 10 > 0) {
76  return nolanes / 10;
77  } else {
78  switch (nolanes % 10) {
79  case 1:
80  return 1;
81  case 2:
82  nolanes = 2;
83  if (speed > 78.0 / 3.6) {
84  nolanes = 3;
85  }
86  return nolanes;
87  case 3:
88  return 4;
89  default:
90  throw ProcessError("Invalid lane number (edge '" + id + "').");
91  }
92  }
93  } catch (NumberFormatException&) {
94  throw ProcessError("Non-numerical value for an edge's lane number occurred (edge '" + id + "'.");
95  }
96 }
97 
98 
99 void
100 NINavTeqHelper::addVehicleClasses(NBEdge& e, const std::string& oclassS) {
101  std::string classS = "0000000000" + oclassS;
102  classS = classS.substr(classS.length() - 10);
103  // 0: allow all vehicle types
104  if (classS[0] == '1') {
106  return;
107  }
108  // we have some restrictions. disallow all and then add classes indiviually
109  e.setPermissions(0);
110  // Passenger cars -- becomes SVC_PASSENGER
111  if (classS[1] == '1') {
113  }
114  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
115  if (classS[2] == '1') {
116  e.allowVehicleClass(-1, SVC_HOV);
118  }
119  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
120  if (classS[3] == '1') {
122  }
123  // Taxi -- becomes SVC_TAXI
124  if (classS[4] == '1') {
126  }
127  // Public Bus -- becomes SVC_BUS|SVC_COACH
128  if (classS[5] == '1') {
129  e.allowVehicleClass(-1, SVC_BUS);
131  }
132  // Delivery Truck -- becomes SVC_DELIVERY
133  if (classS[6] == '1') {
135  }
136  // Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
137  if (classS[7] == '1') {
140  }
141  // Bicycle -- becomes SVC_BICYCLE
142  if (classS[8] == '1') {
144  }
145  // Pedestrian -- becomes SVC_PEDESTRIAN
146  if (classS[9] == '1') {
148  }
149 }
150 
151 
152 void
153 NINavTeqHelper::addVehicleClassesV6(NBEdge& e, const std::string& oclassS) {
154  std::string classS = "0000000000" + oclassS;
155  classS = classS.substr(classS.length() - 12);
156  // 0: allow all vehicle types
157  if (classS[0] == '1') {
159  return;
160  }
161  // we have some restrictions. disallow all and then add classes indiviually
162  e.setPermissions(0);
163  // Passenger cars -- becomes SVC_PASSENGER
164  if (classS[1] == '1') {
166  }
167  // Residential Vehicle -- becomes SVC_PASSENGER
168  if (classS[2] == '1') {
170  }
171  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
172  if (classS[3] == '1') {
173  e.allowVehicleClass(-1, SVC_HOV);
175  }
176  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
177  if (classS[4] == '1') {
179  }
180  // Taxi -- becomes SVC_TAXI
181  if (classS[5] == '1') {
183  }
184  // Public Bus -- becomes SVC_BUS|SVC_COACH
185  if (classS[6] == '1') {
186  e.allowVehicleClass(-1, SVC_BUS);
188  }
189  // Delivery Truck -- becomes SVC_DELIVERY
190  if (classS[7] == '1') {
192  }
193  // Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
194  if (classS[8] == '1') {
197  }
198  // Motorcycle -- becomes SVC_MOTORCYCLE
199  if (classS[9] == '1') {
201  }
202  // Bicycle -- becomes SVC_BICYCLE
203  if (classS[10] == '1') {
205  }
206  // Pedestrian -- becomes SVC_PEDESTRIAN
207  if (classS[11] == '1') {
209  }
210 }
211 /****************************************************************************/
212 
vehicle is a motorcycle
vehicle is a coach
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:86
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:3413
const SVCPermissions SVCAll
all VClasses are allowed
vehicle is a HOV
vehicle is a large transport vehicle
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
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
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:3232
public emergency vehicles