SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_VWunschentscheidungsdefinition.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 <iostream>
32 #include <vector>
33 #include <cassert>
35 #include "../NIImporter_Vissim.h"
36 #include "../tempstructs/NIVissimEdge.h"
37 #include "../tempstructs/NIVissimConnection.h"
39 
40 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
45  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
46 
47 
49 
50 
51 bool
53  std::string tag;
54  from >> tag; // id
55  from >> tag; // name
56  tag = readName(from);
57  tag = overrideOptionalLabel(from);
58  from >> tag; // strecke
59  std::string edgeid;
60  from >> edgeid;
61  from >> tag; // spur
62  std::string lane;
63  from >> lane;
64  from >> tag; // bei
65  std::string pos;
66  from >> pos;
67  from >> tag; // fahrzeugklasse
68  from >> tag; // <fahrzeugklasse>
69  from >> tag; // vwunsch
70  std::string vwunsch;
71  from >> vwunsch; // vwunsch
72  std::vector<std::string> tmp;
73  tmp.push_back("zeit");
74  tmp.push_back("fahrzeugklasse");
75  tag = readEndSecure(from, tmp);
76  while (tag != "DATAEND" && tag != "zeit") {
77  from >> tag;
78  from >> tag;
79  from >> tag;
80  tag = myRead(from);
81  }
82  if (tag == "zeit") {
83  from >> tag;
84  from >> tag;
85  from >> tag;
86  from >> tag;
87  }
88  int numid = TplConvert::_2int(edgeid.c_str());
89  int numlane = TplConvert::_2int(lane.c_str()) - 1;
90  int numv = TplConvert::_2int(vwunsch.c_str());
92  if (e == 0) {
94  const std::vector<int>& lanes = c->getToLanes();
96  for (std::vector<int>::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
97  e->setSpeed((*j), numv);
98  }
99  assert(e != 0);
100  } else {
101  e->setSpeed(numlane, numv);
102  }
103  return true;
104 }
105 
106 
107 
108 /****************************************************************************/
109 
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:59
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:155
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 ...