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