Esempio n. 1
0
 def endElement(self, name):
     if name == 'key':
         self._junctionObj.label = self._chars
         self._junctionObj = self._net.getJunction(self._junctionObj.label)
         if self._junctionObj:
             self._junctionObj.phases = []
         else:
             self._junctionObj = TLJunction()
             self._junctionObj.label = self._junctionObj.label
             self._net.addTLJunctions(self._junctionObj)
         self._chars = ''
     elif name == 'phaseno':
         self._junctionObj.phaseNum = int(self._chars)
         self._chars = ''
     elif name == 'tl-logic' or name == 'tlLogic':
         if not self._phasenoInfo:
             self._junctionObj.phaseNum = self._counter
         self._counter = 0
         self._phasenoInfo = True
         self._junctionObj.label = None
         self._junctionObj = None
Esempio n. 2
0
 def startElement(self, name, attrs):
     self._chars = ''
     if name == 'tl-logic' or name == 'tlLogic':
         if 'id' in attrs:
             self._junctionObj = self._net.getJunction(attrs['id'])
             if self._junctionObj:
                 self._junctionObj.phases = []
             else:
                 self._junctionObj = TLJunction()
                 self._junctionObj.label = attrs['id']
                 self._net.addTLJunctions(self._junctionObj)
             self._phasenoInfo = False
     elif name == 'phase':
         if 'state' in attrs:
             self._newphase = Signalphase(
                 float(attrs['duration']), attrs['state'])
         else:
             self._newphase = Signalphase(
                 float(attrs['duration']), None, attrs['phase'], attrs['brake'], attrs['yellow'])
         if self._junctionObj:
             self._junctionObj.phases.append(self._newphase)
             self._counter += 1
             self._newphase.label = self._counter
Esempio n. 3
0
 def startElement(self, name, attrs):
     self._chars = ''
     if name == 'edge' and (not attrs.has_key('function')
                            or attrs['function'] != 'internal'):
         self._edge = attrs['id']
         self._net.addIsolatedRealEdge(self._edge)
         self._edgeObj = self._net.getEdge(self._edge)
         self._edgeObj.source.label = attrs['from']
         self._edgeObj.target.label = attrs['to']
         self._maxSpeed = 0
         self._laneNumber = 0
         self._length = 0
     elif name == 'tl-logic':
         self._junctionObj = TLJunction()
         if self._junctionObj and attrs.has_key('id'):
             self._junctionObj.label = attrs['id']
             self._net.addTLJunctions(self._junctionObj)
             self._phasenoInfo = False
     elif self._junctionObj and name == 'phase':
         if attrs.has_key('state'):
             self._newphase = Signalphase(float(attrs['duration']),
                                          attrs['state'])
         else:
             self._newphase = Signalphase(float(attrs['duration']), None,
                                          attrs['phase'], attrs['brake'],
                                          attrs['yellow'])
         if self._junctionObj:
             self._junctionObj.phases.append(self._newphase)
             self._counter += 1
             self._newphase.label = self._counter
     elif name == 'succ':
         self._edge = attrs['edge']
         if self._edge[0] != ':':
             self._edgeObj = self._net.getEdge(self._edge)
             if self._edgeObj.junction == 'None':
                 self._edgeObj.junction = attrs['junction']
         else:
             self._edge = ""
     elif name == 'succlane' and self._edge != "":
         l = attrs['lane']
         if l != "SUMO_NO_DESTINATION":
             toEdge = self._net.getEdge(l[:l.rfind('_')])
             newEdge = Edge(self._edge + "_" + l[:l.rfind('_')],
                            self._edgeObj.target, toEdge.source)
             self._net.addEdge(newEdge)
             self._edgeObj.finalizer = l[:l.rfind('_')]
             if attrs.has_key('tl'):
                 self._edgeObj.junction = attrs['tl']
                 self._edgeObj.junctiontype = 'signalized'
                 if attrs['dir'] == "r":
                     self._edgeObj.rightturn = attrs['linkno']
                     self._edgeObj.rightlink.append(toEdge)
                 elif attrs['dir'] == "s":
                     self._edgeObj.straight = attrs['linkno']
                     self._edgeObj.straightlink.append(toEdge)
                 elif attrs['dir'] == "l":
                     self._edgeObj.leftturn = attrs['linkno']
                     self._edgeObj.leftlink.append(toEdge)
                 elif attrs['dir'] == "t":
                     self._edgeObj.uturn = attrs['linkno']
             else:
                 self._edgeObj.junctiontype = 'prioritized'
                 if attrs['dir'] == "r":
                     self._edgeObj.rightturn = attrs['state']
                     self._edgeObj.rightlink.append(toEdge)
                 elif attrs['dir'] == "s":
                     self._edgeObj.straight = attrs['state']
                     self._edgeObj.straightlink.append(toEdge)
                 elif attrs['dir'] == "l":
                     self._edgeObj.leftturn = attrs['state']
                     self._edgeObj.leftlink.append(toEdge)
                 elif attrs['dir'] == "t":
                     self._edgeObj.uturn = attrs['state']
     elif name == 'lane' and self._edge != '':
         self._maxSpeed = max(self._maxSpeed, float(attrs['maxspeed']))
         self._laneNumber = self._laneNumber + 1
         self._length = float(attrs['length'])