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