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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // C++ TraCI client API implementation
16 /****************************************************************************/
17 #ifndef SUMO_Polygon_H
18 #define SUMO_Polygon_H
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <string>
27 #include <vector>
28 #include <libsumo/TraCIDefs.h>
29 #include <libsumo/TraCIConstants.h>
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class NamedRTree;
36 class SUMOPolygon;
37 class SUMOTrafficObject;
38 namespace libsumo {
39 class VariableWrapper;
40 }
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
46 namespace libsumo {
47 class Polygon {
48 public:
49  static std::vector<std::string> getIDList();
50  static int getIDCount();
51  static std::string getType(const std::string& polygonID);
52  static TraCIPositionVector getShape(const std::string& polygonID);
53  static TraCIColor getColor(const std::string& polygonID);
54  static bool getFilled(const std::string& polygonID);
55  static double getLineWidth(const std::string& polygonID);
56  static std::string getParameter(const std::string& polygonID, const std::string& key);
57  static void setType(const std::string& polygonID, const std::string& setType);
58  static void setShape(const std::string& polygonID, const TraCIPositionVector& shape);
59  static void setColor(const std::string& polygonID, const TraCIColor& c);
60  static void add(const std::string& polygonID, const TraCIPositionVector& shape, const TraCIColor& color, bool fill = false, const std::string& polygonType = "", int layer = 0, double lineWidth = 1);
61 
62  static void addDynamics(const std::string& polygonID, const std::string& trackedID = "", const std::vector<double>& timeSpan = std::vector<double>(), const std::vector<double>& alphaSpan = std::vector<double>(), bool looped = false, bool rotate = true);
63  static void remove(const std::string& polygonID, int layer = 0);
64 
65  static void setFilled(std::string polygonID, bool filled);
66  static void setLineWidth(std::string polygonID, double lineWidth);
67  static void setParameter(const std::string& polygonID, const std::string& key, const std::string& value);
68 
70 
71  // currently only used as a Helper function by POI and Vehicle, not part of the public API (and the clients)
72  static void addHighlightPolygon(const std::string& objectID, const int type, const std::string& polygonID, const TraCIPositionVector& shape, const TraCIColor& color, bool fill, const std::string& polygonType, int layer, double lineWidth);
73 
77  static NamedRTree* getTree();
78 
83  static void storeShape(const std::string& id, PositionVector& shape);
84 
85  static std::shared_ptr<VariableWrapper> makeWrapper();
86 
87  static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper);
88 
90  static bool exists(std::string polyID);
91 
92 private:
93  static SUMOPolygon* getPolygon(const std::string& id);
96  static SUMOTrafficObject* getTrafficObject(const std::string& id);
97 
98 private:
101 
103  Polygon() = delete;
104 };
105 
106 
107 }
108 
109 
110 #endif //SUMO_Polygon_H
111 
112 /****************************************************************************/
static void setColor(const std::string &polygonID, const TraCIColor &c)
Definition: Polygon.cpp:116
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:204
static void setLineWidth(std::string polygonID, double lineWidth)
Definition: Polygon.cpp:201
#define LIBSUMO_SUBSCRIPTION_API
Definition: TraCIDefs.h:42
static std::string getParameter(const std::string &polygonID, const std::string &key)
Definition: Polygon.cpp:94
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
Definition: Polygon.cpp:262
static SubscriptionResults mySubscriptionResults
Definition: Polygon.h:99
A RT-tree for efficient storing of SUMO&#39;s Named objects.
Definition: NamedRTree.h:64
Polygon()=delete
invalidated standard constructor
static void setFilled(std::string polygonID, bool filled)
Definition: Polygon.cpp:195
static SUMOTrafficObject * getTrafficObject(const std::string &id)
Obtain a traffic object with the given id if one exists.
Definition: Polygon.cpp:218
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:205
static std::string getType(const std::string &polygonID)
Definition: Polygon.cpp:64
static bool exists(std::string polyID)
Checks if a polygon of the given name exists already in the simulation.
Definition: Polygon.cpp:295
static void add(const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &color, bool fill=false, const std::string &polygonType="", int layer=0, double lineWidth=1)
Definition: Polygon.cpp:122
static LIBSUMO_SUBSCRIPTION_API void addHighlightPolygon(const std::string &objectID, const int type, const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &color, bool fill, const std::string &polygonType, int layer, double lineWidth)
Definition: Polygon.cpp:133
A list of positions.
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
Definition: Polygon.cpp:248
static TraCIPositionVector getShape(const std::string &polygonID)
Definition: Polygon.cpp:70
static void setShape(const std::string &polygonID, const TraCIPositionVector &shape)
Definition: Polygon.cpp:107
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Polygon.cpp:268
Definition: Edge.cpp:30
static std::vector< std::string > getIDList()
Definition: Polygon.cpp:49
Representation of a vehicle or person.
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Polygon.cpp:274
static TraCIColor getColor(const std::string &polygonID)
Definition: Polygon.cpp:87
static bool getFilled(const std::string &polygonID)
Definition: Polygon.cpp:77
static SUMOPolygon * getPolygon(const std::string &id)
Definition: Polygon.cpp:208
static void addDynamics(const std::string &polygonID, const std::string &trackedID="", const std::vector< double > &timeSpan=std::vector< double >(), const std::vector< double > &alphaSpan=std::vector< double >(), bool looped=false, bool rotate=true)
Definition: Polygon.cpp:140
static void setParameter(const std::string &polygonID, const std::string &key, const std::string &value)
Definition: Polygon.cpp:238
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Polygon.h:100
static int getIDCount()
Definition: Polygon.cpp:58
A list of positions.
static void setType(const std::string &polygonID, const std::string &setType)
Definition: Polygon.cpp:100
static double getLineWidth(const std::string &polygonID)
Definition: Polygon.cpp:82