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