SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 //
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 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(-1, "", edge, by,
103  timegap, waygap, vmax);
104  if (tag != "DATAEND") {
105  tag = readEndSecure(from);
106  }
107  } while (tag != "DATAEND" && ok);
108  return ok;
109 }
110 
111 
112 
113 bool
115  //
116  int id;
117  from >> id;
118  //
119  std::string tag;
120  from >> tag;
121  std::string name = readName(from);
122  // skip optional "Beschriftung"
123  while (tag != "ort") {
124  tag = myRead(from);
125  }
126  //
127  from >> tag; // "Strecke"
128  NIVissimExtendedEdgePoint edge = parsePos(from);
129  bool ok = true;
130  do {
131  from >> tag; // "Ort"
132  from >> tag; // "Strecke"
134  //
135  SUMOReal timegap;
136  from >> timegap;
137 
138  SUMOReal waygap;
139  from >> tag;
140  from >> waygap;
141 
142  SUMOReal vmax = -1;
143  tag = readEndSecure(from);
144  if (tag == "vmax") {
145  from >> vmax;
146  }
147 
148  ok = NIVissimDisturbance::dictionary(id, name, edge, by,
149  timegap, waygap, vmax);
150  if (tag != "DATAEND") {
151  tag = readEndSecure(from);
152  }
153  } while (tag != "DATAEND" && ok);
154  return ok;
155 }
156 
157 
158 
161  int edgeid;
162  from >> edgeid; // type-checking is missing!
163  //
164  std::string tag;
165  from >> tag;
166  from >> tag;
167  std::vector<int> lanes;
168  if (tag == "ALLE") {
169  //lanes.push_back(1); // !!!
170  } else {
171  lanes.push_back(TplConvert::_2int(tag.c_str()));
172  }
173  //
174  SUMOReal position;
175  from >> tag;
176  from >> position;
177  // assigned vehicle types
178  std::vector<int> types;
179  from >> tag;
180  while (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND" && tag != "alle") {
181  tag = readEndSecure(from);
182  if (tag != "DATAEND") {
183  if (tag == "alle") {
184  types.push_back(-1);
185  from >> tag;
186  tag = "alle";
187  } else if (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND") {
188  int tmp = TplConvert::_2int(tag.c_str());
189  types.push_back(tmp);
190  }
191  }
192  }
193  return NIVissimExtendedEdgePoint(edgeid, lanes, position, types);
194 }
195 
196 
197 
198 /****************************************************************************/
199 
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.
bool parsePositionDescribed(std::istream &from)
parses a disturbance described by its position
static bool dictionary(int id, const std::string &name, const NIVissimExtendedEdgePoint &edge, const NIVissimExtendedEdgePoint &by, SUMOReal timegap, SUMOReal waygap, SUMOReal vmax)
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:215