Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNEMultiEntryExitDetector.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 GNEMultiEntryExitDetector.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Nov 2015
17
///
18
// multi entry-exit (E3) detector
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include "GNEAdditional.h"
24
25
// ===========================================================================
26
// class definitions
27
// ===========================================================================
28
29
class GNEMultiEntryExitDetector : public GNEAdditional, public Parameterised {
30
31
public:
32
/// @brief default constructor
33
GNEMultiEntryExitDetector(GNENet* net);
34
35
/**@brief GNEMultiEntryExitDetector Constructor
36
* @param[in] id The name of the multi entry exit detector
37
* @param[in] net net in which this polygon is placed
38
* @param[in] filename file in which this element is stored
39
* @param[in] pos position (center) of the detector in the map
40
* @param[in] freq the aggregation period the values the detector collects shall be summed up.
41
* @param[in] outputFilename The path to the output file
42
* @param[in] vehicleTypes space separated list of vehicle type ids to consider
43
* @param[in] nextEdges list of edge ids that must all be part of the future route of the vehicle to qualify for detection
44
* @param[in] detectPersons detect persons instead of vehicles (pedestrians or passengers)
45
* @param[in] name E3 detector name
46
* @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting
47
* @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting
48
* @param[in] openEntry enable or disable open Entry
49
* @param[in] expectedArrival Whether no warning should be issued when a vehicle arrives within the detector area
50
* @param[in] parameters generic parameters
51
*/
52
GNEMultiEntryExitDetector(const std::string& id, GNENet* net, const std::string& filename, const Position pos, const SUMOTime freq, const std::string& outputFilename,
53
const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges, const std::string& detectPersons,
54
const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const bool openEntry,
55
const bool expectedArrival, const Parameterised::Map& parameters);
56
57
/// @brief GNEMultiEntryExitDetector Destructor
58
~GNEMultiEntryExitDetector();
59
60
/**@brief get move operation
61
* @note returned GNEMoveOperation can be nullptr
62
*/
63
GNEMoveOperation* getMoveOperation();
64
65
/// @name members and functions relative to write additionals into XML
66
/// @{
67
68
/**@brief write additional element into a xml file
69
* @param[in] device device in which write parameters of additional element
70
*/
71
void writeAdditional(OutputDevice& device) const;
72
73
/// @brief check if current additional is valid to be written into XML (must be reimplemented in all detector children)
74
bool isAdditionalValid() const;
75
76
/// @brief return a string with the current additional problem (must be reimplemented in all detector children)
77
std::string getAdditionalProblem() const;
78
79
/// @brief fix additional problem (must be reimplemented in all detector children)
80
void fixAdditionalProblem();
81
82
/// @}
83
84
/// @name Function related with contour drawing
85
/// @{
86
87
/// @brief check if draw move contour (red)
88
bool checkDrawMoveContour() const;
89
90
/// @}
91
92
/// @name Functions related with geometry of element
93
/// @{
94
95
/// @brief update pre-computed geometry information
96
void updateGeometry();
97
98
/// @brief Returns position of additional in view
99
Position getPositionInView() const;
100
101
/// @brief update centering boundary (implies change in RTREE)
102
void updateCenteringBoundary(const bool updateGrid);
103
104
/// @brief split geometry
105
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
106
107
/// @}
108
109
/// @name inherited from GUIGlObject
110
/// @{
111
112
/// @brief Returns the name of the parent object
113
/// @return This object's parent id
114
std::string getParentName() const;
115
116
/**@brief Draws the object
117
* @param[in] s The settings for the current view (may influence drawing)
118
* @see GUIGlObject::drawGL
119
*/
120
void drawGL(const GUIVisualizationSettings& s) const;
121
122
/// @}
123
124
/// @name inherited from GNEAttributeCarrier
125
/// @{
126
127
/* @brief method for getting the Attribute of an XML key
128
* @param[in] key The attribute key
129
* @return string with the value associated to key
130
*/
131
std::string getAttribute(SumoXMLAttr key) const;
132
133
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
134
* @param[in] key The attribute key
135
* @return double with the value associated to key
136
*/
137
double getAttributeDouble(SumoXMLAttr key) const;
138
139
/// @brief get parameters map
140
const Parameterised::Map& getACParametersMap() const;
141
142
/* @brief method for setting the attribute and letting the object perform additional changes
143
* @param[in] key The attribute key
144
* @param[in] value The new value
145
* @param[in] undoList The undoList on which to register changes
146
*/
147
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
148
149
/* @brief method for checking if the key and their conrrespond attribute are valids
150
* @param[in] key The attribute key
151
* @param[in] value The value associated to key key
152
* @return true if the value is valid, false in other case
153
*/
154
bool isValid(SumoXMLAttr key, const std::string& value);
155
156
/// @brief get PopPup ID (Used in AC Hierarchy)
157
std::string getPopUpID() const;
158
159
/// @brief get Hierarchy Name (Used in AC Hierarchy)
160
std::string getHierarchyName() const;
161
162
/// @}
163
164
protected:
165
/// @brief position of E3 in view
166
Position myPosition;
167
168
/// @brief period of E3 detector
169
SUMOTime myPeriod = 0;
170
171
/// @brief fielname of E3 detector
172
std::string myOutputFilename;
173
174
/// @brief attribute vehicle types
175
std::vector<std::string> myVehicleTypes;
176
177
/// @brief next edges
178
std::vector<std::string> myNextEdges;
179
180
/// @brief detect persons
181
std::string myDetectPersons;
182
183
/// @brief The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting
184
SUMOTime myTimeThreshold = 0;
185
186
/// @brief The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting
187
double mySpeedThreshold = 0;
188
189
/// @brie open entry
190
bool myOpenEntry = false;
191
192
/// @brief flag for enable/disable expected arrival
193
bool myExpectedArrival = false;
194
195
private:
196
/// @brief check restriction with the number of children
197
bool checkChildAdditionalRestriction() const;
198
199
/// @brief set attribute after validation
200
void setAttribute(SumoXMLAttr key, const std::string& value);
201
202
/// @brief set move shape
203
void setMoveShape(const GNEMoveResult& moveResult);
204
205
/// @brief commit move shape
206
void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
207
208
/// @brief Invalidated copy constructor.
209
GNEMultiEntryExitDetector(const GNEMultiEntryExitDetector&) = delete;
210
211
/// @brief Invalidated assignment operator.
212
GNEMultiEntryExitDetector& operator=(const GNEMultiEntryExitDetector&) = delete;
213
};
214
215