Eclipse SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_VWunschentscheidungsdefinition.cpp
Go to the documentation of this file.
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 /****************************************************************************/
19 //
20 /****************************************************************************/
21 #include <config.h>
22 
23 #include <iostream>
24 #include <vector>
25 #include <cassert>
31 
32 
33 // ===========================================================================
34 // method definitions
35 // ===========================================================================
37  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
38 
39 
41 
42 
43 bool
45  std::string tag;
46  from >> tag; // id
47  from >> tag; // name
48  tag = readName(from);
49  tag = overrideOptionalLabel(from);
50  from >> tag; // strecke
51  std::string edgeid;
52  from >> edgeid;
53  from >> tag; // spur
54  std::string lane;
55  from >> lane;
56  from >> tag; // bei
57  std::string pos;
58  from >> pos;
59  from >> tag; // fahrzeugklasse
60  from >> tag; // <fahrzeugklasse>
61  from >> tag; // vwunsch
62  std::string vwunsch;
63  from >> vwunsch; // vwunsch
64  std::vector<std::string> tmp;
65  tmp.push_back("zeit");
66  tmp.push_back("fahrzeugklasse");
67  tag = readEndSecure(from, tmp);
68  while (tag != "DATAEND" && tag != "zeit") {
69  from >> tag;
70  from >> tag;
71  from >> tag;
72  tag = myRead(from);
73  }
74  if (tag == "zeit") {
75  from >> tag;
76  from >> tag;
77  from >> tag;
78  from >> tag;
79  }
80  int numid = StringUtils::toInt(edgeid);
81  int numlane = StringUtils::toInt(lane) - 1;
82  int numv = StringUtils::toInt(vwunsch);
84  if (e == nullptr) {
86  const std::vector<int>& lanes = c->getToLanes();
88  for (std::vector<int>::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
89  e->setSpeed((*j), numv);
90  }
91  assert(e != 0);
92  } else {
93  e->setSpeed(numlane, numv);
94  }
95  return true;
96 }
97 
98 
99 /****************************************************************************/
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
Importer for networks stored in Vissim format.
const std::vector< int > & getToLanes() const
static bool dictionary(int id, NIVissimConnection *o)
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:51
void setSpeed(int lane, int speedDist)
static bool dictionary(int id, const std::string &name, const std::string &type, int noLanes, double zuschlag1, double zuschlag2, double length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Adds the described item to the dictionary Builds the edge first.
bool parse(std::istream &from)
Parses the data type from the given stream.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...