SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Parkplatzdefinition.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 <utility>
35 #include <utils/common/ToString.h>
38 #include <netbuild/NBDistrict.h>
39 #include <netbuild/NBNode.h>
40 #include <netbuild/NBNodeCont.h>
41 #include "../NIImporter_Vissim.h"
42 #include "../tempstructs/NIVissimDistrictConnection.h"
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
50  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
51 
52 
54 
55 
56 bool
58  int id;
59  from >> id;
60 
61  std::string tag;
62  from >> tag;
63  std::string name = readName(from);
64 
65  // parse the districts
66  // and allocate them if not done before
67  // A district may be already saved when another parking place with
68  // the same district was already build.
69  std::vector<int> districts;
70  std::vector<double> percentages;
71  readUntil(from, "bezirke"); // "Bezirke"
72  while (tag != "ort") {
73  double perc = -1;
74  int districtid;
75  from >> districtid;
76  tag = myRead(from);
77  if (tag == "anteil") {
78  from >> perc;
79  }
80  districts.push_back(districtid);
81  percentages.push_back(perc);
82  tag = myRead(from);
83  }
84 
85  from >> tag; // "Strecke"
86  int edgeid;
87  from >> edgeid;
88 
89  double position;
90  from >> tag; // "bei"
91  from >> position;
92 
93  double length;
94  from >> tag;
95  from >> length;
96 
97  from >> tag; // "Kapazitaet"
98  from >> tag; // "Kapazitaet"-value
99 
100  tag = myRead(from);
101  if (tag == "belegung") {
102  from >> tag;
103  tag = myRead(from); // "fahrzeugklasse"
104  }
105 
106  std::vector<std::pair<int, int> > assignedVehicles;
107  while (tag != "default") {
108  int vclass;
109  from >> vclass;
110  from >> tag; // "vwunsch"
111  int vwunsch;
112  from >> vwunsch; // "vwunsch"-value
113  assignedVehicles.push_back(std::pair<int, int>(vclass, vwunsch));
114  tag = myRead(from);
115  }
116 
117  from >> tag;
118  from >> tag;
119 // NIVissimEdge *e = NIVissimEdge::dictionary(edgeid);
120 // e->addReferencedDistrict(id);
121 
122  // build the district connection
124  districts, percentages, edgeid, position, assignedVehicles);
125 }
126 
127 
128 
129 /****************************************************************************/
130 
void readUntil(std::istream &from, const std::string &name)
Reads from the stream until the keywor occurs.
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.
NIVissimSingleTypeParser_Parkplatzdefinition(NIImporter_Vissim &parent)
Constructor.
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.
static bool dictionary(int id, const std::string &name, const std::vector< int > &districts, const std::vector< double > &percentages, int edgeid, double position, const std::vector< std::pair< int, int > > &assignedVehicles)
Inserts the connection into the dictionary after building it.