sumolib.output.convert.shawn
This module includes functions for converting SUMO's fcd-output into data files read by Shawn.
1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 2# Copyright (C) 2013-2026 German Aerospace Center (DLR) and others. 3# This program and the accompanying materials are made available under the 4# terms of the Eclipse Public License 2.0 which is available at 5# https://www.eclipse.org/legal/epl-2.0/ 6# This Source Code may also be made available under the following Secondary 7# Licenses when the conditions for such availability set forth in the Eclipse 8# Public License 2.0 are satisfied: GNU General Public License, version 2 9# or later which is available at 10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 12 13# @file shawn.py 14# @author Daniel Krajzewicz 15# @author Michael Behrisch 16# @date 2013-01-15 17 18""" 19This module includes functions for converting SUMO's fcd-output into 20data files read by Shawn. 21""" 22from __future__ import print_function 23from __future__ import absolute_import 24import datetime 25import sumolib.output 26import sumolib.net 27 28 29def fcd2shawn(inpFCD, outSTRM, further): 30 print('<?xml version="1.0" encoding="utf-8"?>', file=outSTRM) 31 print('<!-- generated on %s by %s -->\n' % 32 (datetime.datetime.now(), further["app"]), file=outSTRM) 33 print('<scenario>', file=outSTRM) 34 # is it necessary to convert the ids? 35 vIDm = sumolib._Running(further["orig-ids"]) 36 for timestep in inpFCD: 37 print(' <snapshot id="%s">' % timestep.time, file=outSTRM) 38 if timestep.vehicle: 39 for v in timestep.vehicle: 40 nid = vIDm.g(v.id) 41 print(' <node id="%s"> <location x="%s" y="%s" z="%s"/> </node>' % 42 (nid, v.x, v.y, v.z), file=outSTRM) 43 print(' </snapshot>', file=outSTRM) 44 print('</scenario>', file=outSTRM)
def
fcd2shawn(inpFCD, outSTRM, further):
30def fcd2shawn(inpFCD, outSTRM, further): 31 print('<?xml version="1.0" encoding="utf-8"?>', file=outSTRM) 32 print('<!-- generated on %s by %s -->\n' % 33 (datetime.datetime.now(), further["app"]), file=outSTRM) 34 print('<scenario>', file=outSTRM) 35 # is it necessary to convert the ids? 36 vIDm = sumolib._Running(further["orig-ids"]) 37 for timestep in inpFCD: 38 print(' <snapshot id="%s">' % timestep.time, file=outSTRM) 39 if timestep.vehicle: 40 for v in timestep.vehicle: 41 nid = vIDm.g(v.id) 42 print(' <node id="%s"> <location x="%s" y="%s" z="%s"/> </node>' % 43 (nid, v.x, v.y, v.z), file=outSTRM) 44 print(' </snapshot>', file=outSTRM) 45 print('</scenario>', file=outSTRM)