Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNELaneAreaDetector.h
193969 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 GNELaneAreaDetector.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Nov 2015
17
///
18
//
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/elements/moving/GNEMoveElementLaneDouble.h>
24
25
#include "GNEDetector.h"
26
27
// ===========================================================================
28
// class declaration
29
// ===========================================================================
30
31
class GNEMoveElementLaneDouble;
32
33
// ===========================================================================
34
// class definitions
35
// ===========================================================================
36
37
class GNELaneAreaDetector : public GNEDetector {
38
39
public:
40
/// @brief default Constructor
41
GNELaneAreaDetector(SumoXMLTag tag, GNENet* net);
42
43
/**@brief Constructor for Single-Lane E2 detectors
44
* @param[in] id The storage of gl-ids to get the one for this lane representation from
45
* @param[in] net pointer to GNENet of this additional element belongs
46
* @param[in] fileBucket file in which this element is stored
47
* @param[in] lane Lane of this StoppingPlace belongs
48
* @param[in] pos position of the detector on the lane
49
* @param[in] length The length of the detector in meters.
50
* @param[in] freq the aggregation period the values the detector collects shall be summed up.
51
* @param[in] trafficLight The traffic light that triggers aggregation when switching.
52
* @param[in] filename The path to the output file.
53
* @param[in] vehicleTypes space separated list of vehicle type ids to consider
54
* @param[in] nextEdges list of edge ids that must all be part of the future route of the vehicle to qualify for detection
55
* @param[in] detectPersons detect persons instead of vehicles (pedestrians or passengers)
56
* @param[in] name E2 detector name
57
* @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting
58
* @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting
59
* @param[in] speedThreshold The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam
60
* @param[in] friendlyPos enable or disable friendly positions
61
* @param[in] show detector in sumo-gui
62
* @param[in] parameters generic parameters
63
*/
64
GNELaneAreaDetector(const std::string& id, GNENet* net, FileBucket* fileBucket, GNELane* lane, const double pos, const double length,
65
const SUMOTime freq, const std::string& trafficLight, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes,
66
const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,
67
const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,
68
const bool show, const Parameterised::Map& parameters);
69
70
/**@brief Constructor for Multi-Lane detectors
71
* @param[in] id The storage of gl-ids to get the one for this lane representation from
72
* @param[in] net pointer to GNENet of this additional element belongs
73
* @param[in] fileBucket file in which this element is stored
74
* @param[in] lanes vector of lanes Lane of this StoppingPlace belongs
75
* @param[in] pos position of the detector on the first lane
76
* @param[in] endPos position of the detector on the last lane
77
* @param[in] freq the aggregation period the values the detector collects shall be summed up.
78
* @param[in] trafficLight The traffic light that triggers aggregation when switching.
79
* @param[in] filename The path to the output file.
80
* @param[in] vehicleTypes space separated list of vehicle type ids to consider
81
* @param[in] nextEdges list of edge ids that must all be part of the future route of the vehicle to qualify for detection
82
* @param[in] detectPersons detect persons instead of vehicles (pedestrians or passengers)
83
* @param[in] name E2 detector name
84
* @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting
85
* @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting
86
* @param[in] speedThreshold The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam
87
* @param[in] friendlyPos enable or disable friendly positions
88
* @param[in] show detector in sumo-gui
89
* @param[in] parameters generic parameters
90
*/
91
GNELaneAreaDetector(const std::string& id, GNENet* net, FileBucket* fileBucket, std::vector<GNELane*> lanes, const double pos, const double endPos,
92
const SUMOTime freq, const std::string& trafficLight, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes,
93
const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,
94
const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,
95
const bool show, const Parameterised::Map& parameters);
96
97
/// @brief Destructor
98
~GNELaneAreaDetector();
99
100
/// @brief methods to retrieve the elements linked to this GNEAdditional
101
/// @{
102
103
/// @brief get GNEMoveElement associated with this GNEAdditional
104
GNEMoveElement* getMoveElement() const override;
105
106
/// @brief get parameters associated with this GNEAdditional
107
Parameterised* getParameters() override;
108
109
/// @}
110
111
/// @name members and functions relative to write additionals into XML
112
/// @{
113
114
/**@brief write additional element into a xml file
115
* @param[in] device device in which write parameters of additional element
116
*/
117
void writeAdditional(OutputDevice& device) const override;
118
119
/// @brief check if current additional is valid to be written into XML
120
bool isAdditionalValid() const override;
121
122
/// @brief return a string with the current additional problem
123
std::string getAdditionalProblem() const override;
124
125
/// @brief fix additional problem
126
void fixAdditionalProblem() override;
127
128
/// @}
129
130
/// @brief update pre-computed geometry information
131
void updateGeometry() override;
132
133
/// @name inherited from GUIGlObject
134
/// @{
135
136
/**@brief Draws the object
137
* @param[in] s The settings for the current view (may influence drawing)
138
* @see GUIGlObject::drawGL
139
*/
140
void drawGL(const GUIVisualizationSettings& s) const override;
141
142
/// @}
143
144
/// @name inherited from GNEPathElement
145
/// @{
146
147
/// @brief compute pathElement
148
void computePathElement() override;
149
150
/**@brief Draws partial object over lane
151
* @param[in] s The settings for the current view (may influence drawing)
152
* @param[in] segment lane segment
153
* @param[in] offsetFront front offset
154
*/
155
void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
156
157
/**@brief Draws partial object over junction
158
* @param[in] s The settings for the current view (may influence drawing)
159
* @param[in] segment junction segment
160
* @param[in] offsetFront front offset
161
*/
162
void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;
163
164
/// @}
165
166
/// @name inherited from GNEAttributeCarrier
167
/// @{
168
169
/* @brief method for getting the Attribute of an XML key
170
* @param[in] key The attribute key
171
* @return string with the value associated to key
172
*/
173
std::string getAttribute(SumoXMLAttr key) const override;
174
175
/* @brief method for getting the Attribute of an XML key in double format
176
* @param[in] key The attribute key
177
* @return double with the value associated to key
178
*/
179
double getAttributeDouble(SumoXMLAttr key) const override;
180
181
/* @brief method for getting the Attribute of an XML key in position format
182
* @param[in] key The attribute key
183
* @return position with the value associated to key
184
*/
185
Position getAttributePosition(SumoXMLAttr key) const override;
186
187
/* @brief method for getting the Attribute of an XML key in positionVector format
188
* @param[in] key The attribute key
189
* @return positionVector with the value associated to key
190
*/
191
PositionVector getAttributePositionVector(SumoXMLAttr key) const override;
192
193
/* @brief method for setting the attribute and letting the object perform additional changes
194
* @param[in] key The attribute key
195
* @param[in] value The new value
196
* @param[in] undoList The undoList on which to register changes
197
*/
198
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
199
200
/* @brief method for checking if the key and their correspond attribute are valids
201
* @param[in] key The attribute key
202
* @param[in] value The value associated to key key
203
* @return true if the value is valid, false in other case
204
*/
205
bool isValid(SumoXMLAttr key, const std::string& value) override;
206
207
/// @}
208
209
protected:
210
/// @brief The start position over lane
211
double myStartPosOverLane = 0;
212
213
/// @brief The end position over lane
214
double myEndPosPosOverLane = 0;
215
216
/// @brief Flag for friendly position
217
bool myFriendlyPosition = false;
218
219
/// @brief The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting
220
SUMOTime myTimeThreshold = 0;
221
222
/// @brief The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting
223
double mySpeedThreshold = 0;
224
225
/// @brief The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam
226
double myJamThreshold = 0;
227
228
/// @brief Traffic light vinculated with this E2 Detector
229
std::string myTrafficLight;
230
231
/// @brief show or hidde detector in sumo-gui
232
bool myShow = true;
233
234
/// @brief move element lane double
235
GNEMoveElementLaneDouble* myMoveElementLaneDouble = nullptr;
236
237
private:
238
/// @brief draw E2 detector
239
void drawE2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
240
const double exaggeration, const bool drawGeometryPoints) const;
241
242
/// @brief draw E2 partial lane
243
void drawE2PartialLane(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
244
const GNESegment* segment, const double offsetFront,
245
const GUIGeometry& geometry, const double exaggeration, const bool movingGeometryPoints) const;
246
247
/// @brief draw E2 partial junction
248
void drawE2PartialJunction(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
249
const bool onlyContour, const double offsetFront, const GUIGeometry& geometry,
250
const double exaggeration) const;
251
252
/// @brief set attribute after validation
253
void setAttribute(SumoXMLAttr key, const std::string& value) override;
254
255
/// @brief Invalidated copy constructor.
256
GNELaneAreaDetector(const GNELaneAreaDetector&) = delete;
257
258
/// @brief Invalidated assignment operator.
259
GNELaneAreaDetector& operator=(const GNELaneAreaDetector&) = delete;
260
};
261
262