SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 //
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <iostream>
36 #include "../NIImporter_Vissim.h"
37 #include "../tempstructs/NIVissimExtendedEdgePoint.h"
38 #include "../tempstructs/NIVissimDisturbance.h"
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
46  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
47 
48 
50 
51 
52 bool
54  std::string tag;
55  tag = myRead(from);
56  if (tag == "nureigenestrecke") {
57  return parseOnlyMe(from);
58  } else if (tag == "ort") {
59  return parsePositionDescribed(from);
60  } else if (tag == "nummer") {
61  return parseNumbered(from);
62  }
64  "NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition: format problem");
65  throw 1;
66 }
67 
68 bool
70  std::string tag;
71  from >> tag;
72  return true;
73 }
74 
75 
76 bool
78  std::string tag = myRead(from);
80 // from >> tag; // "Durch"
81  bool ok = true;
82  do {
83  from >> tag; // "Strecke"
85  //
86  double timegap;
87  from >> timegap;
88 
89  from >> tag;
90  double waygap;
91  from >> waygap;
92 
93  double vmax = -1;
94  tag = readEndSecure(from);
95  if (tag == "vmax") {
96  from >> vmax;
97  }
98  ok = NIVissimDisturbance::dictionary("", edge, by);
99  if (tag != "DATAEND") {
100  tag = readEndSecure(from);
101  }
102  } while (tag != "DATAEND" && ok);
103  return ok;
104 }
105 
106 
107 
108 bool
110  //
111  int id;
112  from >> id;
113  //
114  std::string tag;
115  from >> tag;
116  std::string name = readName(from);
117  // skip optional "Beschriftung"
118  while (tag != "ort") {
119  tag = myRead(from);
120  }
121  //
122  from >> tag; // "Strecke"
123  NIVissimExtendedEdgePoint edge = parsePos(from);
124  bool ok = true;
125  do {
126  from >> tag; // "Ort"
127  from >> tag; // "Strecke"
129  //
130  double timegap;
131  from >> timegap;
132 
133  double waygap;
134  from >> tag;
135  from >> waygap;
136 
137  double vmax = -1;
138  tag = readEndSecure(from);
139  if (tag == "vmax") {
140  from >> vmax;
141  }
142 
143  ok = NIVissimDisturbance::dictionary(name, edge, by);
144  if (tag != "DATAEND") {
145  tag = readEndSecure(from);
146  }
147  } while (tag != "DATAEND" && ok);
148  return ok;
149 }
150 
151 
152 
155  int edgeid;
156  from >> edgeid; // type-checking is missing!
157  //
158  std::string tag;
159  from >> tag;
160  from >> tag;
161  std::vector<int> lanes;
162  if (tag == "ALLE") {
163  //lanes.push_back(1); // !!!
164  } else {
165  lanes.push_back(TplConvert::_2int(tag.c_str()));
166  }
167  //
168  double position;
169  from >> tag;
170  from >> position;
171  // assigned vehicle types
172  std::vector<int> types;
173  from >> tag;
174  while (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND" && tag != "alle") {
175  tag = readEndSecure(from);
176  if (tag != "DATAEND") {
177  if (tag == "alle") {
178  types.push_back(-1);
179  from >> tag;
180  tag = "alle";
181  } else if (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND") {
182  int tmp = TplConvert::_2int(tag.c_str());
183  types.push_back(tmp);
184  }
185  }
186  }
187  return NIVissimExtendedEdgePoint(edgeid, lanes, position, types);
188 }
189 
190 
191 
192 /****************************************************************************/
193 
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:206
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
Definition: TplConvert.h:149