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