SUMO - Simulation of Urban MObility
MSLinkCont.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2004-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 /****************************************************************************/
16 // Helpers for link vector
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include "MSLinkCont.h"
26 #include "MSLane.h"
27 
28 
29 // ===========================================================================
30 // method definitions
31 // ===========================================================================
32 const MSEdge*
34  const MSEdge* followerAfterInternal) {
35  //@todo to be optimized
36  const MSLinkCont& lc = fromLane->getLinkCont();
37  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
38  MSLink* link = *j;
39  if (&link->getLane()->getEdge() == followerAfterInternal) {
40  if (link->getViaLane() != nullptr) {
41  return &link->getViaLane()->getEdge();
42  } else {
43  return nullptr; // network without internal links
44  }
45  }
46  }
47  return nullptr;
48 }
49 
50 
51 const MSLane*
53  const MSLane* followerAfterInternal) {
54  //@todo to be optimized
55  const MSLinkCont& lc = fromLane->getLinkCont();
56  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
57  MSLink* link = *j;
58  if (link->getLane() == followerAfterInternal) {
59  if (link->getViaLane() != nullptr) {
60  return link->getViaLane();
61  } else {
62  return nullptr; // network without internal links
63  }
64  }
65  }
66  return nullptr;
67 }
68 
69 
70 MSLink*
72  const MSLinkCont& lc = from.getLinkCont();
73  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
74  MSLink* link = *j;
75  if (link->getLane() == &to) {
76  return link;
77  } else if (link->getViaLaneOrLane() == &to) {
78  return link;
79  }
80  }
81  return nullptr;
82 }
83 
84 
85 
86 /****************************************************************************/
87 
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:640
A road/street connecting two junctions.
Definition: MSEdge.h:75
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1975
Representation of a lane in the micro simulation.
Definition: MSLane.h:78