1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2012-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file NBAlgorithms_Ramps.h 11 /// @author Daniel Krajzewicz 12 /// @author Jakob Erdmann 13 /// @date 29. March 2012 14 /// @version $Id$ 15 /// 16 // Algorithms for highway on-/off-ramps computation 17 /****************************************************************************/ 18 #ifndef NBAlgorithms_Ramps_h 19 #define NBAlgorithms_Ramps_h 20 21 22 // =========================================================================== 23 // included modules 24 // =========================================================================== 25 #include <config.h> 26 27 #include <vector> 28 29 30 // =========================================================================== 31 // class declarations 32 // =========================================================================== 33 class NBNetBuilder; 34 class OptionsCont; 35 class NBNode; 36 class NBEdgeCont; 37 class NBDistrictCont; 38 39 40 // =========================================================================== 41 // class definitions 42 // =========================================================================== 43 // --------------------------------------------------------------------------- 44 // NBAlgorithms_Ramps 45 // --------------------------------------------------------------------------- 46 /* @class NBRampsComputer 47 * @brief Computes highway on-/off-ramps (if wished) 48 */ 49 class NBRampsComputer { 50 public: 51 /** @brief Computes highway on-/off-ramps (if wished) 52 * @param[in, changed] nb The network builder which contains the current network representation 53 * @param[in] oc The options container 54 */ 55 static void computeRamps(NBNetBuilder& nb, OptionsCont& oc); 56 57 /// @brief suffix for newly generated on-ramp edges 58 static const std::string ADDED_ON_RAMP_EDGE; 59 60 private: 61 /** @brief Determines whether the given node may be an on-ramp begin 62 * @param[in] cur The node to check 63 * @param[in] minHighwaySpeed The minimum speed limit a highway must have for being a highway 64 * @param[in] maxRampSpeed The maximum speed limit a ramp must have for being a ramp 65 * @param[in] noramps Edges that shall not be treated as ramps 66 * @return Whether the node is assumed to be an on-ramp begin 67 */ 68 static bool mayNeedOnRamp(NBNode* cur, double minHighwaySpeed, double maxRampSpeed, 69 const std::set<std::string>& noramps); 70 71 72 /** @brief Determines whether the given node may be an off-ramp end 73 * @param[in] cur The node to check 74 * @param[in] minHighwaySpeed The minimum speed limit a highway must have for being a highway 75 * @param[in] maxRampSpeed The maximum speed limit a ramp must have for being a ramp 76 * @param[in] noramps Edges that shall not be treated as ramps 77 * @return Whether the node is assumed to be an off-ramp end 78 */ 79 static bool mayNeedOffRamp(NBNode* cur, double minHighwaySpeed, double maxRampSpeed, 80 const std::set<std::string>& noramps); 81 82 83 /** @brief Builds an on-ramp starting at the given node 84 * @param[in] cur The node at which the on-ramp shall begin 85 * @param[in] nc The container of nodes 86 * @param[in] ec The container of edges 87 * @param[in] dc The container of districts 88 * @param[in] rampLength The wished ramp length 89 * @param[in] dontSplit Whether no edges shall be split 90 * @param[in, filled] incremented The list of edges which lane number was already incremented 91 */ 92 static void buildOnRamp(NBNode* cur, NBNodeCont& nc, NBEdgeCont& ec, NBDistrictCont& dc, double rampLength, bool dontSplit, bool addLanes); 93 94 95 /** @brief Builds an off-ramp ending at the given node 96 * @param[in] cur The node at which the off-ramp shall end 97 * @param[in] nc The container of nodes 98 * @param[in] ec The container of edges 99 * @param[in] dc The container of districts 100 * @param[in] rampLength The wished ramp length 101 * @param[in] dontSplit Whether no edges shall be split 102 * @param[in, filled] incremented The list of edges which lane number was already incremented 103 */ 104 static void buildOffRamp(NBNode* cur, NBNodeCont& nc, NBEdgeCont& ec, NBDistrictCont& dc, double rampLength, bool dontSplit); 105 106 107 static void getOnRampEdges(NBNode* n, NBEdge** potHighway, NBEdge** potRamp, NBEdge** other); 108 static void getOffRampEdges(NBNode* n, NBEdge** potHighway, NBEdge** potRamp, NBEdge** other); 109 static bool determinedBySpeed(NBEdge** potHighway, NBEdge** potRamp); 110 static bool determinedByLaneNumber(NBEdge** potHighway, NBEdge** potRamp); 111 112 /** @brief Checks whether an on-/off-ramp can be bult here 113 * 114 * - none of the participating edges must be a macroscopic connector 115 * - ramp+highways together must have more lanes than the continuation 116 * - speeds must match the defined swells 117 * @param[in] potHighway The highway part to check 118 * @param[in] potRamp The ramp part to check 119 * @param[in] other The successor/predecessor edge 120 * @param[in] minHighwaySpeed The minimum speed limit a highway must have for being a highway 121 * @param[in] maxRampSpeed The maximum speed limit a ramp must have for being a ramp 122 * @param[in] noramps Edges that shall not be treated as ramps 123 * @return Whether a ramp can be built here 124 */ 125 static bool fulfillsRampConstraints(NBEdge* potHighway, NBEdge* potRamp, NBEdge* other, double minHighwaySpeed, double maxRampSpeed, 126 const std::set<std::string>& noramps); 127 128 129 /** @brief Moves the ramp to the right, as new lanes were added 130 * @param[in] ramp The ramp to move 131 * @param[in] addedLanes The number of added lanes 132 */ 133 static void moveRampRight(NBEdge* ramp, int addedLanes); 134 135 /// @brief whether the edge has a mode that does not indicate a ramp edge 136 static bool hasWrongMode(NBEdge* edge); 137 138 /// @brief shift ramp geometry to merge smoothly with the motorway 139 static void patchRampGeometry(NBEdge* potRamp, NBEdge* first, NBEdge* potHighway, bool onRamp); 140 }; 141 142 143 #endif 144 145 /****************************************************************************/ 146 147