Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2017-2026 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 : /****************************************************************************/
14 : /// @file Polygon.h
15 : /// @author Gregor Laemmel
16 : /// @date 15.03.2017
17 : ///
18 : // C++ TraCI client API implementation
19 : /****************************************************************************/
20 : #pragma once
21 : #include <string>
22 : #include <vector>
23 : #include <libsumo/TraCIDefs.h>
24 : #include <libsumo/TraCIConstants.h>
25 :
26 :
27 : // ===========================================================================
28 : // class declarations
29 : // ===========================================================================
30 : #ifndef LIBTRACI
31 : class NamedRTree;
32 : class PositionVector;
33 : class SUMOPolygon;
34 : class SUMOTrafficObject;
35 : #endif
36 :
37 :
38 : // ===========================================================================
39 : // class definitions
40 : // ===========================================================================
41 : namespace LIBSUMO_NAMESPACE {
42 : class Polygon {
43 : public:
44 : static std::string getType(const std::string& polygonID);
45 : static libsumo::TraCIPositionVector getShape(const std::string& polygonID);
46 : static libsumo::TraCIColor getColor(const std::string& polygonID);
47 : static bool getFilled(const std::string& polygonID);
48 : static double getLineWidth(const std::string& polygonID);
49 : static double getHeight(const std::string& polygonID);
50 :
51 : LIBSUMO_ID_PARAMETER_API
52 0 : LIBSUMO_SUBSCRIPTION_API
53 :
54 : static void setType(const std::string& polygonID, const std::string& polygonType);
55 : static void setShape(const std::string& polygonID, const libsumo::TraCIPositionVector& shape);
56 : static void setColor(const std::string& polygonID, const libsumo::TraCIColor& color);
57 : 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);
58 :
59 : 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);
60 : static void remove(const std::string& polygonID, int layer = 0);
61 :
62 : static void setFilled(std::string polygonID, bool filled);
63 : static void setLineWidth(std::string polygonID, double lineWidth);
64 : static void setHeight(std::string polygonID, double height);
65 :
66 : #ifndef LIBTRACI
67 : #ifndef SWIG
68 : // currently only used as a Helper function by POI and Vehicle, not part of the public API (and the clients)
69 : 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);
70 :
71 : /** @brief Returns a tree filled with polygon instances
72 : * @return The rtree of polygons
73 : */
74 : static NamedRTree* getTree();
75 : static void cleanup();
76 :
77 : /** @brief Saves the shape of the requested object in the given container
78 : * @param id The id of the poi to retrieve
79 : * @param shape The container to fill
80 : */
81 : static void storeShape(const std::string& id, PositionVector& shape);
82 :
83 : static std::shared_ptr<VariableWrapper> makeWrapper();
84 :
85 : static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData);
86 :
87 : /// Checks if a polygon of the given name exists already in the simulation
88 : static bool exists(std::string polyID);
89 :
90 : private:
91 : static SUMOPolygon* getPolygon(const std::string& id);
92 : /// @brief Obtain a traffic object with the given id if one exists
93 : /// @return Searches the domains Vehicle and Person for the given id (priorizes vehicles)
94 : static SUMOTrafficObject* getTrafficObject(const std::string& id);
95 :
96 :
97 : private:
98 : static SubscriptionResults mySubscriptionResults;
99 : static ContextSubscriptionResults myContextSubscriptionResults;
100 : static NamedRTree* myTree;
101 : #endif
102 : #endif
103 :
104 : /// @brief invalidated standard constructor
105 : Polygon() = delete;
106 : };
107 :
108 :
109 : }
|