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.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 /****************************************************************************/
15 //
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include <iostream>
25 #include <vector>
26 #include <cassert>
28 #include "../NIImporter_Vissim.h"
29 #include "../tempstructs/NIVissimEdge.h"
30 #include "../tempstructs/NIVissimConnection.h"
32 
33 
34 // ===========================================================================
35 // method definitions
36 // ===========================================================================
38  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
39 
40 
42 
43 
44 bool
46  std::string tag;
47  from >> tag; // id
48  from >> tag; // name
49  tag = readName(from);
50  tag = overrideOptionalLabel(from);
51  from >> tag; // strecke
52  std::string edgeid;
53  from >> edgeid;
54  from >> tag; // spur
55  std::string lane;
56  from >> lane;
57  from >> tag; // bei
58  std::string pos;
59  from >> pos;
60  from >> tag; // fahrzeugklasse
61  from >> tag; // <fahrzeugklasse>
62  from >> tag; // vwunsch
63  std::string vwunsch;
64  from >> vwunsch; // vwunsch
65  std::vector<std::string> tmp;
66  tmp.push_back("zeit");
67  tmp.push_back("fahrzeugklasse");
68  tag = readEndSecure(from, tmp);
69  while (tag != "DATAEND" && tag != "zeit") {
70  from >> tag;
71  from >> tag;
72  from >> tag;
73  tag = myRead(from);
74  }
75  if (tag == "zeit") {
76  from >> tag;
77  from >> tag;
78  from >> tag;
79  from >> tag;
80  }
81  int numid = StringUtils::toInt(edgeid);
82  int numlane = StringUtils::toInt(lane) - 1;
83  int numv = StringUtils::toInt(vwunsch);
85  if (e == nullptr) {
87  const std::vector<int>& lanes = c->getToLanes();
89  for (std::vector<int>::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
90  e->setSpeed((*j), numv);
91  }
92  assert(e != 0);
93  } else {
94  e->setSpeed(numlane, numv);
95  }
96  return true;
97 }
98 
99 
100 
101 /****************************************************************************/
102 
NIVissimEdge
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:52
NIImporter_Vissim::VissimSingleTypeParser::readName
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
Definition: NIImporter_Vissim.cpp:797
NIVissimEdge::setSpeed
void setSpeed(int lane, int speedDist)
Definition: NIVissimEdge.cpp:858
NIImporter_Vissim
Importer for networks stored in Vissim format.
Definition: NIImporter_Vissim.h:58
NIVissimConnection::getToEdgeID
int getToEdgeID() const
Definition: NIVissimConnection.cpp:162
NIVissimEdge::dictionary
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.
Definition: NIVissimEdge.cpp:138
NIImporter_Vissim::VissimSingleTypeParser::readEndSecure
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
Definition: NIImporter_Vissim.cpp:679
NIVissimConnection
Definition: NIVissimConnection.h:45
NIVissimSingleTypeParser_VWunschentscheidungsdefinition::~NIVissimSingleTypeParser_VWunschentscheidungsdefinition
~NIVissimSingleTypeParser_VWunschentscheidungsdefinition()
Destructor.
Definition: NIVissimSingleTypeParser_VWunschentscheidungsdefinition.cpp:41
StringUtils.h
StringUtils::toInt
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
Definition: StringUtils.cpp:278
NIVissimSingleTypeParser_VWunschentscheidungsdefinition::NIVissimSingleTypeParser_VWunschentscheidungsdefinition
NIVissimSingleTypeParser_VWunschentscheidungsdefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_VWunschentscheidungsdefinition.cpp:37
NIVissimConnection::getToLanes
const std::vector< int > & getToLanes() const
Definition: NIVissimConnection.cpp:285
NIVissimSingleTypeParser_VWunschentscheidungsdefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_VWunschentscheidungsdefinition.cpp:45
NIImporter_Vissim::VissimSingleTypeParser::overrideOptionalLabel
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure
Definition: NIImporter_Vissim.cpp:727
config.h
NIVissimConnection::dictionary
static bool dictionary(int id, NIVissimConnection *o)
Definition: NIVissimConnection.cpp:77
NIImporter_Vissim::VissimSingleTypeParser::myRead
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
Definition: NIImporter_Vissim.cpp:670
NIVissimSingleTypeParser_VWunschentscheidungsdefinition.h