/****************************************************************************/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 NLEdgeControlBuilder.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @author Leonhard Luecken18/// @date Mon, 9 Jul 200119///20// Interface for building edges21/****************************************************************************/22#pragma once23#include <config.h>2425#include <string>26#include <vector>27#include <microsim/MSEdge.h>28#include <utils/geom/PositionVector.h>293031// ===========================================================================32// class declarations33// ===========================================================================34class MSEdgeControl;35class MSLane;36class MSNet;37class OutputDevice;383940// ===========================================================================41// class definitions42// ===========================================================================43/**44* @class NLEdgeControlBuilder45* @brief Interface for building edges46*47* This class is the container for MSEdge-instances while they are build.48*49* While building instances of MSEdge, these are stored in a list. The list of50* edges is later split into two lists, one containing single-lane-edges and51* one containing multi-lane-edges.52* @todo Assignment of lanes is not really well. Should be reworked after shapes are given as params.53*/54class NLEdgeControlBuilder {5556public:57/// @brief Constructor58NLEdgeControlBuilder();596061/// @brief Destructor62virtual ~NLEdgeControlBuilder();636465/** @brief Begins building of an MSEdge66*67* Builds an instance of MSEdge using "buildEdge". Stores it68* as the current edge in "myActiveEdge" and appends it to the list69* of built edges ("myEdges").70*71* The given information is used to build the edge.72* @param[in] id The id of the edge73* @param[in] function The function of the edge74* @param[in] streetName The street name of the edge75* @exception InvalidArgument If an edge with the same name was already built76*/77void beginEdgeParsing(const std::string& id, const SumoXMLEdgeFunc function,78const std::string& streetName, const std::string& edgeType,79int priority,80const std::string& bidi,81double distance);828384/** @brief Adds a lane to the current edge85*86* @param[in] id The lane's id87* @param[in] maxSpeed The speed allowed on this lane88* @param[in] length The lane's length89* @param[in] shape The shape of the lane90* @param[in] width The width of the lane91* @param[in] permissions Encoding of vehicle classes that may drive on this lane92* @param[in] index The index of this lane within its parent edge93* @see SUMOVehicleClass94* @see MSLane95* @todo Definitely not a good way96*/97virtual MSLane* addLane(const std::string& id, double maxSpeed, double friction,98double length, const PositionVector& shape,99double width,100SVCPermissions permissions,101SVCPermissions changeLeft, SVCPermissions changeRight,102int index, bool isRampAccel,103const std::string& type,104const PositionVector& outlineShape);105106/** @brief process a stopOffset element (originates either from the active edge or lane).107*/108void addStopOffsets(const StopOffset& stopOffsets);109110/** @brief Return info about currently processed edge or lane111*/112std::string reportCurrentEdgeOrLane() const;113114/** @brief Adds a neighbor to the current lane115*116* @param[in] id The lane's id117* @see MSLane118*/119virtual void addNeigh(const std::string id);120121/** @brief Closes the building of an edge;122The edge is completely described by now and may not be opened again */123virtual MSEdge* closeEdge();124125/** @brief Closes the building of a lane;126The edge is completely described by now and may not be opened again */127void closeLane();128129/// builds the MSEdgeControl-class which holds all edges130MSEdgeControl* build(const MMVersion& networkVersion);131132133/** @brief Builds an edge instance (MSEdge in this case)134*135* Builds an MSEdge-instance using the given name and the current index136* "myCurrentNumericalEdgeID". Post-increments the index, returns137* the built edge.138*139* @param[in] id The id of the edge to build140* @param[in] streetName The street name of the edge to build141*/142virtual MSEdge* buildEdge(const std::string& id, const SumoXMLEdgeFunc function,143const std::string& streetName, const std::string& edgeType, const int priority, const double distance);144145/** @brief add the crossingEdges in a crossing edge if present146*147* @param[in] the vector of crossed edges id148*/149virtual void addCrossingEdges(const std::vector<std::string>&);150151protected:152/// @brief A running number for lane numbering153int myCurrentNumericalLaneID;154155/// @brief A running number for edge numbering156int myCurrentNumericalEdgeID;157158/// @brief Temporary, internal storage for built edges159MSEdgeVector myEdges;160161/// @brief pointer to the currently chosen edge162MSEdge* myActiveEdge;163164/// @brief The default stop offset for all lanes belonging to the active edge (this is set if the edge was given a stopOffset child)165StopOffset myCurrentDefaultStopOffset;166167/// @brief The index of the currently active lane (-1 if none is active)168int myCurrentLaneIndex;169170/// @brief pointer to a temporary lane storage171std::vector<MSLane*>* myLaneStorage;172173/// @brief temporary storage for bidi attributes (to be resolved after loading all edges)174std::map<MSEdge*, std::string, ComparatorNumericalIdLess> myBidiEdges;175176std::vector<std::pair<MSLane*, std::string> > myOppositeLanes;177178/** @brief set the stopOffset for the last added lane.179*/180void updateCurrentLaneStopOffset(const StopOffset& stopOffset);181182/** @brief set the stopOffset for the last added lane.183*/184void setDefaultStopOffset(const StopOffset& stopOffset);185186/** @brief187*/188void applyDefaultStopOffsetsToLanes();189190private:191/// @brief invalidated copy constructor192NLEdgeControlBuilder(const NLEdgeControlBuilder& s);193194/// @brief invalidated assignment operator195NLEdgeControlBuilder& operator=(const NLEdgeControlBuilder& s);196197};198199200