Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNEDetector.h
194645 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-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 GNEDetector.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Nov 2015
17
///
18
// A abstract class to define common parameters of detectors placed over lanes
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include "GNEAdditional.h"
24
25
// ===========================================================================
26
// class definitions
27
// ===========================================================================
28
29
class GNEDetector : public GNEAdditional, public Parameterised {
30
31
public:
32
/**@brief Default constructor
33
* @param[in] net pointer to GNENet of this additional element belongs
34
* @param[in] tag Type of xml tag that define the detector (SUMO_TAG_INDUCTION_LOOP, SUMO_TAG_LANE_AREA_DETECTOR, etc...)
35
*/
36
GNEDetector(GNENet* net, SumoXMLTag tag);
37
38
/**@brief Constructor
39
* @param[in] id Gl-id of the detector (Must be unique)
40
* @param[in] net pointer to GNENet of this additional element belongs
41
* @param[in] fileBucket file in which this element is stored
42
* @param[in] tag Type of xml tag that define the detector (SUMO_TAG_INDUCTION_LOOP, SUMO_TAG_LANE_AREA_DETECTOR, etc...)
43
* @param[in] period the aggregation period the values the detector collects shall be summed up.
44
* @param[in] vehicleTypes space separated list of vehicle type ids to consider
45
* @param[in] nextEdges list of edge ids that must all be part of the future route of the vehicle to qualify for detection
46
* @param[in] detectPersons detect persons instead of vehicles (pedestrians or passengers)
47
* @param[in] outputFilename The path to the output file.
48
* @param[in] name detector name
49
* @param[in] parameters generic parameters
50
*/
51
GNEDetector(const std::string& id, GNENet* net, FileBucket* fileBucket, SumoXMLTag tag, const SUMOTime period,
52
const std::string& outputFilename, const std::vector<std::string>& vehicleTypes,
53
const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,
54
const Parameterised::Map& parameters);
55
56
/**@brief Constructor
57
* @param[in] additionalParent parent additional of this detector (ID will be generated automatically)
58
* @param[in] tag Type of xml tag that define the detector (SUMO_TAG_INDUCTION_LOOP, SUMO_TAG_LANE_AREA_DETECTOR, etc...)
59
* @param[in] pos position of the detector on the lane
60
* @param[in] period the aggregation period the values the detector collects shall be summed up.
61
* @param[in] parentLanes vector of parent lanes
62
* @param[in] outputFilename The path to the output file.
63
* @param[in] name detector name
64
* @param[in] parameters generic parameters
65
*/
66
GNEDetector(GNEAdditional* additionalParent, SumoXMLTag tag, const SUMOTime period, const std::string& outputFilename,
67
const std::string& name, const Parameterised::Map& parameters);
68
69
/// @brief Destructor
70
~GNEDetector();
71
72
/// @brief methods to retrieve the elements linked to this detector
73
/// @{
74
75
/// @brief get parameters associated with this detector
76
Parameterised* getParameters() override;
77
78
/// @brief get parameters associated with this detector (constant)
79
const Parameterised* getParameters() const override;
80
81
/// @}
82
83
/// @name Function related with contour drawing
84
/// @{
85
86
/// @brief check if draw move contour (red)
87
bool checkDrawMoveContour() const override;
88
89
/// @}
90
91
/// @name Functions related with geometry of element
92
/// @{
93
94
/// @brief Returns position of additional in view
95
Position getPositionInView() const override;
96
97
/// @brief update centering boundary (implies change in RTREE)
98
void updateCenteringBoundary(const bool updateGrid) override;
99
100
/// @brief split geometry
101
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;
102
103
/// @}
104
105
/// @name inherited from GUIGLObject
106
/// @{
107
108
/**@brief Returns the name of the parent object
109
* @return This object's parent id
110
*/
111
std::string getParentName() const override;
112
113
/// @}
114
115
/// @name inherited from GNEAttributeCarrier
116
/// @{
117
118
/* @brief method for getting the Attribute of an XML key in positionVector format
119
* @param[in] key The attribute key
120
* @return positionVector with the value associated to key
121
*/
122
PositionVector getAttributePositionVector(SumoXMLAttr key) const override;
123
124
/// @brief get PopPup ID (Used in AC Hierarchy)
125
std::string getPopUpID() const override;
126
127
/// @brief get Hierarchy Name (Used in AC Hierarchy)
128
std::string getHierarchyName() const override;
129
130
/// @}
131
132
protected:
133
/// @brief The aggregation period the values the detector collects shall be summed up.
134
SUMOTime myPeriod = 0;
135
136
/// @brief The path to the output file
137
std::string myOutputFilename;
138
139
/// @brief attribute vehicle types
140
std::vector<std::string> myVehicleTypes;
141
142
/// @brief next edges
143
std::vector<std::string> myNextEdges;
144
145
/// @brief detect persons
146
std::string myDetectPersons;
147
148
/* @brief method for getting the Attribute of an XML key
149
* @param[in] key The attribute key
150
* @return string with the value associated to key
151
*/
152
std::string getDetectorAttribute(SumoXMLAttr key) const;
153
154
/* @brief method for getting the Attribute of an XML key in double format
155
* @param[in] key The attribute key
156
* @return double with the value associated to key
157
*/
158
double getDetectorAttributeDouble(SumoXMLAttr key) const;
159
160
/* @brief method for getting the Attribute of an XML key in position format
161
* @param[in] key The attribute key
162
* @return position with the value associated to key
163
*/
164
Position getDetectorAttributePosition(SumoXMLAttr key) const;
165
166
/* @brief method for setting the attribute and letting the object perform additional changes
167
* @param[in] key The attribute key
168
* @param[in] value The new value
169
* @param[in] undoList The undoList on which to register changes
170
*/
171
void setDetectorAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
172
173
/* @brief method for checking if the key and their conrrespond attribute are valids
174
* @param[in] key The attribute key
175
* @param[in] value The value associated to key key
176
* @return true if the value is valid, false in other case
177
*/
178
bool isDetectorValid(SumoXMLAttr key, const std::string& value);
179
180
/**@brief write additional element into a xml file
181
* @param[in] device device in which write parameters of additional element
182
*/
183
void writeDetectorValues(OutputDevice& device) const;
184
185
/// @brief set attribute after validation
186
void setDetectorAttribute(SumoXMLAttr key, const std::string& value);
187
188
/// @brief draw E1 shape
189
void drawE1Shape(const GUIVisualizationSettings::Detail d, const double exaggeration,
190
const RGBColor& mainColor, const RGBColor& secondColor) const;
191
192
/// @brief draw E1 detector Logo
193
void drawE1DetectorLogo(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
194
const double exaggeration, const std::string& logo, const RGBColor& textColor) const;
195
196
/// @brief draw E2 detector Logo
197
void drawE2DetectorLogo(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
198
const double exaggeration, const std::string& logo, const RGBColor& textColor) const;
199
200
private:
201
/// @brief Invalidate return position of additional
202
const Position& getPosition() const = delete;
203
204
/// @brief Invalidate set new position in the view
205
void setPosition(const Position& pos) = delete;
206
};
207
208