NBJunctionTypesMatrix.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 <vector>
00031 #include <string>
00032 #include <map>
00033 #include <algorithm>
00034 #include "NBJunctionTypesMatrix.h"
00035 #include <utils/common/UtilExceptions.h>
00036 #include "NBNode.h"
00037
00038 #ifdef CHECK_MEMORY_LEAKS
00039 #include <foreign/nvwa/debug_new.h>
00040 #endif // CHECK_MEMORY_LEAKS
00041
00042
00043
00044
00045
00046 NBJunctionTypesMatrix::NBJunctionTypesMatrix() {
00047 myMap['t'] = NBNode::NODETYPE_TRAFFIC_LIGHT;
00048 myMap['x'] = NBNode::NODETYPE_NOJUNCTION;
00049 myMap['p'] = NBNode::NODETYPE_PRIORITY_JUNCTION;
00050 myMap['r'] = NBNode::NODETYPE_RIGHT_BEFORE_LEFT;
00051 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(0./3.6), (SUMOReal)(10./3.6)));
00052 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(10./3.6), (SUMOReal)(30./3.6)));
00053 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(30./3.6), (SUMOReal)(50./3.6)));
00054 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(50./3.6), (SUMOReal)(70./3.6)));
00055 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(70./3.6), (SUMOReal)(100./3.6)));
00056 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(100./3.6), (SUMOReal)(999999./3.6)));
00057
00058
00059
00060 myValues.push_back("rppppp");
00061 myValues.push_back(" rpppp");
00062 myValues.push_back(" rppp");
00063 myValues.push_back(" ttp");
00064 myValues.push_back(" tp");
00065 myValues.push_back(" p");
00066 }
00067
00068
00069 NBJunctionTypesMatrix::~NBJunctionTypesMatrix() {}
00070
00071
00072 NBNode::BasicNodeType
00073 NBJunctionTypesMatrix::getType(SUMOReal speed1, SUMOReal speed2) const {
00074 RangeCont::const_iterator p1 = find_if(myRanges.begin(), myRanges.end(), range_finder(speed1));
00075 RangeCont::const_iterator p2 = find_if(myRanges.begin(), myRanges.end(), range_finder(speed2));
00076 char name = getNameAt(distance(myRanges.begin(), p1), distance(myRanges.begin(), p2));
00077 return myMap.find(name)->second;
00078 }
00079
00080
00081 char
00082 NBJunctionTypesMatrix::getNameAt(size_t pos1, size_t pos2) const {
00083 std::string str = myValues[pos1];
00084 if (str[pos2]==' ') {
00085 return getNameAt(pos2, pos1);
00086 }
00087 return str[pos2];
00088 }
00089
00090
00091
00092
00093