Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/tools/sumolib/xml/extend_edgeData/runner.py
428528 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2008-2026 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file runner.py
15
# @author Jakob Erdmann
16
# @date 2025-10-31
17
18
import os
19
import sys
20
if 'SUMO_HOME' in os.environ:
21
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
22
sys.path.append(tools)
23
else:
24
sys.exit("please declare environment variable 'SUMO_HOME'")
25
import sumolib.xml # noqa
26
27
infile, outfile = sys.argv[1:]
28
with open(outfile, 'w') as outf:
29
outf.write('<meanData>\n')
30
for interval in sumolib.xml.parse(sys.argv[1], "interval"):
31
for e in interval.edge:
32
e.setAttribute('flow', 3.6 * float(e.speed) * float(e.density))
33
outf.write(interval.toXML(initialIndent=' ' * 4))
34
35
outf.write('</meanData>\n')
36
37