Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NIVissimSingleTypeParser_Verbindungsdefinition.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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>
29
30
31// ===========================================================================
32// method definitions
33// ===========================================================================
36
37
39
40
41bool
43 int id;
44 from >> id; // type-checking is missing!
45 std::string tag;
46 // Read optional value "Name", skip optional value "Beschriftung"
47 std::string name;
48 while (tag != "von") {
49 tag = overrideOptionalLabel(from);
50 if (tag == "name") {
51 name = readName(from);
52 }
53 }
54 // Read the geometry information
56 PositionVector geom;
57 tag = myRead(from); // "ueber"
58 while (tag != "nach") {
59 std::string x = myRead(from);
60 std::string y = myRead(from);
61 if (y != "nach") {
66 ));
67 tag = myRead(from);
68 try {
70 tag = myRead(from);
71 } catch (NumberFormatException&) {}
72 } else {
73 tag = y;
74 }
75 }
77 // read some optional values until mandatory "Fahrzeugklassen" occurs
78 double dxnothalt = 0;
79 double dxeinordnen = 0;
80 double zuschlag1, zuschlag2;
81 zuschlag1 = zuschlag2 = 0;
82 double seglength = 0;
83 tag = myRead(from);
84// NIVissimConnection::Direction direction = NIVissimConnection::NIVC_DIR_ALL;
85 while (tag != "fahrzeugklassen" && tag != "sperrung" && tag != "auswertung" && tag != "DATAEND") {
86 if (tag == "rechts") {
87// direction = NIVissimConnection::NIVC_DIR_RIGHT;
88 } else if (tag == "links") {
89// direction = NIVissimConnection::NIVC_DIR_LEFT;
90 } else if (tag == "alle") {
91// direction = NIVissimConnection::NIVC_DIR_ALL;
92 } else if (tag == "dxnothalt") {
93 from >> dxnothalt; // type-checking is missing!
94 } else if (tag == "dxeinordnen") {
95 from >> dxeinordnen; // type-checking is missing!
96 } else if (tag == "segment") {
97 from >> tag;
98 from >> seglength;
99 }
100 if (tag == "zuschlag") {
101 from >> zuschlag1; // type-checking is missing!
102 tag = readEndSecure(from);
103 if (tag == "zuschlag") {
104 from >> zuschlag2; // type-checking is missing!
105 tag = readEndSecure(from, "auswertung");
106 }
107 } else {
108 tag = readEndSecure(from, "auswertung");
109 }
110 }
111 // read in allowed vehicle classes
112 std::vector<int> assignedVehicles;
113 if (tag == "fahrzeugklassen") {
114 tag = readEndSecure(from);
115 while (tag != "DATAEND" && tag != "sperrung" && tag != "auswertung") {
116 int classes = StringUtils::toInt(tag);
117 assignedVehicles.push_back(classes);
118 tag = readEndSecure(from, "auswertung");
119 }
120 }
121 // Read definitions of closed lanes
123 if (tag != "DATAEND") {
124 do {
125 // check whether a next close lane definition can be found
126 tag = readEndSecure(from);
127 if (tag == "keinspurwechsel") {
128 while (tag != "DATAEND") {
129 tag = readEndSecure(from);
130 }
131 } else if (tag == "spur") {
132 // get the lane number
133// from >> tag;
134 int laneNo;
135 from >> laneNo; // unused and type-checking is missing!
136 // get the list of assigned car classes
137 std::vector<int> assigned;
138 tag = myRead(from);
139 if (tag == "fahrzeugklassen") {
140 tag = myRead(from);
141 }
142 while (tag != "DATAEND" && tag != "spur" && tag != "keinspurwechsel") {
143 int classes = StringUtils::toInt(tag);
144 assigned.push_back(classes);
145 tag = readEndSecure(from);
146 }
147 // build and add the definition
148 NIVissimClosedLaneDef* cld = new NIVissimClosedLaneDef(assigned);
149 clv.push_back(cld);
150 }
151 } while (tag != "DATAEND");
152 }
153 NIVissimConnection* c = new NIVissimConnection(id, name, from_def, to_def, geom,
154 assignedVehicles, clv);
155
156 if (!NIVissimConnection::dictionary(id, c)) {
157 return false;
158 }
159 return true;
160 //return NIVissimAbstractEdge::dictionary(id, c);
161}
162
163
164/****************************************************************************/
std::vector< NIVissimClosedLaneDef * > NIVissimClosedLanesVector
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream &from)
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure
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, NIVissimConnection *o)
bool parse(std::istream &from)
Parses the data type from the given stream.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
void push_back_noDoublePos(const Position &p)
insert in back a non double position
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...