00001 /****************************************************************************/ 00007 // 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright 2001-2010 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 <iostream> 00031 #include <vector> 00032 #include <cassert> 00033 #include <utils/common/TplConvert.h> 00034 #include "../NIImporter_Vissim.h" 00035 #include "../tempstructs/NIVissimEdge.h" 00036 #include "../tempstructs/NIVissimConnection.h" 00037 #include "NIVissimSingleTypeParser_VWunschentscheidungsdefinition.h" 00038 00039 #ifdef CHECK_MEMORY_LEAKS 00040 #include <foreign/nvwa/debug_new.h> 00041 #endif // CHECK_MEMORY_LEAKS 00042 00043 00044 // =========================================================================== 00045 // method definitions 00046 // =========================================================================== 00047 NIVissimSingleTypeParser_VWunschentscheidungsdefinition::NIVissimSingleTypeParser_VWunschentscheidungsdefinition(NIImporter_Vissim &parent) 00048 : NIImporter_Vissim::VissimSingleTypeParser(parent) {} 00049 00050 00051 NIVissimSingleTypeParser_VWunschentscheidungsdefinition::~NIVissimSingleTypeParser_VWunschentscheidungsdefinition() {} 00052 00053 00054 bool 00055 NIVissimSingleTypeParser_VWunschentscheidungsdefinition::parse(std::istream &from) { 00056 std::string tag; 00057 from >> tag; // id 00058 from >> tag; // name 00059 tag = readName(from); 00060 tag = overrideOptionalLabel(from); 00061 from >> tag; // strecke 00062 std::string edgeid; 00063 from >> edgeid; 00064 from >> tag; // spur 00065 std::string lane; 00066 from >> lane; 00067 from >> tag; // bei 00068 std::string pos; 00069 from >> pos; 00070 from >> tag; // fahrzeugklasse 00071 from >> tag; // <fahrzeugklasse> 00072 from >> tag; // vwunsch 00073 std::string vwunsch; 00074 from >> vwunsch; // vwunsch 00075 std::vector<std::string> tmp; 00076 tmp.push_back("zeit"); 00077 tmp.push_back("fahrzeugklasse"); 00078 tag = readEndSecure(from, tmp); 00079 while (tag!="DATAEND"&&tag!="zeit") { 00080 from >> tag; 00081 from >> tag; 00082 from >> tag; 00083 tag = myRead(from); 00084 } 00085 if (tag=="zeit") { 00086 from >> tag; 00087 from >> tag; 00088 from >> tag; 00089 from >> tag; 00090 } 00091 int numid = TplConvert<char>::_2int(edgeid.c_str()); 00092 int numlane = TplConvert<char>::_2int(lane.c_str()) - 1; 00093 int numv = TplConvert<char>::_2int(vwunsch.c_str()); 00094 NIVissimEdge *e = NIVissimEdge::dictionary(numid); 00095 if (e==0) { 00096 NIVissimConnection *c = NIVissimConnection::dictionary(numid); 00097 const IntVector &lanes = c->getToLanes(); 00098 e = NIVissimEdge::dictionary(c->getToEdgeID()); 00099 for (IntVector::const_iterator j=lanes.begin(); j!=lanes.end(); j++) { 00100 e->setSpeed((*j), numv); 00101 } 00102 assert(e!=0); 00103 } else { 00104 e->setSpeed(numlane, numv); 00105 } 00106 return true; 00107 } 00108 00109 00110 00111 /****************************************************************************/ 00112
1.5.6