Eclipse SUMO - Simulation of Urban MObility
MSLogicJunction.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-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 /****************************************************************************/
17 // with one ore more logics.
18 /****************************************************************************/
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include "MSLinkCont.h"
26 #include "MSLogicJunction.h"
27 #include "MSLane.h"
28 
29 
30 // ===========================================================================
31 // member method definitions
32 // ===========================================================================
33 /* -------------------------------------------------------------------------
34  * methods from MSLogicJunction
35  * ----------------------------------------------------------------------- */
36 MSLogicJunction::MSLogicJunction(const std::string& id,
37  SumoXMLNodeType type,
38  const Position& position,
39  const PositionVector& shape,
40  std::vector<MSLane*> incoming
41  , std::vector<MSLane*> internal
42  ):
43  MSJunction(id, type, position, shape),
44  myIncomingLanes(incoming),
45  myInternalLanes(internal) {
46 }
47 
48 
50 
51 
52 void
54  /*
55  if(getID()=="1565") {
56  int bla = 0;
57  }
58  // inform links where they have to report approaching vehicles to
59  int requestPos = 0;
60  std::vector<MSLane*>::iterator i;
61  // going through the incoming lanes...
62  for(i=myIncomingLanes.begin(); i!=myIncomingLanes.end(); ++i) {
63  const MSLinkCont &links = (*i)->getLinkCont();
64  // ... set information for every link
65  for(MSLinkCont::const_iterator j=links.begin(); j!=links.end(); j++) {
66  (*j)->setRequestInformation(&myRequest, requestPos,
67  &myRespond, requestPos/, clearInfo/);
68  requestPos++;
69  }
70  }
71  // set information for the internal lanes
72  requestPos = 0;
73  for(i=myInternalLanes.begin(); i!=myInternalLanes.end(); ++i) {
74  // ... set information about participation
75  static_cast<MSInternalLane*>(*i)->setParentJunctionInformation(
76  &myInnerState, requestPos++);
77  }
78  */
79 }
80 
81 const std::vector<MSLane*>
83  // Besides the lanes im myInternal lanes, which are only the last parts of the connections,
84  // this collects all lanes on the junction
85  std::vector<MSLane*> allInternalLanes;
86  for (std::vector<MSLane*>::const_iterator i = myInternalLanes.begin(); i != myInternalLanes.end(); ++i) {
87  MSLane* l = *i;
88  while (l != nullptr) {
89  allInternalLanes.push_back(l);
90  const std::vector<MSLane::IncomingLaneInfo> incoming = l->getIncomingLanes();
91  if (incoming.size() == 0) {
92  break;
93  }
94  assert(l->getIncomingLanes().size() == 1);
95  l = l->getIncomingLanes()[0].lane;
96  if (!l->isInternal()) {
97  break;
98  }
99  }
100  }
101  return allInternalLanes;
102 }
103 
104 
105 
106 /****************************************************************************/
107 
MSLogicJunction::MSLogicJunction
MSLogicJunction(const std::string &id, SumoXMLNodeType type, const Position &position, const PositionVector &shape, std::vector< MSLane * > incoming, std::vector< MSLane * > internal)
Constructor.
Definition: MSLogicJunction.cpp:36
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSJunction
The base class for an intersection.
Definition: MSJunction.h:60
MSLogicJunction::myInternalLanes
std::vector< MSLane * > myInternalLanes
list of internal lanes
Definition: MSLogicJunction.h:89
PositionVector
A list of positions.
Definition: PositionVector.h:45
MSLane::getIncomingLanes
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:818
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
MSLogicJunction::getInternalLanes
const std::vector< MSLane * > getInternalLanes() const
Returns all internal lanes on the junction.
Definition: MSLogicJunction.cpp:82
MSLogicJunction::~MSLogicJunction
virtual ~MSLogicJunction()
Destructor.
Definition: MSLogicJunction.cpp:49
config.h
MSLogicJunction.h
MSLane.h
MSLogicJunction::postloadInit
virtual void postloadInit()
initialises the junction after the whole net has been loaded
Definition: MSLogicJunction.cpp:53