Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 //
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <iostream>
26 #include <vector>
27 #include <cassert>
29 #include "../NIImporter_Vissim.h"
30 #include "../tempstructs/NIVissimEdge.h"
31 #include "../tempstructs/NIVissimConnection.h"
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
39  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
40 
41 
43 
44 
45 bool
47  std::string tag;
48  from >> tag; // id
49  from >> tag; // name
50  tag = readName(from);
51  tag = overrideOptionalLabel(from);
52  from >> tag; // strecke
53  std::string edgeid;
54  from >> edgeid;
55  from >> tag; // spur
56  std::string lane;
57  from >> lane;
58  from >> tag; // bei
59  std::string pos;
60  from >> pos;
61  from >> tag; // fahrzeugklasse
62  from >> tag; // <fahrzeugklasse>
63  from >> tag; // vwunsch
64  std::string vwunsch;
65  from >> vwunsch; // vwunsch
66  std::vector<std::string> tmp;
67  tmp.push_back("zeit");
68  tmp.push_back("fahrzeugklasse");
69  tag = readEndSecure(from, tmp);
70  while (tag != "DATAEND" && tag != "zeit") {
71  from >> tag;
72  from >> tag;
73  from >> tag;
74  tag = myRead(from);
75  }
76  if (tag == "zeit") {
77  from >> tag;
78  from >> tag;
79  from >> tag;
80  from >> tag;
81  }
82  int numid = StringUtils::toInt(edgeid);
83  int numlane = StringUtils::toInt(lane) - 1;
84  int numv = StringUtils::toInt(vwunsch);
86  if (e == nullptr) {
88  const std::vector<int>& lanes = c->getToLanes();
90  for (std::vector<int>::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
91  e->setSpeed((*j), numv);
92  }
93  assert(e != 0);
94  } else {
95  e->setSpeed(numlane, numv);
96  }
97  return true;
98 }
99 
100 
101 
102 /****************************************************************************/
103 
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:53
void setSpeed(int lane, int speedDist)
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
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...
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 ...