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 /****************************************************************************/
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:48
libsumo::Polygon::setColor
static void setColor(const std::string &polygonID, const TraCIColor &c)
Definition: Polygon.cpp:116
libsumo::Polygon::add
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
TraCIPositionVector
A list of positions.
LIBSUMO_SUBSCRIPTION_API
#define LIBSUMO_SUBSCRIPTION_API
Definition: TraCIDefs.h:42
libsumo::Polygon::getTree
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
Definition: Polygon.cpp:248
libsumo::Polygon::addDynamics
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
libsumo::Polygon::getIDList
static std::vector< std::string > getIDList()
Definition: Polygon.cpp:49
libsumo::VariableWrapper
Definition: Subscription.h:114
libsumo::Polygon
Definition: Polygon.h:47
libsumo::Polygon::getPolygon
static SUMOPolygon * getPolygon(const std::string &id)
Definition: Polygon.cpp:208
libsumo::Polygon::getParameter
static std::string getParameter(const std::string &polygonID, const std::string &key)
Definition: Polygon.cpp:94
libsumo::Polygon::remove
static void remove(const std::string &polygonID, int layer=0)
Definition: Polygon.cpp:185
libsumo::ContextSubscriptionResults
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:205
libsumo::TraCIColor
A color.
Definition: TraCIDefs.h:136
PositionVector
A list of positions.
Definition: PositionVector.h:46
libsumo::Polygon::myContextSubscriptionResults
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Polygon.h:100
libsumo::Polygon::getIDCount
static int getIDCount()
Definition: Polygon.cpp:58
libsumo::Polygon::setShape
static void setShape(const std::string &polygonID, const TraCIPositionVector &shape)
Definition: Polygon.cpp:107
libsumo
Definition: Edge.cpp:30
libsumo::Polygon::handleVariable
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Polygon.cpp:274
libsumo::Polygon::getTrafficObject
static SUMOTrafficObject * getTrafficObject(const std::string &id)
Obtain a traffic object with the given id if one exists.
Definition: Polygon.cpp:218
TraCIConstants.h
libsumo::Polygon::getColor
static TraCIColor getColor(const std::string &polygonID)
Definition: Polygon.cpp:87
libsumo::Polygon::addHighlightPolygon
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
libsumo::Polygon::getLineWidth
static double getLineWidth(const std::string &polygonID)
Definition: Polygon.cpp:82
libsumo::Polygon::storeShape
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
Definition: Polygon.cpp:262
libsumo::Polygon::setFilled
static void setFilled(std::string polygonID, bool filled)
Definition: Polygon.cpp:195
libsumo::Polygon::getType
static std::string getType(const std::string &polygonID)
Definition: Polygon.cpp:64
SUMOPolygon
Definition: SUMOPolygon.h:47
libsumo::Polygon::exists
static bool exists(std::string polyID)
Checks if a polygon of the given name exists already in the simulation.
Definition: Polygon.cpp:295
libsumo::Polygon::setParameter
static void setParameter(const std::string &polygonID, const std::string &key, const std::string &value)
Definition: Polygon.cpp:238
libsumo::Polygon::setType
static void setType(const std::string &polygonID, const std::string &setType)
Definition: Polygon.cpp:100
libsumo::Polygon::Polygon
Polygon()=delete
invalidated standard constructor
libsumo::Polygon::getShape
static TraCIPositionVector getShape(const std::string &polygonID)
Definition: Polygon.cpp:70
NamedRTree
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:64
libsumo::Polygon::getFilled
static bool getFilled(const std::string &polygonID)
Definition: Polygon.cpp:77
config.h
libsumo::Polygon::makeWrapper
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Polygon.cpp:268
libsumo::Polygon::mySubscriptionResults
static SubscriptionResults mySubscriptionResults
Definition: Polygon.h:99
libsumo::Polygon::setLineWidth
static void setLineWidth(std::string polygonID, double lineWidth)
Definition: Polygon.cpp:201
TraCIDefs.h
libsumo::SubscriptionResults
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:204