1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2004-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 /****************************************************************************/ 10 /// @file MSLinkCont.cpp 11 /// @author Daniel Krajzewicz 12 /// @author Jakob Erdmann 13 /// @date 15 Feb 2004 14 /// @version $Id$ 15 /// 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* getInternalFollowingEdge(const MSLane * fromLane,const MSEdge * followerAfterInternal)33MSLinkContHelper::getInternalFollowingEdge(const MSLane* fromLane, 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* getInternalFollowingLane(const MSLane * fromLane,const MSLane * followerAfterInternal)52MSLinkContHelper::getInternalFollowingLane(const MSLane* fromLane, 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* getConnectingLink(const MSLane & from,const MSLane & to)71MSLinkContHelper::getConnectingLink(const MSLane& from, const MSLane& to) { 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 88