NINavTeqHelper.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include "NINavTeqHelper.h"
00031 #include <utils/common/TplConvert.h>
00032 #include <utils/common/MsgHandler.h>
00033 #include <utils/common/UtilExceptions.h>
00034 #include <netbuild/NBEdge.h>
00035
00036 #ifdef CHECK_MEMORY_LEAKS
00037 #include <foreign/nvwa/debug_new.h>
00038 #endif // CHECK_MEMORY_LEAKS
00039
00040
00041
00042
00043
00044 SUMOReal
00045 NINavTeqHelper::getSpeed(const std::string &id, const std::string &speedClassS) throw(ProcessError) {
00046 try {
00047 int speedClass = TplConvert<char>::_2int(speedClassS.c_str());
00048 switch (speedClass) {
00049 case -1:
00050 return (SUMOReal) 1.0 / (SUMOReal) 3.6;
00051 case 1:
00052 return (SUMOReal) 200 / (SUMOReal) 3.6;
00053 case 2:
00054 return (SUMOReal) 120 / (SUMOReal) 3.6;
00055 case 3:
00056 return (SUMOReal) 100 / (SUMOReal) 3.6;
00057 case 4:
00058 return (SUMOReal) 80 / (SUMOReal) 3.6;
00059 case 5:
00060 return (SUMOReal) 70 / (SUMOReal) 3.6;
00061 case 6:
00062 return (SUMOReal) 50 / (SUMOReal) 3.6;
00063 case 7:
00064 return (SUMOReal) 30 / (SUMOReal) 3.6;
00065 case 8:
00066 return (SUMOReal) 5 / (SUMOReal) 3.6;
00067 default:
00068 throw ProcessError("Invalid speed code (edge '" + id + "').");
00069 }
00070 } catch (NumberFormatException &) {
00071 throw ProcessError("Non-numerical value for an edge's speed type occured (edge '" + id + "').");
00072 }
00073 }
00074
00075
00076 unsigned int
00077 NINavTeqHelper::getLaneNumber(const std::string &id, const std::string &laneNoS, SUMOReal speed) throw(ProcessError) {
00078 try {
00079 int nolanes = TplConvert<char>::_2int(laneNoS.c_str());
00080 if (nolanes<0) {
00081 return 1;
00082 } else if (nolanes/10 > 0) {
00083 return nolanes / 10;
00084 } else {
00085 switch (nolanes%10) {
00086 case 1:
00087 return 1;
00088 case 2:
00089 nolanes = 2;
00090 if (speed>78.0/3.6) {
00091 nolanes = 3;
00092 }
00093 return nolanes;
00094 case 3:
00095 return 4;
00096 default:
00097 throw ProcessError("Invalid lane number (edge '" + id + "').");
00098 }
00099 }
00100 } catch (NumberFormatException &) {
00101 throw ProcessError("Non-numerical value for an edge's lane number occured (edge '" + id + "'.");
00102 }
00103 }
00104
00105
00106 void
00107 NINavTeqHelper::addVehicleClasses(NBEdge &e, const std::string &oclassS) throw() {
00108 std::string classS = "0000000000" + oclassS;
00109 classS = classS.substr(classS.length() - 10);
00110
00111 if (classS[0]=='1') {
00112 return;
00113 }
00114
00115 if (classS[1]=='1') {
00116 addVehicleClass(e, SVC_PASSENGER);
00117 }
00118
00119 if (classS[2]=='1') {
00120 addVehicleClass(e, SVC_HOV);
00121 addVehicleClass(e, SVC_PASSENGER);
00122 }
00123
00124 if (classS[3]=='1') {
00125 addVehicleClass(e, SVC_PUBLIC_EMERGENCY);
00126 }
00127
00128 if (classS[4]=='1') {
00129 addVehicleClass(e, SVC_TAXI);
00130 addVehicleClass(e, SVC_PASSENGER);
00131 }
00132
00133 if (classS[5]=='1') {
00134 addVehicleClass(e, SVC_PUBLIC_TRANSPORT);
00135 addVehicleClass(e, SVC_BUS);
00136 }
00137
00138 if (classS[6]=='1') {
00139 addVehicleClass(e, SVC_DELIVERY);
00140 }
00141
00142 if (classS[7]=='1') {
00143 addVehicleClass(e, SVC_TRANSPORT);
00144 }
00145
00146 if (classS[8]=='1') {
00147 addVehicleClass(e, SVC_BICYCLE);
00148 }
00149
00150 if (classS[9]=='1') {
00151 addVehicleClass(e, SVC_PEDESTRIAN);
00152 }
00153 }
00154
00155
00156 void
00157 NINavTeqHelper::addVehicleClass(NBEdge &e, SUMOVehicleClass c) throw() {
00158 for (unsigned int i=0; i<e.getNoLanes(); i++) {
00159 e.allowVehicleClass(i, c);
00160 }
00161 }
00162
00163
00164
00165
00166