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-2015 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 #ifdef CHECK_MEMORY_LEAKS
42 #include <foreign/nvwa/debug_new.h>
43 #endif // CHECK_MEMORY_LEAKS
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
50  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
51 
52 
54 
55 
56 bool
58  std::string tag;
59  tag = myRead(from);
60  if (tag == "nureigenestrecke") {
61  return parseOnlyMe(from);
62  } else if (tag == "ort") {
63  return parsePositionDescribed(from);
64  } else if (tag == "nummer") {
65  return parseNumbered(from);
66  }
68  "NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition: format problem");
69  throw 1;
70 }
71 
72 bool
74  std::string tag;
75  from >> tag;
76  return true;
77 }
78 
79 
80 bool
82  std::string tag = myRead(from);
84 // from >> tag; // "Durch"
85  bool ok = true;
86  do {
87  from >> tag; // "Strecke"
89  //
90  SUMOReal timegap;
91  from >> timegap;
92 
93  from >> tag;
94  SUMOReal waygap;
95  from >> waygap;
96 
97  SUMOReal vmax = -1;
98  tag = readEndSecure(from);
99  if (tag == "vmax") {
100  from >> vmax;
101  }
102  ok = NIVissimDisturbance::dictionary("", edge, by);
103  if (tag != "DATAEND") {
104  tag = readEndSecure(from);
105  }
106  } while (tag != "DATAEND" && ok);
107  return ok;
108 }
109 
110 
111 
112 bool
114  //
115  int id;
116  from >> id;
117  //
118  std::string tag;
119  from >> tag;
120  std::string name = readName(from);
121  // skip optional "Beschriftung"
122  while (tag != "ort") {
123  tag = myRead(from);
124  }
125  //
126  from >> tag; // "Strecke"
127  NIVissimExtendedEdgePoint edge = parsePos(from);
128  bool ok = true;
129  do {
130  from >> tag; // "Ort"
131  from >> tag; // "Strecke"
133  //
134  SUMOReal timegap;
135  from >> timegap;
136 
137  SUMOReal waygap;
138  from >> tag;
139  from >> waygap;
140 
141  SUMOReal vmax = -1;
142  tag = readEndSecure(from);
143  if (tag == "vmax") {
144  from >> vmax;
145  }
146 
147  ok = NIVissimDisturbance::dictionary(name, edge, by);
148  if (tag != "DATAEND") {
149  tag = readEndSecure(from);
150  }
151  } while (tag != "DATAEND" && ok);
152  return ok;
153 }
154 
155 
156 
159  int edgeid;
160  from >> edgeid; // type-checking is missing!
161  //
162  std::string tag;
163  from >> tag;
164  from >> tag;
165  std::vector<int> lanes;
166  if (tag == "ALLE") {
167  //lanes.push_back(1); // !!!
168  } else {
169  lanes.push_back(TplConvert::_2int(tag.c_str()));
170  }
171  //
172  SUMOReal position;
173  from >> tag;
174  from >> position;
175  // assigned vehicle types
176  std::vector<int> types;
177  from >> tag;
178  while (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND" && tag != "alle") {
179  tag = readEndSecure(from);
180  if (tag != "DATAEND") {
181  if (tag == "alle") {
182  types.push_back(-1);
183  from >> tag;
184  tag = "alle";
185  } else if (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND") {
186  int tmp = TplConvert::_2int(tag.c_str());
187  types.push_back(tmp);
188  }
189  }
190  }
191  return NIVissimExtendedEdgePoint(edgeid, lanes, position, types);
192 }
193 
194 
195 
196 /****************************************************************************/
197 
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)
Definition: TplConvert.h:114
#define SUMOReal
Definition: config.h:218