SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimSingleTypeParser_Verbindungsdefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 //
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
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/NIVissimConnection.h"
38 
39 #ifdef CHECK_MEMORY_LEAKS
40 #include <foreign/nvwa/debug_new.h>
41 #endif // CHECK_MEMORY_LEAKS
42 
43 
44 // ===========================================================================
45 // method definitions
46 // ===========================================================================
48  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
49 
50 
52 
53 
54 bool
56  int id;
57  from >> id; // type-checking is missing!
58  std::string tag;
59  // Read optional value "Name", skip optional value "Beschriftung"
60  std::string name;
61  while (tag != "von") {
62  tag = overrideOptionalLabel(from);
63  if (tag == "name") {
64  name = readName(from);
65  }
66  }
67  // Read the geometry information
69  PositionVector geom;
70  tag = myRead(from); // "ueber"
71  while (tag != "nach") {
72  std::string x = myRead(from);
73  std::string y = myRead(from);
74  if (y != "nach") {
76  Position(
77  TplConvert::_2SUMOReal(x.c_str()),
78  TplConvert::_2SUMOReal(y.c_str())
79  ));
80  tag = myRead(from);
81  try {
82  TplConvert::_2SUMOReal(tag.c_str());
83  tag = myRead(from);
84  } catch (NumberFormatException&) {}
85  } else {
86  tag = y;
87  }
88  }
90  // read some optional values until mandatory "Fahrzeugklassen" occurs
91  SUMOReal dxnothalt = 0;
92  SUMOReal dxeinordnen = 0;
93  SUMOReal zuschlag1, zuschlag2;
94  zuschlag1 = zuschlag2 = 0;
95  SUMOReal seglength = 0;
96  tag = myRead(from);
98  while (tag != "fahrzeugklassen" && tag != "sperrung" && tag != "auswertung" && tag != "DATAEND") {
99  if (tag == "rechts") {
101  } else if (tag == "links") {
103  } else if (tag == "alle") {
105  } else if (tag == "dxnothalt") {
106  from >> dxnothalt; // type-checking is missing!
107  } else if (tag == "dxeinordnen") {
108  from >> dxeinordnen; // type-checking is missing!
109  } else if (tag == "segment") {
110  from >> tag;
111  from >> seglength;
112  }
113  if (tag == "zuschlag") {
114  from >> zuschlag1; // type-checking is missing!
115  tag = readEndSecure(from);
116  if (tag == "zuschlag") {
117  from >> zuschlag2; // type-checking is missing!
118  tag = readEndSecure(from, "auswertung");
119  }
120  } else {
121  tag = readEndSecure(from, "auswertung");
122  }
123  }
124  // read in allowed vehicle classes
125  std::vector<int> assignedVehicles;
126  if (tag == "fahrzeugklassen") {
127  tag = readEndSecure(from);
128  while (tag != "DATAEND" && tag != "sperrung" && tag != "auswertung") {
129  int classes = TplConvert::_2int(tag.c_str());
130  assignedVehicles.push_back(classes);
131  tag = readEndSecure(from, "auswertung");
132  }
133  }
134  // Read definitions of closed lanes
136  if (tag != "DATAEND") {
137  do {
138  // check whether a next close lane definition can be found
139  tag = readEndSecure(from);
140  if (tag == "keinspurwechsel") {
141  while (tag != "DATAEND") {
142  tag = readEndSecure(from);
143  }
144  } else if (tag == "spur") {
145  // get the lane number
146 // from >> tag;
147  int laneNo;
148  from >> laneNo; // type-checking is missing!
149  // get the list of assigned car classes
150  std::vector<int> assignedVehicles;
151  tag = myRead(from);
152  if (tag == "fahrzeugklassen") {
153  tag = myRead(from);
154  }
155  while (tag != "DATAEND" && tag != "spur" && tag != "keinspurwechsel") {
156  int classes = TplConvert::_2int(tag.c_str());
157  assignedVehicles.push_back(classes);
158  tag = readEndSecure(from);
159  }
160  // build and add the definition
161  NIVissimClosedLaneDef* cld = new NIVissimClosedLaneDef(laneNo, assignedVehicles);
162  clv.push_back(cld);
163  }
164  } while (tag != "DATAEND");
165  }
166  NIVissimConnection* c = new NIVissimConnection(id, name, from_def, to_def, geom,
167  direction, dxnothalt, dxeinordnen, zuschlag1, zuschlag2, seglength,
168  assignedVehicles, clv);
169 
170  if (!NIVissimConnection::dictionary(id, c)) {
171  return false;
172  }
173  return true;
174  //return NIVissimAbstractEdge::dictionary(id, c);
175 }
176 
177 
178 
179 /****************************************************************************/
180