Eclipse SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.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 /****************************************************************************/
16 //
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <iostream>
28 #include "../NIImporter_Vissim.h"
29 #include "../tempstructs/NIVissimExtendedEdgePoint.h"
30 #include "../tempstructs/NIVissimDisturbance.h"
32 
33 
34 // ===========================================================================
35 // method definitions
36 // ===========================================================================
38  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
39 
40 
42 
43 
44 bool
46  std::string tag;
47  tag = myRead(from);
48  if (tag == "nureigenestrecke") {
49  return parseOnlyMe(from);
50  } else if (tag == "ort") {
51  return parsePositionDescribed(from);
52  } else if (tag == "nummer") {
53  return parseNumbered(from);
54  }
56  "NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition: format problem");
57  throw 1;
58 }
59 
60 bool
62  std::string tag;
63  from >> tag;
64  return true;
65 }
66 
67 
68 bool
70  std::string tag = myRead(from);
72 // from >> tag; // "Durch"
73  bool ok = true;
74  do {
75  from >> tag; // "Strecke"
77  //
78  double timegap;
79  from >> timegap;
80 
81  from >> tag;
82  double waygap;
83  from >> waygap;
84 
85  double vmax = -1;
86  tag = readEndSecure(from);
87  if (tag == "vmax") {
88  from >> vmax;
89  }
90  ok = NIVissimDisturbance::dictionary("", edge, by);
91  if (tag != "DATAEND") {
92  tag = readEndSecure(from);
93  }
94  } while (tag != "DATAEND" && ok);
95  return ok;
96 }
97 
98 
99 
100 bool
102  //
103  int id;
104  from >> id;
105  //
106  std::string tag;
107  from >> tag;
108  std::string name = readName(from);
109  // skip optional "Beschriftung"
110  while (tag != "ort") {
111  tag = myRead(from);
112  }
113  //
114  from >> tag; // "Strecke"
115  NIVissimExtendedEdgePoint edge = parsePos(from);
116  bool ok = true;
117  do {
118  from >> tag; // "Ort"
119  from >> tag; // "Strecke"
121  //
122  double timegap;
123  from >> timegap;
124 
125  double waygap;
126  from >> tag;
127  from >> waygap;
128 
129  double vmax = -1;
130  tag = readEndSecure(from);
131  if (tag == "vmax") {
132  from >> vmax;
133  }
134 
135  ok = NIVissimDisturbance::dictionary(name, edge, by);
136  if (tag != "DATAEND") {
137  tag = readEndSecure(from);
138  }
139  } while (tag != "DATAEND" && ok);
140  return ok;
141 }
142 
143 
144 
147  int edgeid;
148  from >> edgeid; // type-checking is missing!
149  //
150  std::string tag;
151  from >> tag;
152  from >> tag;
153  std::vector<int> lanes;
154  if (tag == "ALLE") {
155  //lanes.push_back(1); // !!!
156  } else {
157  lanes.push_back(StringUtils::toInt(tag));
158  }
159  //
160  double position;
161  from >> tag;
162  from >> position;
163  // assigned vehicle types
164  std::vector<int> types;
165  from >> tag;
166  while (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND" && tag != "alle") {
167  tag = readEndSecure(from);
168  if (tag != "DATAEND") {
169  if (tag == "alle") {
170  types.push_back(-1);
171  from >> tag;
172  tag = "alle";
173  } else if (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND") {
174  int tmp = StringUtils::toInt(tag);
175  types.push_back(tmp);
176  }
177  }
178  }
179  return NIVissimExtendedEdgePoint(edgeid, lanes, position, types);
180 }
181 
182 
183 
184 /****************************************************************************/
185 
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp:45
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::~NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition
~NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp:41
MsgHandler.h
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
NIVissimDisturbance::dictionary
static bool dictionary(const std::string &name, const NIVissimExtendedEdgePoint &edge, const NIVissimExtendedEdgePoint &by)
Definition: NIVissimDisturbance.cpp:68
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePositionDescribed
bool parsePositionDescribed(std::istream &from)
parses a disturbance described by its position
Definition: NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp:69
NIImporter_Vissim
Importer for networks stored in Vissim format.
Definition: NIImporter_Vissim.h:58
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseOnlyMe
bool parseOnlyMe(std::istream &from)
?? (unknown vissim-description)
Definition: NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp:61
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePos
NIVissimExtendedEdgePoint parsePos(std::istream &from)
Definition: NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp:146
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
NIVissimExtendedEdgePoint
Definition: NIVissimExtendedEdgePoint.h:42
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseNumbered
bool parseNumbered(std::istream &from)
parses a full description of a disturbance
Definition: NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp:101
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp:37
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_Querverkehrsstoerungsdefinition.h
config.h
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
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283