Eclipse SUMO - Simulation of Urban MObility
Polygon.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2017-2023 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/****************************************************************************/
18// C++ TraCI client API implementation
19/****************************************************************************/
20#pragma once
21#include <string>
22#include <vector>
23#include <libsumo/TraCIDefs.h>
25
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
30#ifndef LIBTRACI
31class NamedRTree;
32class SUMOPolygon;
34#endif
35
36
37// ===========================================================================
38// class definitions
39// ===========================================================================
40namespace LIBSUMO_NAMESPACE {
41class Polygon {
42public:
43 static std::string getType(const std::string& polygonID);
44 static libsumo::TraCIPositionVector getShape(const std::string& polygonID);
45 static libsumo::TraCIColor getColor(const std::string& polygonID);
46 static bool getFilled(const std::string& polygonID);
47 static double getLineWidth(const std::string& polygonID);
48
51
52 static void setType(const std::string& polygonID, const std::string& setType);
53 static void setShape(const std::string& polygonID, const libsumo::TraCIPositionVector& shape);
54 static void setColor(const std::string& polygonID, const libsumo::TraCIColor& color);
55 static void add(const std::string& polygonID, const libsumo::TraCIPositionVector& shape, const libsumo::TraCIColor& color, bool fill = false, const std::string& polygonType = "", int layer = 0, double lineWidth = 1);
56
57 static void addDynamics(const std::string& polygonID, const std::string& trackedObjectID = "", const std::vector<double>& timeSpan = std::vector<double>(), const std::vector<double>& alphaSpan = std::vector<double>(), bool looped = false, bool rotate = true);
58 static void remove(const std::string& polygonID, int layer = 0);
59
60 static void setFilled(std::string polygonID, bool filled);
61 static void setLineWidth(std::string polygonID, double lineWidth);
62
63#ifndef LIBTRACI
64#ifndef SWIG
65 // currently only used as a Helper function by POI and Vehicle, not part of the public API (and the clients)
66 static void addHighlightPolygon(const std::string& objectID, const int type, const std::string& polygonID, const libsumo::TraCIPositionVector& shape, const libsumo::TraCIColor& color, bool fill, const std::string& polygonType, int layer, double lineWidth);
67
71 static NamedRTree* getTree();
72 static void cleanup();
73
78 static void storeShape(const std::string& id, PositionVector& shape);
79
80 static std::shared_ptr<VariableWrapper> makeWrapper();
81
82 static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData);
83
85 static bool exists(std::string polyID);
86
87private:
88 static SUMOPolygon* getPolygon(const std::string& id);
91 static SUMOTrafficObject* getTrafficObject(const std::string& id);
92
93
94private:
98#endif
99#endif
100
102 Polygon() = delete;
103};
104
105
106}
#define LIBSUMO_ID_PARAMETER_API
Definition: TraCIDefs.h:116
#define LIBSUMO_SUBSCRIPTION_API
Definition: TraCIDefs.h:62
static bool getFilled(const std::string &polygonID)
static NamedRTree * myTree
Definition: Polygon.h:97
static void setLineWidth(std::string polygonID, double lineWidth)
static double getLineWidth(const std::string &polygonID)
static SUMOTrafficObject * getTrafficObject(const std::string &id)
Obtain a traffic object with the given id if one exists.
static std::string getType(const std::string &polygonID)
static libsumo::TraCIPositionVector getShape(const std::string &polygonID)
static void setColor(const std::string &polygonID, const libsumo::TraCIColor &color)
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
static SUMOPolygon * getPolygon(const std::string &id)
static void addDynamics(const std::string &polygonID, const std::string &trackedObjectID="", const std::vector< double > &timeSpan=std::vector< double >(), const std::vector< double > &alphaSpan=std::vector< double >(), bool looped=false, bool rotate=true)
static void add(const std::string &polygonID, const libsumo::TraCIPositionVector &shape, const libsumo::TraCIColor &color, bool fill=false, const std::string &polygonType="", int layer=0, double lineWidth=1)
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
static libsumo::TraCIColor getColor(const std::string &polygonID)
static void addHighlightPolygon(const std::string &objectID, const int type, const std::string &polygonID, const libsumo::TraCIPositionVector &shape, const libsumo::TraCIColor &color, bool fill, const std::string &polygonType, int layer, double lineWidth)
static void remove(const std::string &polygonID, int layer=0)
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper, tcpip::Storage *paramData)
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Polygon.h:96
static void setFilled(std::string polygonID, bool filled)
static void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape)
static bool exists(std::string polyID)
Checks if a polygon of the given name exists already in the simulation.
Polygon()=delete
invalidated standard constructor
LIBSUMO_ID_PARAMETER_API static LIBSUMO_SUBSCRIPTION_API void setType(const std::string &polygonID, const std::string &setType)
static std::shared_ptr< VariableWrapper > makeWrapper()
static SubscriptionResults mySubscriptionResults
Definition: Polygon.h:95
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:61
A list of positions.
Representation of a vehicle, person, or container.
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:338
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:337
A list of positions.
Definition: TraCIDefs.h:234