Eclipse SUMO - Simulation of Urban MObility
MSNoLogicJunction.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-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 /****************************************************************************/
16 // -------------------
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include "MSNoLogicJunction.h"
26 #include "MSLane.h"
27 #include <algorithm>
28 #include <cassert>
29 #include <cmath>
30 
31 
32 // ===========================================================================
33 // static member definitions
34 // ===========================================================================
35 
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
40  SumoXMLNodeType type,
41  const Position& position,
42  const PositionVector& shape,
43  std::vector<MSLane*> incoming, std::vector<MSLane*> internal):
44  MSJunction(id, type, position, shape),
45  myIncomingLanes(incoming),
46  myInternalLanes(internal) {
47 }
48 
49 
51 
52 
53 void
55  std::vector<MSLane*>::iterator i;
56  // inform links where they have to report approaching vehicles to
57  for (i = myIncomingLanes.begin(); i != myIncomingLanes.end(); ++i) {
58  const MSLinkCont& links = (*i)->getLinkCont();
59  for (MSLinkCont::const_iterator j = links.begin(); j != links.end(); j++) {
60  (*j)->setRequestInformation(-1, false, false, std::vector<MSLink*>(), std::vector<MSLane*>());
61  }
62  }
63 }
64 
65 
66 const std::vector<MSLane*>
68  // Besides the lanes im myInternal lanes, which are only the last parts of the connections,
69  // this collects all lanes on the junction
70  std::vector<MSLane*> allInternalLanes;
71  for (std::vector<MSLane*>::const_iterator i = myInternalLanes.begin(); i != myInternalLanes.end(); ++i) {
72  MSLane* l = *i;
73  while (l != nullptr) {
74  allInternalLanes.push_back(l);
75  const std::vector<MSLane::IncomingLaneInfo> incoming = l->getIncomingLanes();
76  if (incoming.size() == 0) {
77  break;
78  }
79  assert(l->getIncomingLanes().size() == 1);
80  l = l->getIncomingLanes()[0].lane;
81  if (!l->isInternal()) {
82  break;
83  }
84  }
85  }
86  return allInternalLanes;
87 }
88 
89 
90 
91 /****************************************************************************/
92 
MSNoLogicJunction::myIncomingLanes
std::vector< MSLane * > myIncomingLanes
Definition: MSNoLogicJunction.h:74
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSJunction
The base class for an intersection.
Definition: MSJunction.h:60
MSNoLogicJunction::~MSNoLogicJunction
virtual ~MSNoLogicJunction()
Destructor.
Definition: MSNoLogicJunction.cpp:50
PositionVector
A list of positions.
Definition: PositionVector.h:45
MSLane::getIncomingLanes
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:818
MSNoLogicJunction::postloadInit
void postloadInit()
Definition: MSNoLogicJunction.cpp:54
SumoXMLNodeType
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Definition: SUMOXMLDefinitions.h:1054
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
MSNoLogicJunction.h
MSNoLogicJunction::myInternalLanes
std::vector< MSLane * > myInternalLanes
Definition: MSNoLogicJunction.h:77
config.h
MSLane.h
MSNoLogicJunction::getInternalLanes
virtual const std::vector< MSLane * > getInternalLanes() const
Returns all internal lanes on the junction.
Definition: MSNoLogicJunction.cpp:67
MSNoLogicJunction::MSNoLogicJunction
MSNoLogicJunction(const std::string &id, SumoXMLNodeType type, const Position &position, const PositionVector &shape, std::vector< MSLane * > incoming, std::vector< MSLane * > internal)
Constructor.
Definition: MSNoLogicJunction.cpp:39