|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // Definition of a junction's type in dependence 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 00023 00024 // =========================================================================== 00025 // included modules 00026 // =========================================================================== 00027 #ifdef _MSC_VER 00028 #include <windows_config.h> 00029 #else 00030 #include <config.h> 00031 #endif 00032 00033 #include <vector> 00034 #include <string> 00035 #include <map> 00036 #include <algorithm> 00037 #include "NBJunctionTypesMatrix.h" 00038 #include <utils/common/UtilExceptions.h> 00039 #include "NBNode.h" 00040 00041 #ifdef CHECK_MEMORY_LEAKS 00042 #include <foreign/nvwa/debug_new.h> 00043 #endif // CHECK_MEMORY_LEAKS 00044 00045 00046 // =========================================================================== 00047 // method definitions 00048 // =========================================================================== 00049 NBJunctionTypesMatrix::NBJunctionTypesMatrix() { 00050 myMap['t'] = NODETYPE_TRAFFIC_LIGHT; 00051 myMap['x'] = NODETYPE_NOJUNCTION; 00052 myMap['p'] = NODETYPE_PRIORITY_JUNCTION; 00053 myMap['r'] = NODETYPE_RIGHT_BEFORE_LEFT; 00054 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(0. / 3.6), (SUMOReal)(10. / 3.6))); 00055 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(10. / 3.6), (SUMOReal)(30. / 3.6))); 00056 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(30. / 3.6), (SUMOReal)(50. / 3.6))); 00057 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(50. / 3.6), (SUMOReal)(70. / 3.6))); 00058 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(70. / 3.6), (SUMOReal)(100. / 3.6))); 00059 myRanges.push_back(std::pair<SUMOReal, SUMOReal>((SUMOReal)(100. / 3.6), (SUMOReal)(999999. / 3.6))); 00060 // 00001x 00061 // 13570x 00062 // 00000x 00063 myValues.push_back("rppppp"); // 000 - 010 00064 myValues.push_back(" rpppp"); // 010 - 030 00065 myValues.push_back(" rppp"); // 030 - 050 00066 myValues.push_back(" ppp"); // 050 - 070 00067 myValues.push_back(" pp"); // 070 - 100 00068 myValues.push_back(" p"); // 100 - 00069 } 00070 00071 00072 NBJunctionTypesMatrix::~NBJunctionTypesMatrix() {} 00073 00074 00075 SumoXMLNodeType 00076 NBJunctionTypesMatrix::getType(SUMOReal speed1, SUMOReal speed2) const { 00077 RangeCont::const_iterator p1 = find_if(myRanges.begin(), myRanges.end(), range_finder(speed1)); 00078 RangeCont::const_iterator p2 = find_if(myRanges.begin(), myRanges.end(), range_finder(speed2)); 00079 char name = getNameAt(distance(myRanges.begin(), p1), distance(myRanges.begin(), p2)); 00080 return myMap.find(name)->second; 00081 } 00082 00083 00084 char 00085 NBJunctionTypesMatrix::getNameAt(size_t pos1, size_t pos2) const { 00086 std::string str = myValues[pos1]; 00087 if (str[pos2] == ' ') { 00088 return getNameAt(pos2, pos1); 00089 } 00090 return str[pos2]; 00091 } 00092 00093 00094 00095 /****************************************************************************/ 00096