Path: blob/main/src/netedit/elements/additional/GNELaneAreaDetector.h
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 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 "GNEDetector.h"2324// ===========================================================================25// class definitions26// ===========================================================================2728class GNELaneAreaDetector : public GNEDetector {2930public:31/// @brief default Constructor32GNELaneAreaDetector(SumoXMLTag tag, GNENet* net);3334/**@brief Constructor for Single-Lane E2 detectors35* @param[in] id The storage of gl-ids to get the one for this lane representation from36* @param[in] net pointer to GNENet of this additional element belongs37* @param[in] filename file in which this element is stored38* @param[in] lane Lane of this StoppingPlace belongs39* @param[in] pos position of the detector on the lane40* @param[in] length The length of the detector in meters.41* @param[in] freq the aggregation period the values the detector collects shall be summed up.42* @param[in] trafficLight The traffic light that triggers aggregation when switching.43* @param[in] filename The path to the output file.44* @param[in] vehicleTypes space separated list of vehicle type ids to consider45* @param[in] nextEdges list of edge ids that must all be part of the future route of the vehicle to qualify for detection46* @param[in] detectPersons detect persons instead of vehicles (pedestrians or passengers)47* @param[in] name E2 detector name48* @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting49* @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting50* @param[in] speedThreshold The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam51* @param[in] friendlyPos enable or disable friendly positions52* @param[in] show detector in sumo-gui53* @param[in] parameters generic parameters54*/55GNELaneAreaDetector(const std::string& id, GNENet* net, const std::string& filename, GNELane* lane, const double pos, const double length,56const SUMOTime freq, const std::string& trafficLight, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes,57const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,58const SUMOTime timeThreshold, double speedThreshold, const double jamThreshold, const bool friendlyPos,59const bool show, const Parameterised::Map& parameters);6061/**@brief Constructor for Multi-Lane detectors62* @param[in] id The storage of gl-ids to get the one for this lane representation from63* @param[in] net pointer to GNENet of this additional element belongs64* @param[in] filename file in which this element is stored65* @param[in] lanes vector of lanes Lane of this StoppingPlace belongs66* @param[in] pos position of the detector on the first lane67* @param[in] endPos position of the detector on the last lane68* @param[in] freq the aggregation period the values the detector collects shall be summed up.69* @param[in] trafficLight The traffic light that triggers aggregation when switching.70* @param[in] filename The path to the output file.71* @param[in] vehicleTypes space separated list of vehicle type ids to consider72* @param[in] nextEdges list of edge ids that must all be part of the future route of the vehicle to qualify for detection73* @param[in] detectPersons detect persons instead of vehicles (pedestrians or passengers)74* @param[in] name E2 detector name75* @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting76* @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting77* @param[in] speedThreshold The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam78* @param[in] friendlyPos enable or disable friendly positions79* @param[in] show detector in sumo-gui80* @param[in] parameters generic parameters81*/82GNELaneAreaDetector(const std::string& id, GNENet* net, const std::string& filename, std::vector<GNELane*> lanes, double pos, double endPos,83const SUMOTime freq, const std::string& trafficLight, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes,84const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,85const SUMOTime timeThreshold, double speedThreshold, const double jamThreshold, const bool friendlyPos,86const bool show, const Parameterised::Map& parameters);8788/// @brief Destructor89~GNELaneAreaDetector();9091/// @name members and functions relative to write additionals into XML92/// @{9394/**@brief write additional element into a xml file95* @param[in] device device in which write parameters of additional element96*/97void writeAdditional(OutputDevice& device) const;9899/// @brief check if current additional is valid to be written into XML100bool isAdditionalValid() const;101102/// @brief return a string with the current additional problem103std::string getAdditionalProblem() const;104105/// @brief fix additional problem106void fixAdditionalProblem();107108/// @}109110/// @brief update pre-computed geometry information111void updateGeometry();112113/// @name inherited from GUIGlObject114/// @{115116/**@brief Draws the object117* @param[in] s The settings for the current view (may influence drawing)118* @see GUIGlObject::drawGL119*/120void drawGL(const GUIVisualizationSettings& s) const;121122/// @}123124/// @name inherited from GNEPathElement125/// @{126127/// @brief compute pathElement128void computePathElement();129130/**@brief Draws partial object over lane131* @param[in] s The settings for the current view (may influence drawing)132* @param[in] segment lane segment133* @param[in] offsetFront front offset134*/135void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;136137/**@brief Draws partial object over junction138* @param[in] s The settings for the current view (may influence drawing)139* @param[in] segment junction segment140* @param[in] offsetFront front offset141*/142void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;143144/// @}145146/// @name inherited from GNEAttributeCarrier147/// @{148149/* @brief method for getting the Attribute of an XML key150* @param[in] key The attribute key151* @return string with the value associated to key152*/153std::string getAttribute(SumoXMLAttr key) const;154155/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)156* @param[in] key The attribute key157* @return double with the value associated to key158*/159double getAttributeDouble(SumoXMLAttr key) const;160161/* @brief method for setting the attribute and letting the object perform additional changes162* @param[in] key The attribute key163* @param[in] value The new value164* @param[in] undoList The undoList on which to register changes165*/166void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);167168/* @brief method for checking if the key and their correspond attribute are valids169* @param[in] key The attribute key170* @param[in] value The value associated to key key171* @return true if the value is valid, false in other case172*/173bool isValid(SumoXMLAttr key, const std::string& value);174175/// @}176177protected:178/// @brief end position over lane (only for Multilane E2 detectors)179double myEndPositionOverLane = 0;180181/// @brief The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting182SUMOTime myTimeThreshold = 0;183184/// @brief The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting185double mySpeedThreshold = 0;186187/// @brief The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam188double myJamThreshold = 0;189190/// @brief Traffic light vinculated with this E2 Detector191std::string myTrafficLight;192193/// @brief show or hidde detector in sumo-gui194bool myShow = true;195196private:197/// @brief draw E2 detector198void drawE2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,199const double exaggeration) const;200201/// @brief draw E2 partial lane202void drawE2PartialLane(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,203const GNESegment* segment, const double offsetFront,204const GUIGeometry& geometry, const double exaggeration, const bool movingGeometryPoints) const;205206/// @brief draw E2 partial junction207void drawE2PartialJunction(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,208const bool onlyContour, const double offsetFront, const GUIGeometry& geometry,209const double exaggeration) const;210211/// @brief set attribute after validation212void setAttribute(SumoXMLAttr key, const std::string& value);213214/// @brief set move shape215void setMoveShape(const GNEMoveResult& moveResult);216217/// @brief commit move shape218void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);219220/// @brief get start position over lane that is applicable to the shape221double getStartGeometryPositionOverLane() const;222223/// @brief get end position over lane that is applicable to the shape224double getEndGeometryPositionOverLane() const;225226/// @brief Invalidated copy constructor.227GNELaneAreaDetector(const GNELaneAreaDetector&) = delete;228229/// @brief Invalidated assignment operator.230GNELaneAreaDetector& operator=(const GNELaneAreaDetector&) = delete;231};232233234