Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NBAlgorithms_Ramps.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2012-2024 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/****************************************************************************/
19// Algorithms for highway on-/off-ramps computation
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
24#include <vector>
25
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
30class NBNetBuilder;
31class OptionsCont;
32class NBNode;
33class NBEdgeCont;
34class NBDistrictCont;
35
36
37// ===========================================================================
38// class definitions
39// ===========================================================================
40// ---------------------------------------------------------------------------
41// NBAlgorithms_Ramps
42// ---------------------------------------------------------------------------
43/* @class NBRampsComputer
44 * @brief Computes highway on-/off-ramps (if wished)
45 */
47public:
53
54 void computeRamps(NBNetBuilder& nb, OptionsCont& oc, bool mayAddOrRemove);
55
57 static const std::string ADDED_ON_RAMP_EDGE;
58
59private:
60
61 std::map<NBEdge*, double> myShiftedEdges;
62
63
72 static bool mayNeedOnRamp(NBNode* cur, double minHighwaySpeed, double maxRampSpeed,
73 const std::set<std::string>& noramps, double minWeaveLength);
74
75
83 static bool mayNeedOffRamp(NBNode* cur, double minHighwaySpeed, double maxRampSpeed,
84 const std::set<std::string>& noramps);
85
86
96 void buildOnRamp(NBNode* cur, NBNodeCont& nc, NBEdgeCont& ec, NBDistrictCont& dc, double rampLength, bool dontSplit, bool addLanes);
97
98
108 void buildOffRamp(NBNode* cur, NBNodeCont& nc, NBEdgeCont& ec, NBDistrictCont& dc, double rampLength, bool dontSplit, bool addLanes,
109 const std::set<NBNode*, ComparatorIdLess>& potOnRamps);
110
111
112 static void getOnRampEdges(NBNode* n, NBEdge** potHighway, NBEdge** potRamp, NBEdge** other);
113 static void getOffRampEdges(NBNode* n, NBEdge** potHighway, NBEdge** potRamp, NBEdge** other);
114 static bool determinedBySpeed(NBEdge** potHighway, NBEdge** potRamp);
115 static bool determinedByLaneNumber(NBEdge** potHighway, NBEdge** potRamp);
116
130 static bool fulfillsRampConstraints(NBEdge* potHighway, NBEdge* potRamp, NBEdge* other, double minHighwaySpeed, double maxRampSpeed,
131 const std::set<std::string>& noramps);
132
133
138 void moveRampRight(NBEdge* ramp, int addedLanes);
139
141 static bool hasWrongMode(NBEdge* edge);
142
144 static void patchRampGeometry(NBEdge* potRamp, NBEdge* first, NBEdge* potHighway, bool onRamp);
145
146 template <class T>
147 static std::string getUnusedID(const std::string& prefix, const T& objectCont) {
148 if (objectCont.retrieve(prefix) == nullptr) {
149 return prefix;
150 }
151 int i = 0;
152 std::string result = prefix + "#" + toString(i);
153 while (objectCont.retrieve(result) != nullptr) {
154 i++;
155 result = prefix + "#" + toString(i);
156 }
157 return result;
158 }
159};
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A container for districts.
Storage for edges, including some functionality operating on multiple edges.
Definition NBEdgeCont.h:59
The representation of a single edge during network building.
Definition NBEdge.h:92
Instance responsible for building networks.
Container for nodes during the netbuilding process.
Definition NBNodeCont.h:57
Represents a single node (junction) during network building.
Definition NBNode.h:66
void computeRamps(NBNetBuilder &nb, OptionsCont &oc, bool mayAddOrRemove)
static void getOffRampEdges(NBNode *n, NBEdge **potHighway, NBEdge **potRamp, NBEdge **other)
static bool mayNeedOffRamp(NBNode *cur, double minHighwaySpeed, double maxRampSpeed, const std::set< std::string > &noramps)
Determines whether the given node may be an off-ramp end.
static bool mayNeedOnRamp(NBNode *cur, double minHighwaySpeed, double maxRampSpeed, const std::set< std::string > &noramps, double minWeaveLength)
Determines whether the given node may be an on-ramp begin.
static bool determinedBySpeed(NBEdge **potHighway, NBEdge **potRamp)
void moveRampRight(NBEdge *ramp, int addedLanes)
Moves the ramp to the right, as new lanes were added.
static void getOnRampEdges(NBNode *n, NBEdge **potHighway, NBEdge **potRamp, NBEdge **other)
static const std::string ADDED_ON_RAMP_EDGE
suffix for newly generated on-ramp edges
static void patchRampGeometry(NBEdge *potRamp, NBEdge *first, NBEdge *potHighway, bool onRamp)
shift ramp geometry to merge smoothly with the motorway
std::map< NBEdge *, double > myShiftedEdges
void buildOffRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, double rampLength, bool dontSplit, bool addLanes, const std::set< NBNode *, ComparatorIdLess > &potOnRamps)
Builds an off-ramp ending at the given node.
static std::string getUnusedID(const std::string &prefix, const T &objectCont)
static bool determinedByLaneNumber(NBEdge **potHighway, NBEdge **potRamp)
static bool hasWrongMode(NBEdge *edge)
whether the edge has a mode that does not indicate a ramp edge
NBRampsComputer()
Computes highway on-/off-ramps (if wished)
void buildOnRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, double rampLength, bool dontSplit, bool addLanes)
Builds an on-ramp starting at the given node.
static bool fulfillsRampConstraints(NBEdge *potHighway, NBEdge *potRamp, NBEdge *other, double minHighwaySpeed, double maxRampSpeed, const std::set< std::string > &noramps)
Checks whether an on-/off-ramp can be bult here.
A storage for options typed value containers)
Definition OptionsCont.h:89