Path: blob/main/src/netedit/elements/additional/GNELaneAreaDetector.h
193969 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GNELaneAreaDetector.h14/// @author Pablo Alvarez Lopez15/// @date Nov 201516///17//18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/elements/moving/GNEMoveElementLaneDouble.h>2324#include "GNEDetector.h"2526// ===========================================================================27// class declaration28// ===========================================================================2930class GNEMoveElementLaneDouble;3132// ===========================================================================33// class definitions34// ===========================================================================3536class GNELaneAreaDetector : public GNEDetector {3738public:39/// @brief default Constructor40GNELaneAreaDetector(SumoXMLTag tag, GNENet* net);4142/**@brief Constructor for Single-Lane E2 detectors43* @param[in] id The storage of gl-ids to get the one for this lane representation from44* @param[in] net pointer to GNENet of this additional element belongs45* @param[in] fileBucket file in which this element is stored46* @param[in] lane Lane of this StoppingPlace belongs47* @param[in] pos position of the detector on the lane48* @param[in] length The length of the detector in meters.49* @param[in] freq the aggregation period the values the detector collects shall be summed up.50* @param[in] trafficLight The traffic light that triggers aggregation when switching.51* @param[in] filename The path to the output file.52* @param[in] vehicleTypes space separated list of vehicle type ids to consider53* @param[in] nextEdges list of edge ids that must all be part of the future route of the vehicle to qualify for detection54* @param[in] detectPersons detect persons instead of vehicles (pedestrians or passengers)55* @param[in] name E2 detector name56* @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting57* @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting58* @param[in] speedThreshold The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam59* @param[in] friendlyPos enable or disable friendly positions60* @param[in] show detector in sumo-gui61* @param[in] parameters generic parameters62*/63GNELaneAreaDetector(const std::string& id, GNENet* net, FileBucket* fileBucket, GNELane* lane, const double pos, const double length,64const SUMOTime freq, const std::string& trafficLight, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes,65const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,66const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,67const bool show, const Parameterised::Map& parameters);6869/**@brief Constructor for Multi-Lane detectors70* @param[in] id The storage of gl-ids to get the one for this lane representation from71* @param[in] net pointer to GNENet of this additional element belongs72* @param[in] fileBucket file in which this element is stored73* @param[in] lanes vector of lanes Lane of this StoppingPlace belongs74* @param[in] pos position of the detector on the first lane75* @param[in] endPos position of the detector on the last lane76* @param[in] freq the aggregation period the values the detector collects shall be summed up.77* @param[in] trafficLight The traffic light that triggers aggregation when switching.78* @param[in] filename The path to the output file.79* @param[in] vehicleTypes space separated list of vehicle type ids to consider80* @param[in] nextEdges list of edge ids that must all be part of the future route of the vehicle to qualify for detection81* @param[in] detectPersons detect persons instead of vehicles (pedestrians or passengers)82* @param[in] name E2 detector name83* @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting84* @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting85* @param[in] speedThreshold The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam86* @param[in] friendlyPos enable or disable friendly positions87* @param[in] show detector in sumo-gui88* @param[in] parameters generic parameters89*/90GNELaneAreaDetector(const std::string& id, GNENet* net, FileBucket* fileBucket, std::vector<GNELane*> lanes, const double pos, const double endPos,91const SUMOTime freq, const std::string& trafficLight, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes,92const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,93const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,94const bool show, const Parameterised::Map& parameters);9596/// @brief Destructor97~GNELaneAreaDetector();9899/// @brief methods to retrieve the elements linked to this GNEAdditional100/// @{101102/// @brief get GNEMoveElement associated with this GNEAdditional103GNEMoveElement* getMoveElement() const override;104105/// @brief get parameters associated with this GNEAdditional106Parameterised* getParameters() override;107108/// @}109110/// @name members and functions relative to write additionals into XML111/// @{112113/**@brief write additional element into a xml file114* @param[in] device device in which write parameters of additional element115*/116void writeAdditional(OutputDevice& device) const override;117118/// @brief check if current additional is valid to be written into XML119bool isAdditionalValid() const override;120121/// @brief return a string with the current additional problem122std::string getAdditionalProblem() const override;123124/// @brief fix additional problem125void fixAdditionalProblem() override;126127/// @}128129/// @brief update pre-computed geometry information130void updateGeometry() override;131132/// @name inherited from GUIGlObject133/// @{134135/**@brief Draws the object136* @param[in] s The settings for the current view (may influence drawing)137* @see GUIGlObject::drawGL138*/139void drawGL(const GUIVisualizationSettings& s) const override;140141/// @}142143/// @name inherited from GNEPathElement144/// @{145146/// @brief compute pathElement147void computePathElement() override;148149/**@brief Draws partial object over lane150* @param[in] s The settings for the current view (may influence drawing)151* @param[in] segment lane segment152* @param[in] offsetFront front offset153*/154void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;155156/**@brief Draws partial object over junction157* @param[in] s The settings for the current view (may influence drawing)158* @param[in] segment junction segment159* @param[in] offsetFront front offset160*/161void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;162163/// @}164165/// @name inherited from GNEAttributeCarrier166/// @{167168/* @brief method for getting the Attribute of an XML key169* @param[in] key The attribute key170* @return string with the value associated to key171*/172std::string getAttribute(SumoXMLAttr key) const override;173174/* @brief method for getting the Attribute of an XML key in double format175* @param[in] key The attribute key176* @return double with the value associated to key177*/178double getAttributeDouble(SumoXMLAttr key) const override;179180/* @brief method for getting the Attribute of an XML key in position format181* @param[in] key The attribute key182* @return position with the value associated to key183*/184Position getAttributePosition(SumoXMLAttr key) const override;185186/* @brief method for getting the Attribute of an XML key in positionVector format187* @param[in] key The attribute key188* @return positionVector with the value associated to key189*/190PositionVector getAttributePositionVector(SumoXMLAttr key) const override;191192/* @brief method for setting the attribute and letting the object perform additional changes193* @param[in] key The attribute key194* @param[in] value The new value195* @param[in] undoList The undoList on which to register changes196*/197void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;198199/* @brief method for checking if the key and their correspond attribute are valids200* @param[in] key The attribute key201* @param[in] value The value associated to key key202* @return true if the value is valid, false in other case203*/204bool isValid(SumoXMLAttr key, const std::string& value) override;205206/// @}207208protected:209/// @brief The start position over lane210double myStartPosOverLane = 0;211212/// @brief The end position over lane213double myEndPosPosOverLane = 0;214215/// @brief Flag for friendly position216bool myFriendlyPosition = false;217218/// @brief The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting219SUMOTime myTimeThreshold = 0;220221/// @brief The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting222double mySpeedThreshold = 0;223224/// @brief The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam225double myJamThreshold = 0;226227/// @brief Traffic light vinculated with this E2 Detector228std::string myTrafficLight;229230/// @brief show or hidde detector in sumo-gui231bool myShow = true;232233/// @brief move element lane double234GNEMoveElementLaneDouble* myMoveElementLaneDouble = nullptr;235236private:237/// @brief draw E2 detector238void drawE2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,239const double exaggeration, const bool drawGeometryPoints) const;240241/// @brief draw E2 partial lane242void drawE2PartialLane(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,243const GNESegment* segment, const double offsetFront,244const GUIGeometry& geometry, const double exaggeration, const bool movingGeometryPoints) const;245246/// @brief draw E2 partial junction247void drawE2PartialJunction(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,248const bool onlyContour, const double offsetFront, const GUIGeometry& geometry,249const double exaggeration) const;250251/// @brief set attribute after validation252void setAttribute(SumoXMLAttr key, const std::string& value) override;253254/// @brief Invalidated copy constructor.255GNELaneAreaDetector(const GNELaneAreaDetector&) = delete;256257/// @brief Invalidated assignment operator.258GNELaneAreaDetector& operator=(const GNELaneAreaDetector&) = delete;259};260261262