SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
//
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
22
23
24
// ===========================================================================
25
// included modules
26
// ===========================================================================
27
#ifdef _MSC_VER
28
#include <
windows_config.h
>
29
#else
30
#include <
config.h
>
31
#endif
32
33
#include <iostream>
34
#include <
utils/common/TplConvert.h
>
35
#include <
utils/common/MsgHandler.h
>
36
#include "../NIImporter_Vissim.h"
37
#include "../tempstructs/NIVissimExtendedEdgePoint.h"
38
#include "../tempstructs/NIVissimDisturbance.h"
39
#include "
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.h
"
40
41
#ifdef CHECK_MEMORY_LEAKS
42
#include <
foreign/nvwa/debug_new.h
>
43
#endif // CHECK_MEMORY_LEAKS
44
45
46
// ===========================================================================
47
// method definitions
48
// ===========================================================================
49
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition
(
NIImporter_Vissim
& parent)
50
:
NIImporter_Vissim
::VissimSingleTypeParser(parent) {}
51
52
53
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::~NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition
() {}
54
55
56
bool
57
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parse
(std::istream& from) {
58
std::string tag;
59
tag =
myRead
(from);
60
if
(tag ==
"nureigenestrecke"
) {
61
return
parseOnlyMe
(from);
62
}
else
if
(tag ==
"ort"
) {
63
return
parsePositionDescribed
(from);
64
}
else
if
(tag ==
"nummer"
) {
65
return
parseNumbered
(from);
66
}
67
WRITE_ERROR
(
68
"NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition: format problem"
);
69
throw
1;
70
}
71
72
bool
73
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseOnlyMe
(std::istream& from) {
74
std::string tag;
75
from >> tag;
76
return
true
;
77
}
78
79
80
bool
81
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePositionDescribed
(std::istream& from) {
82
std::string tag =
myRead
(from);
83
NIVissimExtendedEdgePoint
edge =
parsePos
(from);
84
// from >> tag; // "Durch"
85
bool
ok =
true
;
86
do
{
87
from >> tag;
// "Strecke"
88
NIVissimExtendedEdgePoint
by =
parsePos
(from);
89
//
90
SUMOReal
timegap;
91
from >> timegap;
92
93
from >> tag;
94
SUMOReal
waygap;
95
from >> waygap;
96
97
SUMOReal
vmax = -1;
98
tag =
readEndSecure
(from);
99
if
(tag ==
"vmax"
) {
100
from >> vmax;
101
}
102
ok =
NIVissimDisturbance::dictionary
(-1,
""
, edge, by,
103
timegap, waygap, vmax);
104
if
(tag !=
"DATAEND"
) {
105
tag =
readEndSecure
(from);
106
}
107
}
while
(tag !=
"DATAEND"
&& ok);
108
return
ok;
109
}
110
111
112
113
bool
114
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseNumbered
(std::istream& from) {
115
//
116
int
id;
117
from >> id;
118
//
119
std::string tag;
120
from >> tag;
121
std::string name =
readName
(from);
122
// skip optional "Beschriftung"
123
while
(tag !=
"ort"
) {
124
tag =
myRead
(from);
125
}
126
//
127
from >> tag;
// "Strecke"
128
NIVissimExtendedEdgePoint
edge =
parsePos
(from);
129
bool
ok =
true
;
130
do
{
131
from >> tag;
// "Ort"
132
from >> tag;
// "Strecke"
133
NIVissimExtendedEdgePoint
by =
parsePos
(from);
134
//
135
SUMOReal
timegap;
136
from >> timegap;
137
138
SUMOReal
waygap;
139
from >> tag;
140
from >> waygap;
141
142
SUMOReal
vmax = -1;
143
tag =
readEndSecure
(from);
144
if
(tag ==
"vmax"
) {
145
from >> vmax;
146
}
147
148
ok =
NIVissimDisturbance::dictionary
(
id
, name, edge, by,
149
timegap, waygap, vmax);
150
if
(tag !=
"DATAEND"
) {
151
tag =
readEndSecure
(from);
152
}
153
}
while
(tag !=
"DATAEND"
&& ok);
154
return
ok;
155
}
156
157
158
159
NIVissimExtendedEdgePoint
160
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePos
(std::istream& from) {
161
int
edgeid;
162
from >> edgeid;
// type-checking is missing!
163
//
164
std::string tag;
165
from >> tag;
166
from >> tag;
167
std::vector<int> lanes;
168
if
(tag ==
"ALLE"
) {
169
//lanes.push_back(1); // !!!
170
}
else
{
171
lanes.push_back(
TplConvert<char>::_2int
(tag.c_str()));
172
}
173
//
174
SUMOReal
position;
175
from >> tag;
176
from >> position;
177
// assigned vehicle types
178
std::vector<int> types;
179
from >> tag;
180
while
(tag !=
"zeitluecke"
&& tag !=
"durch"
&& tag !=
"DATAEND"
&& tag !=
"alle"
) {
181
tag =
readEndSecure
(from);
182
if
(tag !=
"DATAEND"
) {
183
if
(tag ==
"alle"
) {
184
types.push_back(-1);
185
from >> tag;
186
tag =
"alle"
;
187
}
else
if
(tag !=
"zeitluecke"
&& tag !=
"durch"
&& tag !=
"DATAEND"
) {
188
int
tmp =
TplConvert<char>::_2int
(tag.c_str());
189
types.push_back(tmp);
190
}
191
}
192
}
193
return
NIVissimExtendedEdgePoint
(edgeid, lanes, position, types);
194
}
195
196
197
198
/****************************************************************************/
199
build
buildd
sumo-0.15.0~dfsg
src
netimport
vissim
typeloader
NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp
Generated on Wed Jul 18 2012 22:58:35 for SUMO - Simulation of Urban MObility by
1.8.1.1