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-2020 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 <config.h>
22 
23 #include <string>
24 #include <vector>
25 #include <libsumo/TraCIDefs.h>
26 #include <libsumo/TraCIConstants.h>
27 
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 class NamedRTree;
33 class SUMOPolygon;
34 class SUMOTrafficObject;
35 class NamedRTree;
36 namespace libsumo {
37 class VariableWrapper;
38 }
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
44 namespace libsumo {
45 class Polygon {
46 public:
47  static std::string getType(const std::string& polygonID);
48  static TraCIPositionVector getShape(const std::string& polygonID);
49  static TraCIColor getColor(const std::string& polygonID);
50  static bool getFilled(const std::string& polygonID);
51  static double getLineWidth(const std::string& polygonID);
52 
55 
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& color);
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 
67  // currently only used as a Helper function by POI and Vehicle, not part of the public API (and the clients)
68  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);
69 
73  static NamedRTree* getTree();
74  static void cleanup();
75 
80  static void storeShape(const std::string& id, PositionVector& shape);
81 
82  static std::shared_ptr<VariableWrapper> makeWrapper();
83 
84  static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper);
85 
87  static bool exists(std::string polyID);
88 
89 private:
90  static SUMOPolygon* getPolygon(const std::string& id);
93  static SUMOTrafficObject* getTrafficObject(const std::string& id);
94 
95 
96 private:
99  static NamedRTree* myTree;
100 
102  Polygon() = delete;
103 };
104 
105 
106 }
#define LIBSUMO_ID_PARAMETER_API
Definition: TraCIDefs.h:97
#define LIBSUMO_SUBSCRIPTION_API
Definition: TraCIDefs.h:44
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:60
A list of positions.
Representation of a vehicle, person, or container.
static bool getFilled(const std::string &polygonID)
Definition: Polygon.cpp:76
static NamedRTree * myTree
Definition: Polygon.h:99
static void setShape(const std::string &polygonID, const TraCIPositionVector &shape)
Definition: Polygon.cpp:109
static void setLineWidth(std::string polygonID, double lineWidth)
Definition: Polygon.cpp:219
static double getLineWidth(const std::string &polygonID)
Definition: Polygon.cpp:81
static SUMOTrafficObject * getTrafficObject(const std::string &id)
Obtain a traffic object with the given id if one exists.
Definition: Polygon.cpp:236
static std::string getType(const std::string &polygonID)
Definition: Polygon.cpp:63
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
Definition: Polygon.cpp:266
static SUMOPolygon * getPolygon(const std::string &id)
Definition: Polygon.cpp:226
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:149
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)
Definition: Polygon.cpp:142
static TraCIColor getColor(const std::string &polygonID)
Definition: Polygon.cpp:86
static void setColor(const std::string &polygonID, const TraCIColor &color)
Definition: Polygon.cpp:118
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
Definition: Polygon.cpp:287
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:124
static void remove(const std::string &polygonID, int layer=0)
Definition: Polygon.cpp:194
static TraCIPositionVector getShape(const std::string &polygonID)
Definition: Polygon.cpp:69
static ContextSubscriptionResults myContextSubscriptionResults
Definition: Polygon.h:98
static void setFilled(std::string polygonID, bool filled)
Definition: Polygon.cpp:213
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
Definition: Polygon.cpp:299
static bool exists(std::string polyID)
Checks if a polygon of the given name exists already in the simulation.
Definition: Polygon.cpp:320
Polygon()=delete
invalidated standard constructor
LIBSUMO_ID_PARAMETER_API static LIBSUMO_SUBSCRIPTION_API void setType(const std::string &polygonID, const std::string &setType)
Definition: Polygon.cpp:102
static std::shared_ptr< VariableWrapper > makeWrapper()
Definition: Polygon.cpp:293
static SubscriptionResults mySubscriptionResults
Definition: Polygon.h:97
static void cleanup()
Definition: Polygon.cpp:281
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIDefs.h:196
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:250
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:251