SUMO - Simulation of Urban MObility
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-2017 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 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
47  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
48 
49 
51 
52 
53 bool
55  //
56  int id;
57  from >> id;
58  //
59  std::string tag, name;
60  tag = myRead(from);
61  if (tag == "name") {
62  name = readName(from);
63  tag = myRead(from);
64  }
65  // skip optional "Beschriftung"
66  tag = overrideOptionalLabel(from, tag);
67  //
68  int lsaid;
69  std::vector<int> groupids;
70  if (tag == "lsa") {
71  int groupid;
72  from >> lsaid; // type-checking is missing!
73  from >> tag; // "Gruppe"
74  do {
75  from >> groupid;
76  groupids.push_back(groupid);
77  tag = myRead(from);
78  } while (tag == "oder");
79  //
80  } else {
81  from >> tag; // strecke
82  WRITE_WARNING("Omitting unknown traffic light.");
83  return true;
84  }
85  if (tag == "typ") {
86  from >> tag; // typ-value
87  from >> tag; // "ort"
88  }
89 
90  //
91  from >> tag;
92  int edgeid;
93  from >> edgeid;
94 
95  from >> tag;
96  int laneno;
97  from >> laneno;
98 
99  from >> tag;
100  double position;
101  from >> position;
102  //
103  while (tag != "fahrzeugklassen") {
104  tag = myRead(from);
105  }
106  std::vector<int> assignedVehicleTypes = parseAssignedVehicleTypes(from, "N/A");
107  //
108  NIVissimTL::dictionary(lsaid); // !!! check whether someting is really done here
110  new NIVissimTL::NIVissimTLSignal(id, name, groupids, edgeid,
111  laneno, position, assignedVehicleTypes);
112  if (!NIVissimTL::NIVissimTLSignal::dictionary(lsaid, id, signal)) {
113  throw 1; // !!!
114  }
115  return true;
116 }
117 
118 
119 
120 /****************************************************************************/
121 
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:88
#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:328
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