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-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19//
20/****************************************************************************/
21#include <config.h>
22
23#include <iostream>
24#include <vector>
25#include <utility>
30#include <netbuild/NBDistrict.h>
31#include <netbuild/NBNode.h>
32#include <netbuild/NBNodeCont.h>
36
37
38// ===========================================================================
39// method definitions
40// ===========================================================================
42 : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
43
44
46
47
48bool
50 int id;
51 from >> id;
52
53 std::string tag;
54 from >> tag;
55 std::string name = readName(from);
56
57 // parse the districts
58 // and allocate them if not done before
59 // A district may be already saved when another parking place with
60 // the same district was already build.
61 std::vector<int> districts;
62 std::vector<double> percentages;
63 readUntil(from, "bezirke"); // "Bezirke"
64 while (tag != "ort") {
65 double perc = -1;
66 int districtid;
67 from >> districtid;
68 tag = myRead(from);
69 if (tag == "anteil") {
70 from >> perc;
71 }
72 districts.push_back(districtid);
73 percentages.push_back(perc);
74 tag = myRead(from);
75 }
76
77 from >> tag; // "Strecke"
78 int edgeid;
79 from >> edgeid;
80
81 double position;
82 from >> tag; // "bei"
83 from >> position;
84
85 double length;
86 from >> tag;
87 from >> length;
88
89 from >> tag; // "Kapazitaet"
90 from >> tag; // "Kapazitaet"-value
91
92 tag = myRead(from);
93 if (tag == "belegung") {
94 from >> tag;
95 tag = myRead(from); // "fahrzeugklasse"
96 }
97
98 std::vector<std::pair<int, int> > assignedVehicles;
99 while (tag != "default") {
100 int vclass;
101 from >> vclass;
102 from >> tag; // "vwunsch"
103 int vwunsch;
104 from >> vwunsch; // "vwunsch"-value
105 assignedVehicles.push_back(std::pair<int, int>(vclass, vwunsch));
106 tag = myRead(from);
107 }
108
109 from >> tag;
110 from >> tag;
111// NIVissimEdge *e = NIVissimEdge::dictionary(edgeid);
112// e->addReferencedDistrict(id);
113
114 // build the district connection
116 districts, percentages, edgeid, position, assignedVehicles);
117}
118
119
120/****************************************************************************/
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
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.
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.
bool parse(std::istream &from)
Parses the data type from the given stream.
NIVissimSingleTypeParser_Parkplatzdefinition(NIImporter_Vissim &parent)
Constructor.