1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 2# Copyright (C) 2011-2019 German Aerospace Center (DLR) and others. 3# This program and the accompanying materials 4# are made available under the terms of the Eclipse Public License v2.0 5# which accompanies this distribution, and is available at 6# http://www.eclipse.org/legal/epl-v20.html 7# SPDX-License-Identifier: EPL-2.0 8 9# @file connection.py 10# @author Daniel Krajzewicz 11# @author Laura Bieker 12# @author Karol Stosiek 13# @author Michael Behrisch 14# @author Jakob Erdmann 15# @date 2011-11-28 16# @version $Id$ 17 18 19class Connection: 20 # constants as defined in sumo/src/utils/xml/SUMOXMLDefinitions.cpp 21 LINKDIR_STRAIGHT = "s" 22 LINKDIR_TURN = "t" 23 LINKDIR_LEFT = "l" 24 LINKDIR_RIGHT = "r" 25 LINKDIR_PARTLEFT = "L" 26 LINKDIR_PARTRIGHT = "R" 27 28 """edge connection for a sumo network""" 29 30 def __init__(self, fromEdge, toEdge, fromLane, toLane, direction, tls, tllink, state, viaLaneID=None): 31 self._from = fromEdge 32 self._to = toEdge 33 self._fromLane = fromLane 34 self._toLane = toLane 35 self._direction = direction 36 self._tls = tls 37 self._tlLink = tllink 38 self._state = state 39 self._via = viaLaneID 40 41 def __str__(self): 42 return '<connection from="%s" to="%s" fromLane="%s" toLane="%s" %sdirection="%s">' % ( 43 self._from.getID(), 44 self._to.getID(), 45 self._fromLane.getIndex(), 46 self._toLane.getIndex(), 47 ('' if self._tls == '' else 'tl="%s" linkIndex="%s" ' % 48 (self._tls, self._tlLink)), 49 self._direction) 50 51 def getFrom(self): 52 return self._fromLane.getEdge() 53 54 def getTo(self): 55 return self._toLane.getEdge() 56 57 def getFromLane(self): 58 return self._fromLane 59 60 def getToLane(self): 61 return self._toLane 62 63 def getViaLaneID(self): 64 return self._via 65 66 def getDirection(self): 67 return self._direction 68 69 def getTLSID(self): 70 return self._tls 71 72 def getTLLinkIndex(self): 73 return self._tlLink 74 75 def getJunctionIndex(self): 76 return self._from.getToNode().getLinkIndex(self) 77 78 def getJunction(self): 79 return self._from.getToNode() 80 81 def getState(self): 82 return self._state 83