SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Signalgeberdefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <cassert>
32 #include <iostream>
34 #include <utils/common/ToString.h>
37 #include "../NIImporter_Vissim.h"
38 #include "../tempstructs/NIVissimTL.h"
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
46  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
47 
48 
50 
51 
52 bool
54  //
55  int id;
56  from >> id;
57  //
58  std::string tag, name;
59  tag = myRead(from);
60  if (tag == "name") {
61  name = readName(from);
62  tag = myRead(from);
63  }
64  // skip optional "Beschriftung"
65  tag = overrideOptionalLabel(from, tag);
66  //
67  int lsaid;
68  std::vector<int> groupids;
69  if (tag == "lsa") {
70  int groupid;
71  from >> lsaid; // type-checking is missing!
72  from >> tag; // "Gruppe"
73  do {
74  from >> groupid;
75  groupids.push_back(groupid);
76  tag = myRead(from);
77  } while (tag == "oder");
78  //
79  } else {
80  from >> tag; // strecke
81  WRITE_WARNING("Omitting unknown traffic light.");
82  return true;
83  }
84  if (tag == "typ") {
85  from >> tag; // typ-value
86  from >> tag; // "ort"
87  }
88 
89  //
90  from >> tag;
91  int edgeid;
92  from >> edgeid;
93 
94  from >> tag;
95  int laneno;
96  from >> laneno;
97 
98  from >> tag;
99  double position;
100  from >> position;
101  //
102  while (tag != "fahrzeugklassen") {
103  tag = myRead(from);
104  }
105  std::vector<int> assignedVehicleTypes = parseAssignedVehicleTypes(from, "N/A");
106  //
107  NIVissimTL::dictionary(lsaid); // !!! check whether someting is really done here
109  new NIVissimTL::NIVissimTLSignal(id, name, groupids, edgeid,
110  laneno, position, assignedVehicleTypes);
111  if (!NIVissimTL::NIVissimTLSignal::dictionary(lsaid, id, signal)) {
112  throw 1; // !!!
113  }
114  return true;
115 }
116 
117 
118 
119 /****************************************************************************/
120 
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:87
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
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:327
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...
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