1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file NIVissimSingleTypeParser_VWunschentscheidungsdefinition.cpp 11 /// @author Daniel Krajzewicz 12 /// @author Michael Behrisch 13 /// @date Wed, 18 Dec 2002 14 /// @version $Id$ 15 /// 16 // 17 /****************************************************************************/ 18 19 20 // =========================================================================== 21 // included modules 22 // =========================================================================== 23 #include <config.h> 24 25 #include <iostream> 26 #include <vector> 27 #include <cassert> 28 #include <utils/common/StringUtils.h> 29 #include "../NIImporter_Vissim.h" 30 #include "../tempstructs/NIVissimEdge.h" 31 #include "../tempstructs/NIVissimConnection.h" 32 #include "NIVissimSingleTypeParser_VWunschentscheidungsdefinition.h" 33 34 35 // =========================================================================== 36 // method definitions 37 // =========================================================================== NIVissimSingleTypeParser_VWunschentscheidungsdefinition(NIImporter_Vissim & parent)38NIVissimSingleTypeParser_VWunschentscheidungsdefinition::NIVissimSingleTypeParser_VWunschentscheidungsdefinition(NIImporter_Vissim& parent) 39 : NIImporter_Vissim::VissimSingleTypeParser(parent) {} 40 41 ~NIVissimSingleTypeParser_VWunschentscheidungsdefinition()42NIVissimSingleTypeParser_VWunschentscheidungsdefinition::~NIVissimSingleTypeParser_VWunschentscheidungsdefinition() {} 43 44 45 bool parse(std::istream & from)46NIVissimSingleTypeParser_VWunschentscheidungsdefinition::parse(std::istream& from) { 47 std::string tag; 48 from >> tag; // id 49 from >> tag; // name 50 tag = readName(from); 51 tag = overrideOptionalLabel(from); 52 from >> tag; // strecke 53 std::string edgeid; 54 from >> edgeid; 55 from >> tag; // spur 56 std::string lane; 57 from >> lane; 58 from >> tag; // bei 59 std::string pos; 60 from >> pos; 61 from >> tag; // fahrzeugklasse 62 from >> tag; // <fahrzeugklasse> 63 from >> tag; // vwunsch 64 std::string vwunsch; 65 from >> vwunsch; // vwunsch 66 std::vector<std::string> tmp; 67 tmp.push_back("zeit"); 68 tmp.push_back("fahrzeugklasse"); 69 tag = readEndSecure(from, tmp); 70 while (tag != "DATAEND" && tag != "zeit") { 71 from >> tag; 72 from >> tag; 73 from >> tag; 74 tag = myRead(from); 75 } 76 if (tag == "zeit") { 77 from >> tag; 78 from >> tag; 79 from >> tag; 80 from >> tag; 81 } 82 int numid = StringUtils::toInt(edgeid); 83 int numlane = StringUtils::toInt(lane) - 1; 84 int numv = StringUtils::toInt(vwunsch); 85 NIVissimEdge* e = NIVissimEdge::dictionary(numid); 86 if (e == nullptr) { 87 NIVissimConnection* c = NIVissimConnection::dictionary(numid); 88 const std::vector<int>& lanes = c->getToLanes(); 89 e = NIVissimEdge::dictionary(c->getToEdgeID()); 90 for (std::vector<int>::const_iterator j = lanes.begin(); j != lanes.end(); j++) { 91 e->setSpeed((*j), numv); 92 } 93 assert(e != 0); 94 } else { 95 e->setSpeed(numlane, numv); 96 } 97 return true; 98 } 99 100 101 102 /****************************************************************************/ 103 104