/usr/share/sumo/tools/net/netextract.py is in sumo-tools 0.15.0~dfsg-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #!/usr/bin/env python
"""
@file netextract.py
@author Daniel Krajzewicz
@author Laura Bieker
@author Michael Behrisch
@date 2007-02-21
@version $Id: netextract.py 11671 2012-01-07 20:14:30Z behrisch $
This script reads in the network given as
first parameter and extracts nodes and edges
from it which are saved into "nodes.xml" and
"edges.xml" for their reuse in NETCONVERT
todo:
- parse connections
- parse tls information
SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
Copyright (C) 2008-2012 DLR (http://www.dlr.de/) and contributors
All rights reserved
"""
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import sumolib.net
def writeNodes(net):
""" Writes nodes in a xml file """
fd = open("nodes.xml", "w")
fd.write("<nodes>\n")
for node in net._nodes:
fd.write(" <node id=\"" + node._id + "\" x=\"" + str(node._coord[0]) + "\" y=\"" + str(node._coord[1]) + "\"/>\n")
fd.write("</nodes>\n")
def writeEdges(net):
""" Writes edges in a xml file """
fd = open("edges.xml", "w")
fd.write("<edges>\n")
for edge in net._edges:
fd.write(" <edge id=\"" + edge._id + "\" from=\"" + edge._from._id + "\" to=\"" + edge._to._id)
fd.write("\" speed=\"" + str(edge._speed))
fd.write("\" priority=\"" + str(edge._priority))
fd.write("\" spreadType=\"center")
fd.write("\" numLanes=\"" + str(len(edge._lanes)) + "\"")
shape = edge.getShape()
fd.write(" shape=\"")
for i,c in enumerate(shape):
if i!=0:
fd.write(" ")
fd.write(str(c[0]) + "," + str(c[1]))
fd.write("\"")
fd.write("/>\n")
fd.write("</edges>\n")
if len(sys.argv) < 2:
print "Usage: " + sys.argv[0] + " <net>"
sys.exit()
print "Reading net..."
net = sumolib.net.readNet(sys.argv[1])
print "Writing nodes..."
writeNodes(net)
print "Writing edges..."
writeEdges(net)
|