SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NIVissimSingleTypeParser_Signalgeberdefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 //
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2016 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 <cassert>
33 #include <iostream>
35 #include <utils/common/ToString.h>
38 #include "../NIImporter_Vissim.h"
39 #include "../tempstructs/NIVissimTL.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  //
60  int id;
61  from >> id;
62  //
63  std::string tag, name;
64  tag = myRead(from);
65  if (tag == "name") {
66  name = readName(from);
67  tag = myRead(from);
68  }
69  // skip optional "Beschriftung"
70  tag = overrideOptionalLabel(from, tag);
71  //
72  int lsaid;
73  std::vector<int> groupids;
74  if (tag == "lsa") {
75  int groupid;
76  from >> lsaid; // type-checking is missing!
77  from >> tag; // "Gruppe"
78  do {
79  from >> groupid;
80  groupids.push_back(groupid);
81  tag = myRead(from);
82  } while (tag == "oder");
83  //
84  } else {
85  from >> tag; // strecke
86  WRITE_WARNING("Omitting unknown traffic light.");
87  return true;
88  }
89  if (tag == "typ") {
90  from >> tag; // typ-value
91  from >> tag; // "ort"
92  }
93 
94  //
95  from >> tag;
96  int edgeid;
97  from >> edgeid;
98 
99  from >> tag;
100  int laneno;
101  from >> laneno;
102 
103  from >> tag;
104  SUMOReal position;
105  from >> position;
106  //
107  while (tag != "fahrzeugklassen") {
108  tag = myRead(from);
109  }
110  std::vector<int> assignedVehicleTypes = parseAssignedVehicleTypes(from, "N/A");
111  //
112  NIVissimTL::dictionary(lsaid); // !!! check whether someting is really done here
114  new NIVissimTL::NIVissimTLSignal(id, name, groupids, edgeid,
115  laneno, position, assignedVehicleTypes);
116  if (!NIVissimTL::NIVissimTLSignal::dictionary(lsaid, id, signal)) {
117  throw 1; // !!!
118  }
119  return true;
120 }
121 
122 
123 
124 /****************************************************************************/
125 
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
Importer for networks stored in Vissim format.
static bool dictionary(int lsaid, int id, NIVissimTLSignal *o)
Definition: NIVissimTL.cpp:92
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
NIVissimSingleTypeParser_Signalgeberdefinition(NIImporter_Vissim &parent)
Constructor.
static bool dictionary(int id, const std::string &type, const std::string &name, SUMOTime absdur, SUMOTime offset)
Definition: NIVissimTL.cpp:332
bool parse(std::istream &from)
Parses the data type from the given stream.
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 SUMOReal
Definition: config.h:214
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure ...
std::vector< int > parseAssignedVehicleTypes(std::istream &from, const std::string &next)
parses a listof vehicle types assigned to the current data field One should remeber, that -1 means "all" vehicle types