Eclipse 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-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 /****************************************************************************/
15 //
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include <iostream>
25 #include <vector>
26 #include <utility>
28 #include <utils/common/ToString.h>
31 #include <netbuild/NBDistrict.h>
32 #include <netbuild/NBNode.h>
33 #include <netbuild/NBNodeCont.h>
34 #include "../NIImporter_Vissim.h"
35 #include "../tempstructs/NIVissimDistrictConnection.h"
37 
38 
39 // ===========================================================================
40 // method definitions
41 // ===========================================================================
43  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
44 
45 
47 
48 
49 bool
51  int id;
52  from >> id;
53 
54  std::string tag;
55  from >> tag;
56  std::string name = readName(from);
57 
58  // parse the districts
59  // and allocate them if not done before
60  // A district may be already saved when another parking place with
61  // the same district was already build.
62  std::vector<int> districts;
63  std::vector<double> percentages;
64  readUntil(from, "bezirke"); // "Bezirke"
65  while (tag != "ort") {
66  double perc = -1;
67  int districtid;
68  from >> districtid;
69  tag = myRead(from);
70  if (tag == "anteil") {
71  from >> perc;
72  }
73  districts.push_back(districtid);
74  percentages.push_back(perc);
75  tag = myRead(from);
76  }
77 
78  from >> tag; // "Strecke"
79  int edgeid;
80  from >> edgeid;
81 
82  double position;
83  from >> tag; // "bei"
84  from >> position;
85 
86  double length;
87  from >> tag;
88  from >> length;
89 
90  from >> tag; // "Kapazitaet"
91  from >> tag; // "Kapazitaet"-value
92 
93  tag = myRead(from);
94  if (tag == "belegung") {
95  from >> tag;
96  tag = myRead(from); // "fahrzeugklasse"
97  }
98 
99  std::vector<std::pair<int, int> > assignedVehicles;
100  while (tag != "default") {
101  int vclass;
102  from >> vclass;
103  from >> tag; // "vwunsch"
104  int vwunsch;
105  from >> vwunsch; // "vwunsch"-value
106  assignedVehicles.push_back(std::pair<int, int>(vclass, vwunsch));
107  tag = myRead(from);
108  }
109 
110  from >> tag;
111  from >> tag;
112 // NIVissimEdge *e = NIVissimEdge::dictionary(edgeid);
113 // e->addReferencedDistrict(id);
114 
115  // build the district connection
117  districts, percentages, edgeid, position, assignedVehicles);
118 }
119 
120 
121 
122 /****************************************************************************/
123 
ToString.h
NIVissimSingleTypeParser_Parkplatzdefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Parkplatzdefinition.cpp:50
NIVissimSingleTypeParser_Parkplatzdefinition::NIVissimSingleTypeParser_Parkplatzdefinition
NIVissimSingleTypeParser_Parkplatzdefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Parkplatzdefinition.cpp:42
NIImporter_Vissim::VissimSingleTypeParser::readName
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
Definition: NIImporter_Vissim.cpp:797
NIImporter_Vissim
Importer for networks stored in Vissim format.
Definition: NIImporter_Vissim.h:58
NIVissimDistrictConnection::dictionary
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.
Definition: NIVissimDistrictConnection.cpp:81
NBDistrict.h
NIVissimSingleTypeParser_Parkplatzdefinition.h
VectorHelper.h
NBNodeCont.h
StringUtils.h
NIImporter_Vissim::VissimSingleTypeParser::readUntil
void readUntil(std::istream &from, const std::string &name)
Reads from the stream until the keywor occurs.
Definition: NIImporter_Vissim.cpp:813
NBDistrictCont.h
config.h
NIVissimSingleTypeParser_Parkplatzdefinition::~NIVissimSingleTypeParser_Parkplatzdefinition
~NIVissimSingleTypeParser_Parkplatzdefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Parkplatzdefinition.cpp:46
NIImporter_Vissim::VissimSingleTypeParser::myRead
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
Definition: NIImporter_Vissim.cpp:670
NBNode.h