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-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 <iostream>
33 #include <vector>
34 #include <cassert>
36 #include "../NIImporter_Vissim.h"
37 #include "../tempstructs/NIVissimEdge.h"
38 #include "../tempstructs/NIVissimConnection.h"
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
46  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
47 
48 
50 
51 
52 bool
54  std::string tag;
55  from >> tag; // id
56  from >> tag; // name
57  tag = readName(from);
58  tag = overrideOptionalLabel(from);
59  from >> tag; // strecke
60  std::string edgeid;
61  from >> edgeid;
62  from >> tag; // spur
63  std::string lane;
64  from >> lane;
65  from >> tag; // bei
66  std::string pos;
67  from >> pos;
68  from >> tag; // fahrzeugklasse
69  from >> tag; // <fahrzeugklasse>
70  from >> tag; // vwunsch
71  std::string vwunsch;
72  from >> vwunsch; // vwunsch
73  std::vector<std::string> tmp;
74  tmp.push_back("zeit");
75  tmp.push_back("fahrzeugklasse");
76  tag = readEndSecure(from, tmp);
77  while (tag != "DATAEND" && tag != "zeit") {
78  from >> tag;
79  from >> tag;
80  from >> tag;
81  tag = myRead(from);
82  }
83  if (tag == "zeit") {
84  from >> tag;
85  from >> tag;
86  from >> tag;
87  from >> tag;
88  }
89  int numid = TplConvert::_2int(edgeid.c_str());
90  int numlane = TplConvert::_2int(lane.c_str()) - 1;
91  int numv = TplConvert::_2int(vwunsch.c_str());
93  if (e == 0) {
95  const std::vector<int>& lanes = c->getToLanes();
97  for (std::vector<int>::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
98  e->setSpeed((*j), numv);
99  }
100  assert(e != 0);
101  } else {
102  e->setSpeed(numlane, numv);
103  }
104  return true;
105 }
106 
107 
108 
109 /****************************************************************************/
110 
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.
const std::vector< int > & getToLanes() const
static bool dictionary(int id, NIVissimConnection *o)
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:60
static bool dictionary(int id, const std::string &name, const std::string &type, int noLanes, double zuschlag1, double zuschlag2, double length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Adds the described item to the dictionary Builds the edge first.
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.
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure ...