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