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-2017 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 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
44 double
45 NINavTeqHelper::getSpeed(const std::string& id, const std::string& speedClassS) {
46  try {
47  int speedClass = TplConvert::_2int(speedClassS.c_str());
48  switch (speedClass) {
49  case -1:
50  return (double) 1.0 / (double) 3.6;
51  case 1:
52  return (double) 200 / (double) 3.6; //> 130 KPH / > 80 MPH
53  case 2:
54  return (double) 120 / (double) 3.6; //101-130 KPH / 65-80 MPH
55  case 3:
56  return (double) 100 / (double) 3.6; // 91-100 KPH / 55-64 MPH
57  case 4:
58  return (double) 80 / (double) 3.6; // 71-90 KPH / 41-54 MPH
59  case 5:
60  return (double) 70 / (double) 3.6; // 51-70 KPH / 31-40 MPH
61  case 6:
62  return (double) 50 / (double) 3.6; // 31-50 KPH / 21-30 MPH
63  case 7:
64  return (double) 30 / (double) 3.6; // 11-30 KPH / 6-20 MPH
65  case 8:
66  return (double) 5 / (double) 3.6; //< 11 KPH / < 6 MPH
67  default:
68  throw ProcessError("Invalid speed code (edge '" + id + "').");
69  }
70  } catch (NumberFormatException&) {
71  throw ProcessError("Non-numerical value for an edge's speed type occured (edge '" + id + "').");
72  }
73 }
74 
75 
76 int
77 NINavTeqHelper::getLaneNumber(const std::string& id, const std::string& laneNoS, double speed) {
78  try {
79  int nolanes = TplConvert::_2int(laneNoS.c_str());
80  if (nolanes < 0) {
81  return 1;
82  } else if (nolanes / 10 > 0) {
83  return nolanes / 10;
84  } else {
85  switch (nolanes % 10) {
86  case 1:
87  return 1;
88  case 2:
89  nolanes = 2;
90  if (speed > 78.0 / 3.6) {
91  nolanes = 3;
92  }
93  return nolanes;
94  case 3:
95  return 4;
96  default:
97  throw ProcessError("Invalid lane number (edge '" + id + "').");
98  }
99  }
100  } catch (NumberFormatException&) {
101  throw ProcessError("Non-numerical value for an edge's lane number occured (edge '" + id + "'.");
102  }
103 }
104 
105 
106 void
107 NINavTeqHelper::addVehicleClasses(NBEdge& e, const std::string& oclassS) {
108  std::string classS = "0000000000" + oclassS;
109  classS = classS.substr(classS.length() - 10);
110  // 0: allow all vehicle types
111  if (classS[0] == '1') {
113  return;
114  }
115  // we have some restrictions. disallow all and then add classes indiviually
116  e.setPermissions(0);
117  // Passenger cars -- becomes SVC_PASSENGER
118  if (classS[1] == '1') {
120  }
121  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
122  if (classS[2] == '1') {
123  e.allowVehicleClass(-1, SVC_HOV);
125  }
126  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
127  if (classS[3] == '1') {
129  }
130  // Taxi -- becomes SVC_TAXI
131  if (classS[4] == '1') {
133  }
134  // Public Bus -- becomes SVC_BUS|SVC_COACH
135  if (classS[5] == '1') {
136  e.allowVehicleClass(-1, SVC_BUS);
138  }
139  // Delivery Truck -- becomes SVC_DELIVERY
140  if (classS[6] == '1') {
142  }
143  // Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
144  if (classS[7] == '1') {
147  }
148  // Bicycle -- becomes SVC_BICYCLE
149  if (classS[8] == '1') {
151  }
152  // Pedestrian -- becomes SVC_PEDESTRIAN
153  if (classS[9] == '1') {
155  }
156 }
157 
158 
159 void
160 NINavTeqHelper::addVehicleClassesV6(NBEdge& e, const std::string& oclassS) {
161  std::string classS = "0000000000" + oclassS;
162  classS = classS.substr(classS.length() - 12);
163  // 0: allow all vehicle types
164  if (classS[0] == '1') {
166  return;
167  }
168  // we have some restrictions. disallow all and then add classes indiviually
169  e.setPermissions(0);
170  // Passenger cars -- becomes SVC_PASSENGER
171  if (classS[1] == '1') {
173  }
174  // Residential Vehicle -- becomes SVC_PASSENGER
175  if (classS[2] == '1') {
177  }
178  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
179  if (classS[3] == '1') {
180  e.allowVehicleClass(-1, SVC_HOV);
182  }
183  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
184  if (classS[4] == '1') {
186  }
187  // Taxi -- becomes SVC_TAXI
188  if (classS[5] == '1') {
190  }
191  // Public Bus -- becomes SVC_BUS|SVC_COACH
192  if (classS[6] == '1') {
193  e.allowVehicleClass(-1, SVC_BUS);
195  }
196  // Delivery Truck -- becomes SVC_DELIVERY
197  if (classS[7] == '1') {
199  }
200  // Transport Truck -- becomes SVC_TRUCK|SVC_TRAILER
201  if (classS[8] == '1') {
204  }
205  // Motorcycle -- becomes SVC_MOTORCYCLE
206  if (classS[9] == '1') {
208  }
209  // Bicycle -- becomes SVC_BICYCLE
210  if (classS[10] == '1') {
212  }
213  // Pedestrian -- becomes SVC_PEDESTRIAN
214  if (classS[11] == '1') {
216  }
217 }
218 /****************************************************************************/
219 
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:71
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:2885
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:149
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:2768
public emergency vehicles