SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_VWunschentscheidungsdefinition.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 <iostream>
33 #include <vector>
34 #include <cassert>
36 #include "../NIImporter_Vissim.h"
37 #include "../tempstructs/NIVissimEdge.h"
38 #include "../tempstructs/NIVissimConnection.h"
40 
41 #ifdef CHECK_MEMORY_LEAKS
42 #include <foreign/nvwa/debug_new.h>
43 #endif // CHECK_MEMORY_LEAKS
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
50  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
51 
52 
54 
55 
56 bool
58  std::string tag;
59  from >> tag; // id
60  from >> tag; // name
61  tag = readName(from);
62  tag = overrideOptionalLabel(from);
63  from >> tag; // strecke
64  std::string edgeid;
65  from >> edgeid;
66  from >> tag; // spur
67  std::string lane;
68  from >> lane;
69  from >> tag; // bei
70  std::string pos;
71  from >> pos;
72  from >> tag; // fahrzeugklasse
73  from >> tag; // <fahrzeugklasse>
74  from >> tag; // vwunsch
75  std::string vwunsch;
76  from >> vwunsch; // vwunsch
77  std::vector<std::string> tmp;
78  tmp.push_back("zeit");
79  tmp.push_back("fahrzeugklasse");
80  tag = readEndSecure(from, tmp);
81  while (tag != "DATAEND" && tag != "zeit") {
82  from >> tag;
83  from >> tag;
84  from >> tag;
85  tag = myRead(from);
86  }
87  if (tag == "zeit") {
88  from >> tag;
89  from >> tag;
90  from >> tag;
91  from >> tag;
92  }
93  int numid = TplConvert::_2int(edgeid.c_str());
94  int numlane = TplConvert::_2int(lane.c_str()) - 1;
95  int numv = TplConvert::_2int(vwunsch.c_str());
97  if (e == 0) {
99  const std::vector<int>& lanes = c->getToLanes();
101  for (std::vector<int>::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
102  e->setSpeed((*j), numv);
103  }
104  assert(e != 0);
105  } else {
106  e->setSpeed(numlane, numv);
107  }
108  return true;
109 }
110 
111 
112 
113 /****************************************************************************/
114 
const std::vector< int > & getToLanes() const
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
Importer for networks stored in Vissim format.
static bool dictionary(int id, NIVissimConnection *o)
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:61
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
Definition: TplConvert.h:149
bool parse(std::istream &from)
Parses the data type from the given stream.
static bool dictionary(int id, const std::string &name, const std::string &type, int noLanes, SUMOReal zuschlag1, SUMOReal zuschlag2, SUMOReal length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Adds the described item to the dictionary Builds the edge first.
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure ...