traci._poi

  1# -*- coding: utf-8 -*-
  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    _poi.py
 15# @author  Michael Behrisch
 16# @author  Lena Kalleske
 17# @date    2008-10-09
 18
 19from __future__ import absolute_import
 20from .domain import Domain
 21from . import constants as tc
 22from .exceptions import TraCIException
 23
 24
 25class PoiDomain(Domain):
 26
 27    def __init__(self):
 28        Domain.__init__(self, "poi", tc.CMD_GET_POI_VARIABLE, tc.CMD_SET_POI_VARIABLE,
 29                        tc.CMD_SUBSCRIBE_POI_VARIABLE, tc.RESPONSE_SUBSCRIBE_POI_VARIABLE,
 30                        tc.CMD_SUBSCRIBE_POI_CONTEXT, tc.RESPONSE_SUBSCRIBE_POI_CONTEXT)
 31
 32    def getType(self, poiID):
 33        """getType(string) -> string
 34
 35        Returns the (abstract) type of the poi.
 36        """
 37        return self._getUniversal(tc.VAR_TYPE, poiID)
 38
 39    def getPosition(self, poiID):
 40        """getPosition(string) -> (double, double)
 41
 42        Returns the position coordinates of the given poi.
 43        """
 44        return self._getUniversal(tc.VAR_POSITION, poiID)
 45
 46    def getColor(self, poiID):
 47        """getColor(string) -> (integer, integer, integer, integer)
 48
 49        Returns the rgba color of the given poi.
 50        """
 51        return self._getUniversal(tc.VAR_COLOR, poiID)
 52
 53    def getWidth(self, poiID):
 54        """getWidth(string) -> double
 55
 56        Returns the width of the given poi.
 57        """
 58        return self._getUniversal(tc.VAR_WIDTH, poiID)
 59
 60    def getHeight(self, poiID):
 61        """getHeight(string) -> double
 62
 63        Returns the height of the given poi.
 64        """
 65        return self._getUniversal(tc.VAR_HEIGHT, poiID)
 66
 67    def getAngle(self, poiID):
 68        """getAngle(string) -> double
 69
 70        Returns the angle of the given poi.
 71        """
 72        return self._getUniversal(tc.VAR_ANGLE, poiID)
 73
 74    def getImageFile(self, poiID):
 75        """getImageFile(string) -> string
 76
 77        Returns the image file of the given poi.
 78        """
 79        return self._getUniversal(tc.VAR_IMAGEFILE, poiID)
 80
 81    def setType(self, poiID, poiType):
 82        """setType(string, string) -> None
 83
 84        Sets the (abstract) type of the poi.
 85        """
 86        self._setCmd(tc.VAR_TYPE, poiID, "s", poiType)
 87
 88    def setPosition(self, poiID, x, y):
 89        """setPosition(string, (double, double)) -> None
 90
 91        Sets the position coordinates of the poi.
 92        """
 93        self._setCmd(tc.VAR_POSITION, poiID, "o", (x, y))
 94
 95    def setColor(self, poiID, color):
 96        """setColor(string, (integer, integer, integer, integer)) -> None
 97
 98        Sets the rgba color of the poi, i.e. (255,0,0) for the color red.
 99        The fourth component (alpha) is optional.
100        """
101        self._setCmd(tc.VAR_COLOR, poiID, "c", color)
102
103    def setWidth(self, poiID, width):
104        """setWidth(string, double) -> None
105
106        Sets the width of the poi.
107        """
108        self._setCmd(tc.VAR_WIDTH, poiID, "d", width)
109
110    def setHeight(self, poiID, height):
111        """setHeight(string, double) -> None
112
113        Sets the height of the poi.
114        """
115        self._setCmd(tc.VAR_HEIGHT, poiID, "d", height)
116
117    def setAngle(self, poiID, angle):
118        """setAngle(string, double) -> None
119
120        Sets the angle of the poi.
121        """
122        self._setCmd(tc.VAR_ANGLE, poiID, "d", angle)
123
124    def setImageFile(self, poiID, imageFile):
125        """setImageFile(string, string) -> None
126
127        Sets the image file of the poi.
128        """
129        self._setCmd(tc.VAR_IMAGEFILE, poiID, "s", imageFile)
130
131    def add(self, poiID, x, y, color, poiType="", layer=0, imgFile="", width=1, height=1, angle=0, icon=""):
132        """
133        add(string, double, double, (byte, byte, byte, byte), string, integer, string, double, double, double) -> None
134
135        Adds a poi with the given values
136        """
137        self._setCmd(tc.ADD, poiID, "tsciosddds", 9, poiType, color, layer, (x, y), imgFile, width, height, angle, icon)
138
139    def remove(self, poiID, layer=0):
140        """
141        remove(string, integer) -> None
142        Removes the poi with the given poiID
143        """
144        self._setCmd(tc.REMOVE, poiID, "i", layer)
145
146    def highlight(self, poiID, color=(255, 0, 0, 255), size=-1, alphaMax=-1, duration=-1, type=0):
147        """ highlight(string, color, float, ubyte) -> void
148            Adds a circle of the given color highlighting the poi.
149            If a positive size [in m] is given the size of the highlight is chosen accordingly,
150            otherwise the image size of the poi is used as reference.
151            If alphaMax and duration are positive, the circle fades in and out within the given duration,
152            otherwise it is permanently added on top of the poi.
153        """
154        if type > 255:
155            raise TraCIException("poi.highlight(): maximal value for type is 255")
156        if alphaMax > 255:
157            raise TraCIException("poi.highlight(): maximal value for alphaMax is 255")
158        if alphaMax <= 0 and duration > 0:
159            raise TraCIException("poi.highlight(): duration>0 requires alphaMax>0")
160        if alphaMax > 0 and duration <= 0:
161            raise TraCIException("poi.highlight(): alphaMax>0 requires duration>0")
162        if alphaMax > 0:
163            self._setCmd(tc.VAR_HIGHLIGHT, poiID, "tcdBdB", 5, color, size, alphaMax, duration, type)
164        else:
165            self._setCmd(tc.VAR_HIGHLIGHT, poiID, "tcd", 2, color, size)
class PoiDomain(traci.domain.Domain):
 26class PoiDomain(Domain):
 27
 28    def __init__(self):
 29        Domain.__init__(self, "poi", tc.CMD_GET_POI_VARIABLE, tc.CMD_SET_POI_VARIABLE,
 30                        tc.CMD_SUBSCRIBE_POI_VARIABLE, tc.RESPONSE_SUBSCRIBE_POI_VARIABLE,
 31                        tc.CMD_SUBSCRIBE_POI_CONTEXT, tc.RESPONSE_SUBSCRIBE_POI_CONTEXT)
 32
 33    def getType(self, poiID):
 34        """getType(string) -> string
 35
 36        Returns the (abstract) type of the poi.
 37        """
 38        return self._getUniversal(tc.VAR_TYPE, poiID)
 39
 40    def getPosition(self, poiID):
 41        """getPosition(string) -> (double, double)
 42
 43        Returns the position coordinates of the given poi.
 44        """
 45        return self._getUniversal(tc.VAR_POSITION, poiID)
 46
 47    def getColor(self, poiID):
 48        """getColor(string) -> (integer, integer, integer, integer)
 49
 50        Returns the rgba color of the given poi.
 51        """
 52        return self._getUniversal(tc.VAR_COLOR, poiID)
 53
 54    def getWidth(self, poiID):
 55        """getWidth(string) -> double
 56
 57        Returns the width of the given poi.
 58        """
 59        return self._getUniversal(tc.VAR_WIDTH, poiID)
 60
 61    def getHeight(self, poiID):
 62        """getHeight(string) -> double
 63
 64        Returns the height of the given poi.
 65        """
 66        return self._getUniversal(tc.VAR_HEIGHT, poiID)
 67
 68    def getAngle(self, poiID):
 69        """getAngle(string) -> double
 70
 71        Returns the angle of the given poi.
 72        """
 73        return self._getUniversal(tc.VAR_ANGLE, poiID)
 74
 75    def getImageFile(self, poiID):
 76        """getImageFile(string) -> string
 77
 78        Returns the image file of the given poi.
 79        """
 80        return self._getUniversal(tc.VAR_IMAGEFILE, poiID)
 81
 82    def setType(self, poiID, poiType):
 83        """setType(string, string) -> None
 84
 85        Sets the (abstract) type of the poi.
 86        """
 87        self._setCmd(tc.VAR_TYPE, poiID, "s", poiType)
 88
 89    def setPosition(self, poiID, x, y):
 90        """setPosition(string, (double, double)) -> None
 91
 92        Sets the position coordinates of the poi.
 93        """
 94        self._setCmd(tc.VAR_POSITION, poiID, "o", (x, y))
 95
 96    def setColor(self, poiID, color):
 97        """setColor(string, (integer, integer, integer, integer)) -> None
 98
 99        Sets the rgba color of the poi, i.e. (255,0,0) for the color red.
100        The fourth component (alpha) is optional.
101        """
102        self._setCmd(tc.VAR_COLOR, poiID, "c", color)
103
104    def setWidth(self, poiID, width):
105        """setWidth(string, double) -> None
106
107        Sets the width of the poi.
108        """
109        self._setCmd(tc.VAR_WIDTH, poiID, "d", width)
110
111    def setHeight(self, poiID, height):
112        """setHeight(string, double) -> None
113
114        Sets the height of the poi.
115        """
116        self._setCmd(tc.VAR_HEIGHT, poiID, "d", height)
117
118    def setAngle(self, poiID, angle):
119        """setAngle(string, double) -> None
120
121        Sets the angle of the poi.
122        """
123        self._setCmd(tc.VAR_ANGLE, poiID, "d", angle)
124
125    def setImageFile(self, poiID, imageFile):
126        """setImageFile(string, string) -> None
127
128        Sets the image file of the poi.
129        """
130        self._setCmd(tc.VAR_IMAGEFILE, poiID, "s", imageFile)
131
132    def add(self, poiID, x, y, color, poiType="", layer=0, imgFile="", width=1, height=1, angle=0, icon=""):
133        """
134        add(string, double, double, (byte, byte, byte, byte), string, integer, string, double, double, double) -> None
135
136        Adds a poi with the given values
137        """
138        self._setCmd(tc.ADD, poiID, "tsciosddds", 9, poiType, color, layer, (x, y), imgFile, width, height, angle, icon)
139
140    def remove(self, poiID, layer=0):
141        """
142        remove(string, integer) -> None
143        Removes the poi with the given poiID
144        """
145        self._setCmd(tc.REMOVE, poiID, "i", layer)
146
147    def highlight(self, poiID, color=(255, 0, 0, 255), size=-1, alphaMax=-1, duration=-1, type=0):
148        """ highlight(string, color, float, ubyte) -> void
149            Adds a circle of the given color highlighting the poi.
150            If a positive size [in m] is given the size of the highlight is chosen accordingly,
151            otherwise the image size of the poi is used as reference.
152            If alphaMax and duration are positive, the circle fades in and out within the given duration,
153            otherwise it is permanently added on top of the poi.
154        """
155        if type > 255:
156            raise TraCIException("poi.highlight(): maximal value for type is 255")
157        if alphaMax > 255:
158            raise TraCIException("poi.highlight(): maximal value for alphaMax is 255")
159        if alphaMax <= 0 and duration > 0:
160            raise TraCIException("poi.highlight(): duration>0 requires alphaMax>0")
161        if alphaMax > 0 and duration <= 0:
162            raise TraCIException("poi.highlight(): alphaMax>0 requires duration>0")
163        if alphaMax > 0:
164            self._setCmd(tc.VAR_HIGHLIGHT, poiID, "tcdBdB", 5, color, size, alphaMax, duration, type)
165        else:
166            self._setCmd(tc.VAR_HIGHLIGHT, poiID, "tcd", 2, color, size)
def getType(self, poiID):
33    def getType(self, poiID):
34        """getType(string) -> string
35
36        Returns the (abstract) type of the poi.
37        """
38        return self._getUniversal(tc.VAR_TYPE, poiID)

getType(string) -> string

Returns the (abstract) type of the poi.

def getPosition(self, poiID):
40    def getPosition(self, poiID):
41        """getPosition(string) -> (double, double)
42
43        Returns the position coordinates of the given poi.
44        """
45        return self._getUniversal(tc.VAR_POSITION, poiID)

getPosition(string) -> (double, double)

Returns the position coordinates of the given poi.

def getColor(self, poiID):
47    def getColor(self, poiID):
48        """getColor(string) -> (integer, integer, integer, integer)
49
50        Returns the rgba color of the given poi.
51        """
52        return self._getUniversal(tc.VAR_COLOR, poiID)

getColor(string) -> (integer, integer, integer, integer)

Returns the rgba color of the given poi.

def getWidth(self, poiID):
54    def getWidth(self, poiID):
55        """getWidth(string) -> double
56
57        Returns the width of the given poi.
58        """
59        return self._getUniversal(tc.VAR_WIDTH, poiID)

getWidth(string) -> double

Returns the width of the given poi.

def getHeight(self, poiID):
61    def getHeight(self, poiID):
62        """getHeight(string) -> double
63
64        Returns the height of the given poi.
65        """
66        return self._getUniversal(tc.VAR_HEIGHT, poiID)

getHeight(string) -> double

Returns the height of the given poi.

def getAngle(self, poiID):
68    def getAngle(self, poiID):
69        """getAngle(string) -> double
70
71        Returns the angle of the given poi.
72        """
73        return self._getUniversal(tc.VAR_ANGLE, poiID)

getAngle(string) -> double

Returns the angle of the given poi.

def getImageFile(self, poiID):
75    def getImageFile(self, poiID):
76        """getImageFile(string) -> string
77
78        Returns the image file of the given poi.
79        """
80        return self._getUniversal(tc.VAR_IMAGEFILE, poiID)

getImageFile(string) -> string

Returns the image file of the given poi.

def setType(self, poiID, poiType):
82    def setType(self, poiID, poiType):
83        """setType(string, string) -> None
84
85        Sets the (abstract) type of the poi.
86        """
87        self._setCmd(tc.VAR_TYPE, poiID, "s", poiType)

setType(string, string) -> None

Sets the (abstract) type of the poi.

def setPosition(self, poiID, x, y):
89    def setPosition(self, poiID, x, y):
90        """setPosition(string, (double, double)) -> None
91
92        Sets the position coordinates of the poi.
93        """
94        self._setCmd(tc.VAR_POSITION, poiID, "o", (x, y))

setPosition(string, (double, double)) -> None

Sets the position coordinates of the poi.

def setColor(self, poiID, color):
 96    def setColor(self, poiID, color):
 97        """setColor(string, (integer, integer, integer, integer)) -> None
 98
 99        Sets the rgba color of the poi, i.e. (255,0,0) for the color red.
100        The fourth component (alpha) is optional.
101        """
102        self._setCmd(tc.VAR_COLOR, poiID, "c", color)

setColor(string, (integer, integer, integer, integer)) -> None

Sets the rgba color of the poi, i.e. (255,0,0) for the color red. The fourth component (alpha) is optional.

def setWidth(self, poiID, width):
104    def setWidth(self, poiID, width):
105        """setWidth(string, double) -> None
106
107        Sets the width of the poi.
108        """
109        self._setCmd(tc.VAR_WIDTH, poiID, "d", width)

setWidth(string, double) -> None

Sets the width of the poi.

def setHeight(self, poiID, height):
111    def setHeight(self, poiID, height):
112        """setHeight(string, double) -> None
113
114        Sets the height of the poi.
115        """
116        self._setCmd(tc.VAR_HEIGHT, poiID, "d", height)

setHeight(string, double) -> None

Sets the height of the poi.

def setAngle(self, poiID, angle):
118    def setAngle(self, poiID, angle):
119        """setAngle(string, double) -> None
120
121        Sets the angle of the poi.
122        """
123        self._setCmd(tc.VAR_ANGLE, poiID, "d", angle)

setAngle(string, double) -> None

Sets the angle of the poi.

def setImageFile(self, poiID, imageFile):
125    def setImageFile(self, poiID, imageFile):
126        """setImageFile(string, string) -> None
127
128        Sets the image file of the poi.
129        """
130        self._setCmd(tc.VAR_IMAGEFILE, poiID, "s", imageFile)

setImageFile(string, string) -> None

Sets the image file of the poi.

def add( self, poiID, x, y, color, poiType='', layer=0, imgFile='', width=1, height=1, angle=0, icon=''):
132    def add(self, poiID, x, y, color, poiType="", layer=0, imgFile="", width=1, height=1, angle=0, icon=""):
133        """
134        add(string, double, double, (byte, byte, byte, byte), string, integer, string, double, double, double) -> None
135
136        Adds a poi with the given values
137        """
138        self._setCmd(tc.ADD, poiID, "tsciosddds", 9, poiType, color, layer, (x, y), imgFile, width, height, angle, icon)

add(string, double, double, (byte, byte, byte, byte), string, integer, string, double, double, double) -> None

Adds a poi with the given values

def remove(self, poiID, layer=0):
140    def remove(self, poiID, layer=0):
141        """
142        remove(string, integer) -> None
143        Removes the poi with the given poiID
144        """
145        self._setCmd(tc.REMOVE, poiID, "i", layer)

remove(string, integer) -> None Removes the poi with the given poiID

def highlight( self, poiID, color=(255, 0, 0, 255), size=-1, alphaMax=-1, duration=-1, type=0):
147    def highlight(self, poiID, color=(255, 0, 0, 255), size=-1, alphaMax=-1, duration=-1, type=0):
148        """ highlight(string, color, float, ubyte) -> void
149            Adds a circle of the given color highlighting the poi.
150            If a positive size [in m] is given the size of the highlight is chosen accordingly,
151            otherwise the image size of the poi is used as reference.
152            If alphaMax and duration are positive, the circle fades in and out within the given duration,
153            otherwise it is permanently added on top of the poi.
154        """
155        if type > 255:
156            raise TraCIException("poi.highlight(): maximal value for type is 255")
157        if alphaMax > 255:
158            raise TraCIException("poi.highlight(): maximal value for alphaMax is 255")
159        if alphaMax <= 0 and duration > 0:
160            raise TraCIException("poi.highlight(): duration>0 requires alphaMax>0")
161        if alphaMax > 0 and duration <= 0:
162            raise TraCIException("poi.highlight(): alphaMax>0 requires duration>0")
163        if alphaMax > 0:
164            self._setCmd(tc.VAR_HIGHLIGHT, poiID, "tcdBdB", 5, color, size, alphaMax, duration, type)
165        else:
166            self._setCmd(tc.VAR_HIGHLIGHT, poiID, "tcd", 2, color, size)

highlight(string, color, float, ubyte) -> void Adds a circle of the given color highlighting the poi. If a positive size [in m] is given the size of the highlight is chosen accordingly, otherwise the image size of the poi is used as reference. If alphaMax and duration are positive, the circle fades in and out within the given duration, otherwise it is permanently added on top of the poi.