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.sourceforge.net/
13 // Copyright (C) 2001-2012 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<char>::_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<char>::_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') {
116  return;
117  }
118  // we have some restrictions. disallow all and then add classes indiviually
119  e.setPermissions(0);
120  // Passenger cars -- becomes SVC_PASSENGER
121  if (classS[1] == '1') {
123  }
124  // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
125  if (classS[2] == '1') {
126  e.allowVehicleClass(-1, SVC_HOV);
128  }
129  // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
130  if (classS[3] == '1') {
132  }
133  // Taxi -- becomes SVC_PASSENGER|SVC_TAXI
134  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