SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimSingleTypeParser_Streckendefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 //
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11 // Copyright (C) 2001-2012 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>
36 #include "../NIImporter_Vissim.h"
37 #include "../tempstructs/NIVissimEdge.h"
38 #include "../tempstructs/NIVissimClosedLaneDef.h"
39 #include "../tempstructs/NIVissimClosedLanesVector.h"
41 
42 #ifdef CHECK_MEMORY_LEAKS
43 #include <foreign/nvwa/debug_new.h>
44 #endif // CHECK_MEMORY_LEAKS
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
51  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
52 
53 
55 
56 
57 bool
59  // read in the id
60  int id;
61  from >> id;
62  //
63  std::string tag;
64  // the following elements may occure: "Name", "Beschriftung", "Typ",
65  // followed by the mandatory "Laenge"
66  std::string name, label, type;
67  SUMOReal length = -1;
68  while (length < 0) {
69  tag = overrideOptionalLabel(from);
70  if (tag == "name") {
71  name = readName(from);
72  } else if (tag == "typ") {
73  type = myRead(from);
74  } else if (tag == "laenge") {
75  from >> length; // type-checking is missing!
76  }
77  }
78  // read in the number of lanes
79  int noLanes;
80  tag = myRead(from);
81  from >> noLanes;
82  // skip some parameter, except optional "Zuschlag" until "Von" (mandatory)
83  // occurs
84  SUMOReal zuschlag1, zuschlag2;
85  zuschlag1 = zuschlag2 = 0;
86  while (tag != "von") {
87  tag = myRead(from);
88  if (tag == "zuschlag") {
89  from >> zuschlag1; // type-checking is missing!
90  tag = myRead(from);
91  if (tag == "zuschlag") {
92  from >> zuschlag2; // type-checking is missing!
93  }
94  }
95  }
96  // Read the geometry information
97  PositionVector geom;
98  while (tag != "nach") {
100  tag = myRead(from);
101  try {
102  TplConvert<char>::_2SUMOReal(tag.c_str());
103  tag = myRead(from);
104  } catch (NumberFormatException&) {}
105  }
107  // Read definitions of closed lanes
109  // check whether a next close lane definition can be found
110  tag = readEndSecure(from);
111  while (tag != "DATAEND") {
112  if (tag == "keinspurwechsel") {
113  while (tag != "DATAEND") {
114  tag = readEndSecure(from);
115  }
116  } else if (tag == "spur") {
117  // get the lane number
118  int laneNo;
119  from >> laneNo; // type-checking is missing!
120  // get the list of assigned car classes
121  std::vector<int> assignedVehicles;
122  tag = myRead(from);
123  tag = myRead(from);
124  while (tag != "DATAEND" && tag != "spur" && tag != "keinspurwechsel") {
125  int classes = TplConvert<char>::_2int(tag.c_str());
126  assignedVehicles.push_back(classes);
127  tag = readEndSecure(from);
128  }
129  // build and add the definition
130  NIVissimClosedLaneDef* cld = new NIVissimClosedLaneDef(laneNo, assignedVehicles);
131  clv.push_back(cld);
132  } else {
133  tag = readEndSecure(from);
134  }
135  }
136  NIVissimEdge* e = new NIVissimEdge(id, name, type, noLanes,
137  zuschlag1, zuschlag2, length, geom, clv);
138  if (!NIVissimEdge::dictionary(id, e)) {
139  return false;
140  }
141  return true;
142  //return NIVissimAbstractEdge::dictionary(id, e);
143 }
144 
145 
146 
147 /****************************************************************************/
148