|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Definition of a junction's type in dependence 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 00020 00021 // =========================================================================== 00022 // included modules 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 // method definitions 00045 // =========================================================================== 00046 NBJunctionTypesMatrix::NBJunctionTypesMatrix() { 00047 myMap['t'] = NODETYPE_TRAFFIC_LIGHT; 00048 myMap['x'] = NODETYPE_NOJUNCTION; 00049 myMap['p'] = NODETYPE_PRIORITY_JUNCTION; 00050 myMap['r'] = 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 // 00001x 00058 // 13570x 00059 // 00000x 00060 myValues.push_back("rppppp"); // 000 - 010 00061 myValues.push_back(" rpppp"); // 010 - 030 00062 myValues.push_back(" rppp"); // 030 - 050 00063 myValues.push_back(" ppp"); // 050 - 070 00064 myValues.push_back(" pp"); // 070 - 100 00065 myValues.push_back(" p"); // 100 - 00066 } 00067 00068 00069 NBJunctionTypesMatrix::~NBJunctionTypesMatrix() {} 00070 00071 00072 SumoXMLNodeType 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