SUMO - Simulation of Urban MObility
 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-sim.org/
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"
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_PUBLIC_TRANSPORT
139  if (classS[5] == '1') {
141  e.allowVehicleClass(-1, SVC_BUS);
142  }
143  // Delivery Truck -- becomes SVC_DELIVERY
144  if (classS[6] == '1') {
146  }
147  // Transport Truck -- becomes SVC_TRANSPORT
148  if (classS[7] == '1') {
150  }
151  // Bicycle -- becomes SVC_BICYCLE
152  if (classS[8] == '1') {
154  }
155  // Pedestrian -- becomes SVC_PEDESTRIAN
156  if (classS[9] == '1') {
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') {
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') {
176  }
177  // Residential Vehicle -- becomes SVC_PASSENGER
178  if (classS[2] == '1') {
180  }
181  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
182  if (classS[3] == '1') {
183  e.allowVehicleClass(-1, SVC_HOV);
185  }
186  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
187  if (classS[4] == '1') {
189  }
190  // Taxi -- becomes SVC_TAXI
191  if (classS[5] == '1') {
193  }
194  // Public Bus -- becomes SVC_BUS|SVC_PUBLIC_TRANSPORT
195  if (classS[6] == '1') {
197  e.allowVehicleClass(-1, SVC_BUS);
198  }
199  // Delivery Truck -- becomes SVC_DELIVERY
200  if (classS[7] == '1') {
202  }
203  // Transport Truck -- becomes SVC_TRANSPORT
204  if (classS[8] == '1') {
206  }
207  // Motorcycle -- becomes SVC_MOTORCYCLE
208  if (classS[9] == '1') {
210  }
211  // Bicycle -- becomes SVC_BICYCLE
212  if (classS[10] == '1') {
214  }
215  // Pedestrian -- becomes SVC_PEDESTRIAN
216  if (classS[11] == '1') {
218  }
219 }
220 /****************************************************************************/
221 
vehicle is a motorcycle
is a pedestrian
vehicle is a large transport vehicle
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:2039
vehicle is a HOV
const SVCPermissions SVCFreeForAll
vehicle is a passenger car (a &quot;normal&quot; 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
public emergency vehicles
static int _2int(const E *const data)
Definition: TplConvert.h:114
#define SUMOReal
Definition: config.h:215
public transport vehicles
void allowVehicleClass(int lane, SUMOVehicleClass vclass)
set allowed class for the given lane or for all lanes if -1 is given
Definition: NBEdge.cpp:1938