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