/****************************************************************************/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 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,79const std::string& routingType,80int priority,81const std::string& bidi,82double distance);838485/** @brief Adds a lane to the current edge86*87* @param[in] id The lane's id88* @param[in] maxSpeed The speed allowed on this lane89* @param[in] length The lane's length90* @param[in] shape The shape of the lane91* @param[in] width The width of the lane92* @param[in] permissions Encoding of vehicle classes that may drive on this lane93* @param[in] index The index of this lane within its parent edge94* @see SUMOVehicleClass95* @see MSLane96* @todo Definitely not a good way97*/98virtual MSLane* addLane(const std::string& id, double maxSpeed, double friction,99double length, const PositionVector& shape,100double width,101SVCPermissions permissions,102SVCPermissions changeLeft, SVCPermissions changeRight,103int index, bool isRampAccel,104const std::string& type,105const PositionVector& outlineShape);106107/** @brief process a stopOffset element (originates either from the active edge or lane).108*/109void addStopOffsets(const StopOffset& stopOffsets);110111/** @brief Return info about currently processed edge or lane112*/113std::string reportCurrentEdgeOrLane() const;114115/** @brief Adds a neighbor to the current lane116*117* @param[in] id The lane's id118* @see MSLane119*/120virtual void addNeigh(const std::string id);121122/** @brief Closes the building of an edge;123The edge is completely described by now and may not be opened again */124virtual MSEdge* closeEdge();125126/** @brief Closes the building of a lane;127The edge is completely described by now and may not be opened again */128void closeLane();129130/// builds the MSEdgeControl-class which holds all edges131MSEdgeControl* build(const MMVersion& networkVersion);132133134/** @brief Builds an edge instance (MSEdge in this case)135*136* Builds an MSEdge-instance using the given name and the current index137* "myCurrentNumericalEdgeID". Post-increments the index, returns138* the built edge.139*140* @param[in] id The id of the edge to build141* @param[in] streetName The street name of the edge to build142*/143virtual MSEdge* buildEdge(const std::string& id, const SumoXMLEdgeFunc function,144const std::string& streetName, const std::string& edgeType,145const std::string& routingType, const int priority, const double distance);146147/** @brief add the crossingEdges in a crossing edge if present148*149* @param[in] the vector of crossed edges id150*/151virtual void addCrossingEdges(const std::vector<std::string>&);152153protected:154/// @brief A running number for lane numbering155int myCurrentNumericalLaneID;156157/// @brief A running number for edge numbering158int myCurrentNumericalEdgeID;159160/// @brief Temporary, internal storage for built edges161MSEdgeVector myEdges;162163/// @brief pointer to the currently chosen edge164MSEdge* myActiveEdge;165166/// @brief The default stop offset for all lanes belonging to the active edge (this is set if the edge was given a stopOffset child)167StopOffset myCurrentDefaultStopOffset;168169/// @brief The index of the currently active lane (-1 if none is active)170int myCurrentLaneIndex;171172/// @brief pointer to a temporary lane storage173std::vector<MSLane*>* myLaneStorage;174175/// @brief temporary storage for bidi attributes (to be resolved after loading all edges)176std::map<MSEdge*, std::string, ComparatorNumericalIdLess> myBidiEdges;177178std::vector<std::pair<MSLane*, std::string> > myOppositeLanes;179180/** @brief set the stopOffset for the last added lane.181*/182void updateCurrentLaneStopOffset(const StopOffset& stopOffset);183184/** @brief set the stopOffset for the last added lane.185*/186void setDefaultStopOffset(const StopOffset& stopOffset);187188/** @brief189*/190void applyDefaultStopOffsetsToLanes();191192private:193/// @brief invalidated copy constructor194NLEdgeControlBuilder(const NLEdgeControlBuilder& s);195196/// @brief invalidated assignment operator197NLEdgeControlBuilder& operator=(const NLEdgeControlBuilder& s);198199};200201202