sumolib.output.convert.poi

This module includes functions for converting SUMO's fcd-output into pois (useful for showing synthetic GPS disturtbances)

 1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
 2# Copyright (C) 2014-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    poi.py
14# @author  Jakob Erdmann
15# @author  Laura Bieker
16# @date    2014-02-13
17
18"""
19This module includes functions for converting SUMO's fcd-output into
20pois (useful for showing synthetic GPS disturtbances)
21"""
22from __future__ import absolute_import
23from collections import defaultdict
24from sumolib.shapes.poi import PoI
25from sumolib.color import RGBAColor
26from sumolib.miscutils import Colorgen
27
28LAYER = 100  # show above everything else
29
30
31def fcd2poi(inpFCD, outSTRM, ignored):
32    colors = defaultdict(
33        lambda: RGBAColor(*Colorgen(("random", 1, 1)).byteTuple()))
34    outSTRM.write("<pois>\n")
35    for timestep in inpFCD:
36        for v in timestep.vehicle:
37            outSTRM.write("    %s\n" % PoI("%s_%s" % (
38                v.id, timestep.time), v.id, LAYER, colors[v.id], v.x, v.y, lonLat=True).toXML())
39    outSTRM.write("</pois>\n")
LAYER = 100
def fcd2poi(inpFCD, outSTRM, ignored):
32def fcd2poi(inpFCD, outSTRM, ignored):
33    colors = defaultdict(
34        lambda: RGBAColor(*Colorgen(("random", 1, 1)).byteTuple()))
35    outSTRM.write("<pois>\n")
36    for timestep in inpFCD:
37        for v in timestep.vehicle:
38            outSTRM.write("    %s\n" % PoI("%s_%s" % (
39                v.id, timestep.time), v.id, LAYER, colors[v.id], v.x, v.y, lonLat=True).toXML())
40    outSTRM.write("</pois>\n")