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 /****************************************************************************/
14 // C++ TraCI client API implementation
15 /****************************************************************************/
16 #ifndef SUMO_Polygon_H
17 #define SUMO_Polygon_H
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <string>
26 #include <vector>
27 #include <libsumo/TraCIDefs.h>
28 #include <libsumo/TraCIConstants.h>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class NamedRTree;
35 class SUMOPolygon;
36 class SUMOTrafficObject;
37 namespace libsumo {
38 class VariableWrapper;
39 }
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
45 namespace libsumo {
46 class Polygon {
47 public:
48  static std::vector<std::string> getIDList();
49  static int getIDCount();
50  static std::string getType(const std::string& polygonID);
51  static TraCIPositionVector getShape(const std::string& polygonID);
52  static TraCIColor getColor(const std::string& polygonID);
53  static bool getFilled(const std::string& polygonID);
54  static double getLineWidth(const std::string& polygonID);
55  static std::string getParameter(const std::string& polygonID, const std::string& key);
56  static void setType(const std::string& polygonID, const std::string& setType);
57  static void setShape(const std::string& polygonID, const TraCIPositionVector& shape);
58  static void setColor(const std::string& polygonID, const TraCIColor& c);
59  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);
60 
61  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);
62  static void remove(const std::string& polygonID, int layer = 0);
63 
64  static void setFilled(std::string polygonID, bool filled);
65  static void setLineWidth(std::string polygonID, double lineWidth);
66  static void setParameter(const std::string& polygonID, const std::string& key, const std::string& value);
67 
69 
70  // currently only used as a Helper function by POI and Vehicle, not part of the public API (and the clients)
71  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);
72 
76  static NamedRTree* getTree();
77 
82  static void storeShape(const std::string& id, PositionVector& shape);
83 
84  static std::shared_ptr<VariableWrapper> makeWrapper();
85 
86  static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper);
87 
89  static bool exists(std::string polyID);
90 
91 private:
92  static SUMOPolygon* getPolygon(const std::string& id);
95  static SUMOTrafficObject* getTrafficObject(const std::string& id);
96 
97 private:
100 
102  Polygon() = delete;
103 };
104 
105 
106 }
107 
108 
109 #endif //SUMO_Polygon_H
110 
111 /****************************************************************************/
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
libsumo::Polygon::setColor
static void setColor(const std::string &polygonID, const TraCIColor &c)
Definition: Polygon.cpp:115
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:121
TraCIPositionVector
A list of positions.
LIBSUMO_SUBSCRIPTION_API
#define LIBSUMO_SUBSCRIPTION_API
Definition: TraCIDefs.h:41
libsumo::Polygon::getTree
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
Definition: Polygon.cpp:247
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:139
libsumo::Polygon::getIDList
static std::vector< std::string > getIDList()
Definition: Polygon.cpp:48
libsumo::VariableWrapper
Definition: Subscription.h:132
libsumo::Polygon
Definition: Polygon.h:46
libsumo::Polygon::getPolygon
static SUMOPolygon * getPolygon(const std::string &id)
Definition: Polygon.cpp:207
libsumo::Polygon::getParameter
static std::string getParameter(const std::string &polygonID, const std::string &key)
Definition: Polygon.cpp:93
libsumo::Polygon::remove
static void remove(const std::string &polygonID, int layer=0)
Definition: Polygon.cpp:184
libsumo::ContextSubscriptionResults
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:204
libsumo::TraCIColor
A color.
Definition: TraCIDefs.h:135
PositionVector
A list of positions.
Definition: PositionVector.h:45
libsumo::Polygon::myContextSubscriptionResults
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Polygon.h:99
libsumo::Polygon::getIDCount
static int getIDCount()
Definition: Polygon.cpp:57
libsumo::Polygon::setShape
static void setShape(const std::string &polygonID, const TraCIPositionVector &shape)
Definition: Polygon.cpp:106
libsumo
Definition: Edge.cpp:29
libsumo::Polygon::handleVariable
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Polygon.cpp:273
libsumo::Polygon::getTrafficObject
static SUMOTrafficObject * getTrafficObject(const std::string &id)
Obtain a traffic object with the given id if one exists.
Definition: Polygon.cpp:217
TraCIConstants.h
libsumo::Polygon::getColor
static TraCIColor getColor(const std::string &polygonID)
Definition: Polygon.cpp:86
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:132
libsumo::Polygon::getLineWidth
static double getLineWidth(const std::string &polygonID)
Definition: Polygon.cpp:81
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:261
libsumo::Polygon::setFilled
static void setFilled(std::string polygonID, bool filled)
Definition: Polygon.cpp:194
libsumo::Polygon::getType
static std::string getType(const std::string &polygonID)
Definition: Polygon.cpp:63
SUMOPolygon
Definition: SUMOPolygon.h:46
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:294
libsumo::Polygon::setParameter
static void setParameter(const std::string &polygonID, const std::string &key, const std::string &value)
Definition: Polygon.cpp:237
libsumo::Polygon::setType
static void setType(const std::string &polygonID, const std::string &setType)
Definition: Polygon.cpp:99
libsumo::Polygon::Polygon
Polygon()=delete
invalidated standard constructor
libsumo::Polygon::getShape
static TraCIPositionVector getShape(const std::string &polygonID)
Definition: Polygon.cpp:69
NamedRTree
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:63
libsumo::Polygon::getFilled
static bool getFilled(const std::string &polygonID)
Definition: Polygon.cpp:76
config.h
libsumo::Polygon::makeWrapper
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Polygon.cpp:267
libsumo::Polygon::mySubscriptionResults
static SubscriptionResults mySubscriptionResults
Definition: Polygon.h:98
libsumo::Polygon::setLineWidth
static void setLineWidth(std::string polygonID, double lineWidth)
Definition: Polygon.cpp:200
TraCIDefs.h
libsumo::SubscriptionResults
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:203