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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <iostream>
35 #include "../NIImporter_Vissim.h"
36 #include "../tempstructs/NIVissimExtendedEdgePoint.h"
37 #include "../tempstructs/NIVissimDisturbance.h"
39 
40 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
45  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
46 
47 
49 
50 
51 bool
53  std::string tag;
54  tag = myRead(from);
55  if (tag == "nureigenestrecke") {
56  return parseOnlyMe(from);
57  } else if (tag == "ort") {
58  return parsePositionDescribed(from);
59  } else if (tag == "nummer") {
60  return parseNumbered(from);
61  }
63  "NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition: format problem");
64  throw 1;
65 }
66 
67 bool
69  std::string tag;
70  from >> tag;
71  return true;
72 }
73 
74 
75 bool
77  std::string tag = myRead(from);
79 // from >> tag; // "Durch"
80  bool ok = true;
81  do {
82  from >> tag; // "Strecke"
84  //
85  double timegap;
86  from >> timegap;
87 
88  from >> tag;
89  double waygap;
90  from >> waygap;
91 
92  double vmax = -1;
93  tag = readEndSecure(from);
94  if (tag == "vmax") {
95  from >> vmax;
96  }
97  ok = NIVissimDisturbance::dictionary("", edge, by);
98  if (tag != "DATAEND") {
99  tag = readEndSecure(from);
100  }
101  } while (tag != "DATAEND" && ok);
102  return ok;
103 }
104 
105 
106 
107 bool
109  //
110  int id;
111  from >> id;
112  //
113  std::string tag;
114  from >> tag;
115  std::string name = readName(from);
116  // skip optional "Beschriftung"
117  while (tag != "ort") {
118  tag = myRead(from);
119  }
120  //
121  from >> tag; // "Strecke"
122  NIVissimExtendedEdgePoint edge = parsePos(from);
123  bool ok = true;
124  do {
125  from >> tag; // "Ort"
126  from >> tag; // "Strecke"
128  //
129  double timegap;
130  from >> timegap;
131 
132  double waygap;
133  from >> tag;
134  from >> waygap;
135 
136  double vmax = -1;
137  tag = readEndSecure(from);
138  if (tag == "vmax") {
139  from >> vmax;
140  }
141 
142  ok = NIVissimDisturbance::dictionary(name, edge, by);
143  if (tag != "DATAEND") {
144  tag = readEndSecure(from);
145  }
146  } while (tag != "DATAEND" && ok);
147  return ok;
148 }
149 
150 
151 
154  int edgeid;
155  from >> edgeid; // type-checking is missing!
156  //
157  std::string tag;
158  from >> tag;
159  from >> tag;
160  std::vector<int> lanes;
161  if (tag == "ALLE") {
162  //lanes.push_back(1); // !!!
163  } else {
164  lanes.push_back(TplConvert::_2int(tag.c_str()));
165  }
166  //
167  double position;
168  from >> tag;
169  from >> position;
170  // assigned vehicle types
171  std::vector<int> types;
172  from >> tag;
173  while (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND" && tag != "alle") {
174  tag = readEndSecure(from);
175  if (tag != "DATAEND") {
176  if (tag == "alle") {
177  types.push_back(-1);
178  from >> tag;
179  tag = "alle";
180  } else if (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND") {
181  int tmp = TplConvert::_2int(tag.c_str());
182  types.push_back(tmp);
183  }
184  }
185  }
186  return NIVissimExtendedEdgePoint(edgeid, lanes, position, types);
187 }
188 
189 
190 
191 /****************************************************************************/
192 
bool parse(std::istream &from)
Parses the data type from the given stream.
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
Importer for networks stored in Vissim format.
static bool dictionary(const std::string &name, const NIVissimExtendedEdgePoint &edge, const NIVissimExtendedEdgePoint &by)
bool parsePositionDescribed(std::istream &from)
parses a disturbance described by its position
bool parseNumbered(std::istream &from)
parses a full description of a disturbance
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
Definition: TplConvert.h:155