Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
libtraci/POI.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2017-2024 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/****************************************************************************/
22// C++ TraCI client API implementation
23/****************************************************************************/
24#include <config.h>
25
26#define LIBTRACI 1
27#include "Domain.h"
28#include <libsumo/POI.h>
30
31
32namespace libtraci {
33
34typedef Domain<libsumo::CMD_GET_POI_VARIABLE, libsumo::CMD_SET_POI_VARIABLE> Dom;
35
36// ===========================================================================
37// static member definitions
38// ===========================================================================
39std::vector<std::string>
40POI::getIDList() {
42}
43
44
45int
46POI::getIDCount() {
48}
49
50
51std::string
52POI::getType(const std::string& poiID) {
53 return Dom::getString(libsumo::VAR_TYPE, poiID);
54}
55
56
58POI::getColor(const std::string& poiID) {
59 return Dom::getCol(libsumo::VAR_COLOR, poiID);
60}
61
62
64POI::getPosition(const std::string& poiID, const bool includeZ) {
66}
67
68
69double
70POI::getWidth(const std::string& poiID) {
72}
73
74
75double
76POI::getHeight(const std::string& poiID) {
78}
79
80
81double
82POI::getAngle(const std::string& poiID) {
84}
85
86
87std::string
88POI::getImageFile(const std::string& poiID) {
90}
91
92
94
95
96void
97POI::setType(const std::string& poiID, const std::string& poiType) {
98 Dom::setString(libsumo::VAR_TYPE, poiID, poiType);
99}
100
101
102void
103POI::setPosition(const std::string& poiID, double x, double y) {
104 tcpip::Storage content;
106 content.writeDouble(x);
107 content.writeDouble(y);
108 Dom::set(libsumo::VAR_POSITION, poiID, &content);
109}
110
111
112void
113POI::setColor(const std::string& poiID, const libsumo::TraCIColor& c) {
115}
116
117
118void
119POI::setWidth(const std::string& poiID, double width) {
120 Dom::setDouble(libsumo::VAR_WIDTH, poiID, width);
121}
122
123
124void
125POI::setHeight(const std::string& poiID, double height) {
126 Dom::setDouble(libsumo::VAR_HEIGHT, poiID, height);
127}
128
129
130void
131POI::setAngle(const std::string& poiID, double angle) {
132 Dom::setDouble(libsumo::VAR_ANGLE, poiID, angle);
133}
134
135
136void
137POI::setImageFile(const std::string& poiID, const std::string& imageFile) {
138 Dom::setString(libsumo::VAR_IMAGEFILE, poiID, imageFile);
139}
140
141
142bool
143POI::add(const std::string& poiID, double x, double y, const libsumo::TraCIColor& color, const std::string& poiType,
144 int layer, const std::string& imgFile, double width, double height, double angle, const std::string& icon) {
145 tcpip::Storage content;
146 StoHelp::writeCompound(content, 9);
147 StoHelp::writeTypedString(content, poiType);
149 content.writeUnsignedByte(color.r);
150 content.writeUnsignedByte(color.g);
151 content.writeUnsignedByte(color.b);
152 content.writeUnsignedByte(color.a);
153 StoHelp::writeTypedInt(content, layer);
155 content.writeDouble(x);
156 content.writeDouble(y);
157 StoHelp::writeTypedString(content, imgFile);
158 StoHelp::writeTypedDouble(content, width);
159 StoHelp::writeTypedDouble(content, height);
160 StoHelp::writeTypedDouble(content, angle);
161 StoHelp::writeTypedString(content, icon);
162 Dom::set(libsumo::ADD, poiID, &content);
163 return true;
164}
165
166
167bool
168POI::remove(const std::string& poiID, int layer) {
169 Dom::setInt(libsumo::REMOVE, poiID, layer);
170 return true;
171}
172
173
174void
175POI::highlight(const std::string& poiID, const libsumo::TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
176 tcpip::Storage content;
177 StoHelp::writeCompound(content, alphaMax > 0 ? 5 : 2);
179 content.writeUnsignedByte(col.r);
180 content.writeUnsignedByte(col.g);
181 content.writeUnsignedByte(col.b);
182 content.writeUnsignedByte(col.a);
183 StoHelp::writeTypedDouble(content, size);
184 if (alphaMax > 0) {
186 content.writeUnsignedByte(alphaMax);
187 StoHelp::writeTypedDouble(content, duration);
189 content.writeUnsignedByte(type);
190 }
191 Dom::set(libsumo::VAR_HIGHLIGHT, poiID, &content);
192}
193
194
196
197
198}
199
200
201/****************************************************************************/
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition Domain.h:38
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
Definition Domain.h:77
C++ TraCI client API implementation.
static void writeTypedDouble(tcpip::Storage &content, double value)
static void writeCompound(tcpip::Storage &content, int size)
static void writeTypedInt(tcpip::Storage &content, int value)
static void writeTypedString(tcpip::Storage &content, const std::string &value)
static void setDouble(int var, const std::string &id, double value)
Definition Domain.h:231
static libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
Definition Domain.h:153
static void setCol(int var, const std::string &id, const libsumo::TraCIColor value)
Definition Domain.h:252
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:177
static libsumo::TraCIColor getCol(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:187
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:172
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:125
static void set(int var, const std::string &id, tcpip::Storage *add)
Definition Domain.h:219
static libsumo::TraCIPosition getPos3D(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
Definition Domain.h:162
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:130
static void setInt(int var, const std::string &id, int value)
Definition Domain.h:224
static void setString(int var, const std::string &id, const std::string &value)
Definition Domain.h:238
virtual void writeDouble(double)
Definition storage.cpp:354
virtual void writeUnsignedByte(int)
Definition storage.cpp:165
TRACI_CONST int TYPE_COLOR
TRACI_CONST int VAR_IMAGEFILE
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_TYPE
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_HIGHLIGHT
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_POSITION
TRACI_CONST int VAR_WIDTH
TRACI_CONST int POSITION_2D
TRACI_CONST int ID_COUNT
TRACI_CONST int REMOVE
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int ADD
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
Definition TraCIDefs.h:178