SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_VWunschentscheidungsdefinition.cpp
Go to the documentation of this file.
00001 /****************************************************************************/
00008 //
00009 /****************************************************************************/
00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00012 /****************************************************************************/
00013 //
00014 //   This file is part of SUMO.
00015 //   SUMO is free software: you can redistribute it and/or modify
00016 //   it under the terms of the GNU General Public License as published by
00017 //   the Free Software Foundation, either version 3 of the License, or
00018 //   (at your option) any later version.
00019 //
00020 /****************************************************************************/
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <iostream>
00033 #include <vector>
00034 #include <cassert>
00035 #include <utils/common/TplConvert.h>
00036 #include "../NIImporter_Vissim.h"
00037 #include "../tempstructs/NIVissimEdge.h"
00038 #include "../tempstructs/NIVissimConnection.h"
00039 #include "NIVissimSingleTypeParser_VWunschentscheidungsdefinition.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 NIVissimSingleTypeParser_VWunschentscheidungsdefinition::NIVissimSingleTypeParser_VWunschentscheidungsdefinition(NIImporter_Vissim& parent)
00050     : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
00051 
00052 
00053 NIVissimSingleTypeParser_VWunschentscheidungsdefinition::~NIVissimSingleTypeParser_VWunschentscheidungsdefinition() {}
00054 
00055 
00056 bool
00057 NIVissimSingleTypeParser_VWunschentscheidungsdefinition::parse(std::istream& from) {
00058     std::string tag;
00059     from >> tag; // id
00060     from >> tag; // name
00061     tag = readName(from);
00062     tag = overrideOptionalLabel(from);
00063     from >> tag; // strecke
00064     std::string edgeid;
00065     from >> edgeid;
00066     from >> tag; // spur
00067     std::string lane;
00068     from >> lane;
00069     from >> tag; // bei
00070     std::string pos;
00071     from >> pos;
00072     from >> tag; // fahrzeugklasse
00073     from >> tag; // <fahrzeugklasse>
00074     from >> tag; // vwunsch
00075     std::string vwunsch;
00076     from >> vwunsch; // vwunsch
00077     std::vector<std::string> tmp;
00078     tmp.push_back("zeit");
00079     tmp.push_back("fahrzeugklasse");
00080     tag = readEndSecure(from, tmp);
00081     while (tag != "DATAEND" && tag != "zeit") {
00082         from >> tag;
00083         from >> tag;
00084         from >> tag;
00085         tag = myRead(from);
00086     }
00087     if (tag == "zeit") {
00088         from >> tag;
00089         from >> tag;
00090         from >> tag;
00091         from >> tag;
00092     }
00093     int numid = TplConvert<char>::_2int(edgeid.c_str());
00094     int numlane = TplConvert<char>::_2int(lane.c_str()) - 1;
00095     int numv = TplConvert<char>::_2int(vwunsch.c_str());
00096     NIVissimEdge* e = NIVissimEdge::dictionary(numid);
00097     if (e == 0) {
00098         NIVissimConnection* c = NIVissimConnection::dictionary(numid);
00099         const std::vector<int>& lanes = c->getToLanes();
00100         e = NIVissimEdge::dictionary(c->getToEdgeID());
00101         for (std::vector<int>::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
00102             e->setSpeed((*j), numv);
00103         }
00104         assert(e != 0);
00105     } else {
00106         e->setSpeed(numlane, numv);
00107     }
00108     return true;
00109 }
00110 
00111 
00112 
00113 /****************************************************************************/
00114 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines