def writeConnections(net):
    fd = open("roundabout-connection.con.xml", "w")
    fd.write("<connections>\n")
    for ra in net.getRoundabouts():
        for node in ra.getNodes():
            edgesOut= net.getNode(node)._outgoing
            edgesIn= net.getNode(node)._incoming
            for edgeOut in edgesOut:
                outNumber= edgeOut.getLaneNumber() 
                for edgeIn in edgesIn:
                    if not edgeOut in edgeIn._outgoing:
                        continue
                    inNumber= edgeIn.getLaneNumber() 
                    for x in range(inNumber):
                        if x < inNumber and x < outNumber:
                            fd.write("   <connection from=\"" +str(edgeIn._id)+ "\" to=\"" + str(edgeOut._id)+ "\" lane=\""+ str(x) +":"+ str(x) +"\" />\n")
    fd.write("</connections>\n")
Beispiel #2
0
def writeConnections(net):
    fd = open("roundabout-connection.con.xml", "w")
    fd.write("<connections>\n")
    for ra in net.getRoundabouts():
        for node in ra.getNodes():
            edgesOut= net.getNode(node)._outgoing
            edgesIn= net.getNode(node)._incoming
            for edgeOut in edgesOut:
                outNumber= edgeOut.getLaneNumber() 
                for edgeIn in edgesIn:
                    if not edgeOut in edgeIn._outgoing:
                        continue
                    inNumber= edgeIn.getLaneNumber() 
                    for x in range(inNumber):
                        if x < inNumber and x < outNumber:
                            fd.write("   <connection from=\"" +str(edgeIn._id)+ "\" to=\"" + str(edgeOut._id)+ "\" lane=\""+ str(x) +":"+ str(x) +"\" />\n")
    fd.write("</connections>\n")
        fd.write("\"")
        fd.write("/>\n")
    fd.write("</edges>\n")


    
if len(sys.argv) < 4:
    print "Usage: " + sys.argv[0] + " <net> <prefix> <nodes>"
    sys.exit()
print "Reading net..."
net = sumolib.net.readNet(sys.argv[1])

edges = set()
nodes = set()
for n in sys.argv[3].split(","):
    n = net.getNode(n)
    nodes.add(n)
    for e in n._incoming:
        edges.add(e)
        nodes.add(e._from)
    for e in n._outgoing:
        edges.add(e)
        nodes.add(e._to)

net = sumolib.net.Net()
for e in edges:
    c = net.addEdge(e._id, e._from._id, e._to._id, e._priority, e._function)
    for l in e._lanes:
        lane = sumolib.net.Lane(c, l.getSpeed(), l.getLength())
        lane.setShape(l.getShape())
    c.rebuildShape()
Beispiel #4
0
            fd.write(str(c[0]) + "," + str(c[1]))
        fd.write("\"")
        fd.write("/>\n")
    fd.write("</edges>\n")


if len(sys.argv) < 4:
    print("Usage: " + sys.argv[0] + " <net> <prefix> <nodes>")
    sys.exit()
print("Reading net...")
net = sumolib.net.readNet(sys.argv[1])

edges = set()
nodes = set()
for n in sys.argv[3].split(","):
    n = net.getNode(n)
    nodes.add(n)
    for e in n._incoming:
        edges.add(e)
        nodes.add(e._from)
    for e in n._outgoing:
        edges.add(e)
        nodes.add(e._to)

net = sumolib.net.Net()
for e in edges:
    c = net.addEdge(e._id, e._from._id, e._to._id, e._priority, e._function)
    for l in e._lanes:
        lane = sumolib.net.Lane(c, l.getSpeed(), l.getLength())
        lane.setShape(l.getShape())
    c.rebuildShape()