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
NLEdgeControlBuilder.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// Interface for building edges
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2001-2014 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 <vector>
34
#include <string>
35
#include <map>
36
#include <algorithm>
37
#include <iterator>
38
#include <
microsim/MSLane.h
>
39
#include <
microsim/MSEdge.h
>
40
#include <
microsim/MSEdgeControl.h
>
41
#include <
utils/common/StringTokenizer.h
>
42
#include <
utils/common/UtilExceptions.h
>
43
#include "
NLBuilder.h
"
44
#include "
NLEdgeControlBuilder.h
"
45
#include <
utils/options/OptionsCont.h
>
46
#include <
utils/iodevices/OutputDevice.h
>
47
48
#ifdef HAVE_INTERNAL
49
#include <mesosim/MELoop.h>
50
#endif
51
52
#ifdef CHECK_MEMORY_LEAKS
53
#include <
foreign/nvwa/debug_new.h
>
54
#endif // CHECK_MEMORY_LEAKS
55
56
57
// ===========================================================================
58
// method definitions
59
// ===========================================================================
60
NLEdgeControlBuilder::NLEdgeControlBuilder
()
61
: myCurrentNumericalLaneID(0), myCurrentNumericalEdgeID(0), myEdges(0) {
62
myActiveEdge
= (
MSEdge
*) 0;
63
myLaneStorage
=
new
std::vector<MSLane*>();
64
}
65
66
67
NLEdgeControlBuilder::~NLEdgeControlBuilder
() {
68
delete
myLaneStorage
;
69
}
70
71
72
void
73
NLEdgeControlBuilder::beginEdgeParsing
(
74
const
std::string&
id
,
const
MSEdge::EdgeBasicFunction
function
,
75
const
std::string& streetName,
76
const
std::string& edgeType) {
77
myActiveEdge
=
buildEdge
(
id
,
function
, streetName, edgeType);
78
if
(
MSEdge::dictionary
(
id
) != 0) {
79
throw
InvalidArgument
(
"Another edge with the id '"
+
id
+
"' exists."
);
80
}
81
myEdges
.push_back(
myActiveEdge
);
82
}
83
84
85
MSLane
*
86
NLEdgeControlBuilder::addLane
(
const
std::string&
id
,
87
SUMOReal
maxSpeed,
SUMOReal
length,
88
const
PositionVector
& shape,
SUMOReal
width,
89
SVCPermissions
permissions) {
90
MSLane
* lane =
new
MSLane
(
id
, maxSpeed, length,
myActiveEdge
,
myCurrentNumericalLaneID
++, shape, width, permissions);
91
myLaneStorage
->push_back(lane);
92
return
lane;
93
}
94
95
96
MSEdge
*
97
NLEdgeControlBuilder::closeEdge
() {
98
std::vector<MSLane*>* lanes =
new
std::vector<MSLane*>();
99
lanes->reserve(
myLaneStorage
->size());
100
copy(
myLaneStorage
->begin(),
myLaneStorage
->end(), back_inserter(*lanes));
101
myLaneStorage
->clear();
102
myActiveEdge
->
initialize
(lanes);
103
return
myActiveEdge
;
104
}
105
106
107
MSEdgeControl
*
108
NLEdgeControlBuilder::build
() {
109
for
(EdgeCont::iterator i1 =
myEdges
.begin(); i1 !=
myEdges
.end(); i1++) {
110
(*i1)->closeBuilding();
111
#ifdef HAVE_INTERNAL
112
if
(
MSGlobals::gUseMesoSim
) {
113
MSGlobals::gMesoNet->buildSegmentsFor(**i1,
OptionsCont::getOptions
());
114
}
115
#endif
116
}
117
// mark internal edges belonging to a roundabout (after all edges are build)
118
if
(
MSGlobals::gUsingInternalLanes
) {
119
for
(EdgeCont::iterator i1 =
myEdges
.begin(); i1 !=
myEdges
.end(); i1++) {
120
MSEdge
* edge = *i1;
121
if
(edge->
isInternal
()) {
122
assert(edge->
getNoFollowing
() == 1);
123
assert(edge->
getIncomingEdges
().size() == 1);
124
if
(edge->
getFollower
(0)->
isRoundabout
() || edge->
getIncomingEdges
()[0]->isRoundabout()) {
125
edge->
markAsRoundabout
();
126
}
127
}
128
}
129
}
130
if
(!
deprecatedVehicleClassesSeen
.empty()) {
131
WRITE_WARNING
(
"Deprecated vehicle classes '"
+
toString
(
deprecatedVehicleClassesSeen
) +
"' in input network."
);
132
deprecatedVehicleClassesSeen
.clear();
133
}
134
return
new
MSEdgeControl
(
myEdges
);
135
}
136
137
138
MSEdge
*
139
NLEdgeControlBuilder::buildEdge
(
const
std::string&
id
,
const
MSEdge::EdgeBasicFunction
function
,
const
std::string& streetName,
const
std::string& edgeType) {
140
return
new
MSEdge
(
id
,
myCurrentNumericalEdgeID
++,
function
, streetName, edgeType);
141
}
142
143
144
145
/****************************************************************************/
146
tmp
buildd
sumo-0.21.0+dfsg
src
netload
NLEdgeControlBuilder.cpp
Generated on Thu Nov 20 2014 19:49:57 for SUMO - Simulation of Urban MObility by
1.8.1.2