43 #ifdef CHECK_MEMORY_LEAKS 45 #endif // CHECK_MEMORY_LEAKS 64 bool dontSplit = oc.
getBool(
"ramps.no-split");
65 std::set<NBEdge*> incremented;
67 if (oc.
getBool(
"ramps.guess")) {
72 std::set<std::string> noramps;
73 if (oc.
isSet(
"ramps.unset")) {
75 noramps.insert(edges.begin(), edges.end());
79 for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
80 it_round != roundabouts.end(); ++it_round) {
81 for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
82 noramps.insert((*it_edge)->getID());
86 std::set<NBNode*, Named::ComparatorIdLess> potOnRamps;
87 std::set<NBNode*, Named::ComparatorIdLess> potOffRamps;
88 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
90 if (
mayNeedOnRamp(cur, minHighwaySpeed, maxRampSpeed, noramps)) {
91 potOnRamps.insert(cur);
94 potOffRamps.insert(cur);
97 for (std::set<NBNode*, Named::ComparatorIdLess>::const_iterator i = potOnRamps.begin(); i != potOnRamps.end(); ++i) {
100 for (std::set<NBNode*, Named::ComparatorIdLess>::const_iterator i = potOffRamps.begin(); i != potOffRamps.end(); ++i) {
105 if (oc.
isSet(
"ramps.set")) {
110 for (std::vector<std::string>::iterator i = edges.begin(); i != edges.end(); ++i) {
113 WRITE_WARNING(
"Can not build on ramp on edge '" + *i +
"' - the edge is not known.");
118 buildOnRamp(from, nc, ec, dc, rampLength, dontSplit);
123 WRITE_WARNING(
"Can not build off ramp on edge '" + *i +
"' - the edge is not known.");
140 NBEdge* potHighway, *potRamp, *cont;
153 NBEdge* potHighway, *potRamp, *prev;
161 NBEdge* potHighway, *potRamp, *cont;
164 const unsigned int firstLaneNumber = cont->
getNumLanes();
169 std::set<NBEdge*> incremented;
170 if (toAdd > 0 && find(incremented.begin(), incremented.end(), cont) == incremented.end()) {
173 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
178 incremented.insert(curr);
192 }
else if (curr == potHighway || curr == potRamp) {
202 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
204 bool wasFirst = first == curr;
207 throw ProcessError(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
209 std::string name = curr->
getID();
212 WRITE_ERROR(
"Ups - could not build on-ramp for edge '" + curr->
getID() +
"'!");
217 incremented.insert(curr);
224 if (curr == cont && dontSplit) {
225 WRITE_WARNING(
"Could not build on-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
250 NBEdge* potHighway, *potRamp, *prev;
253 const unsigned int firstLaneNumber = prev->
getNumLanes();
258 std::set<NBEdge*> incremented;
259 if (toAdd > 0 && find(incremented.begin(), incremented.end(), prev) == incremented.end()) {
262 if (find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
267 incremented.insert(curr);
285 }
else if (curr == potHighway || curr == potRamp) {
295 if (curr != 0 && !dontSplit && currLength - POSITION_EPS < rampLength && curr->getNumLanes() == firstLaneNumber && find(incremented.begin(), incremented.end(), curr) == incremented.end()) {
297 bool wasFirst = first == curr;
301 throw ProcessError(
"Ups - could not build off-ramp for edge '" + curr->
getID() +
"' (node could not be build)!");
303 std::string name = curr->
getID();
306 WRITE_ERROR(
"Ups - could not build off-ramp for edge '" + curr->
getID() +
"'!");
309 curr = ec.
retrieve(name +
"-AddedOffRampEdge");
310 incremented.insert(curr);
317 if (curr == prev && dontSplit) {
318 WRITE_WARNING(
"Could not build off-ramp for edge '" + curr->
getID() +
"' due to option '--ramps.no-split'");
345 const SUMOReal offset = (0.5 * addedLanes *
357 if (fabs((*potHighway)->getSpeed() - (*potRamp)->getSpeed()) < .1) {
360 if ((*potHighway)->getSpeed() < (*potRamp)->getSpeed()) {
361 std::swap(*potHighway, *potRamp);
369 if ((*potHighway)->getNumLanes() == (*potRamp)->getNumLanes()) {
372 if ((*potHighway)->getNumLanes() < (*potRamp)->getNumLanes()) {
373 std::swap(*potHighway, *potRamp);
383 assert(edges.size() == 2);
384 *potHighway = edges[0];
397 const std::vector<NBEdge*>& edges2 = n->
getEdges();
398 std::vector<NBEdge*>::const_iterator i = std::find(edges2.begin(), edges2.end(), *other);
400 if ((*i) == *potHighway) {
401 std::swap(*potHighway, *potRamp);
410 *potHighway = edges[0];
412 assert(edges.size() == 2);
424 const std::vector<NBEdge*>& edges2 = n->
getEdges();
425 std::vector<NBEdge*>::const_iterator i = std::find(edges2.begin(), edges2.end(), *other);
427 if ((*i) == *potRamp) {
428 std::swap(*potHighway, *potRamp);
436 const std::set<std::string>& noramps) {
451 if (maxSpeed < minHighwaySpeed) {
474 if (maxRampSpeed > 0 && maxRampSpeed < potRamp->getSpeed()) {
477 if (noramps.find(other->
getID()) != noramps.end()) {
491 for (
int i = 0; i < (int)edge->
getNumLanes(); ++i) {
void invalidateConnections(bool reallowSetting=false)
const PositionVector & getLaneShape(unsigned int i) const
Returns the shape of the nth lane.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
const SUMOReal SUMO_const_laneWidth
static bool determinedBySpeed(NBEdge **potHighway, NBEdge **potRamp)
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
static bool fulfillsRampConstraints(NBEdge *potHighway, NBEdge *potRamp, NBEdge *other, SUMOReal minHighwaySpeed, SUMOReal maxRampSpeed, const std::set< std::string > &noramps)
Checks whether an on-/off-ramp can be bult here.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
void incLaneNo(unsigned int by)
A container for districts.
bool addLane2LaneConnections(unsigned int fromLane, NBEdge *dest, unsigned int toLane, unsigned int no, Lane2LaneInfoType type, bool invalidatePrevious=false, bool mayDefinitelyPass=false)
Builds no connections starting at the given lanes.
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
static void moveRampRight(NBEdge *ramp, int addedLanes)
Moves the ramp to the right, as new lanes were added.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
static void nextCW(const EdgeVector &edges, EdgeVector::const_iterator &from)
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
#define WRITE_WARNING(msg)
The connection was computed and validated.
static bool determinedByLaneNumber(NBEdge **potHighway, NBEdge **potRamp)
static const std::string ADDED_ON_RAMP_EDGE
suffix for newly generated on-ramp edges
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
const std::string & getID() const
Returns the id.
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
A point in 2D or 3D with translation and scaling methods.
NBEdgeCont & getEdgeCont()
Returns the edge container.
unsigned int getNumLanes() const
Returns the number of lanes.
static void buildOnRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, SUMOReal rampLength, bool dontSplit)
Builds an on-ramp starting at the given node.
EdgeBuildingStep getStep() const
The building step of this edge.
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
const EdgeVector & getEdges() const
Returns all edges which participate in this node.
Storage for edges, including some functionality operating on multiple edges.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
vehicle is a passenger car (a "normal" car)
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
SUMOReal length() const
Returns the length.
static bool mayNeedOnRamp(NBNode *cur, SUMOReal minHighwaySpeed, SUMOReal maxRampSpeed, const std::set< std::string > &noramps)
Determines whether the given node may be an on-ramp begin.
NBNode * getToNode() const
Returns the destination node of the edge.
static void computeRamps(NBNetBuilder &nb, OptionsCont &oc)
Computes highway on-/off-ramps (if wished)
static bool mayNeedOffRamp(NBNode *cur, SUMOReal minHighwaySpeed, SUMOReal maxRampSpeed, const std::set< std::string > &noramps)
Determines whether the given node may be an off-ramp end.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
static void getOffRampEdges(NBNode *n, NBEdge **potHighway, NBEdge **potRamp, NBEdge **other)
NBNodeCont & getNodeCont()
Returns the node container.
Instance responsible for building networks.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
bool isMacroscopicConnector() const
Returns whether this edge was marked as a macroscopic connector.
A storage for options typed value containers)
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
Represents a single node (junction) during network building.
static void getOnRampEdges(NBNode *n, NBEdge **potHighway, NBEdge **potRamp, NBEdge **other)
void move2side(SUMOReal amount)
static bool hasWrongMode(NBEdge *edge)
whether the edge has a mode that does not indicate a ramp edge
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Container for nodes during the netbuilding process.
static void buildOffRamp(NBNode *cur, NBNodeCont &nc, NBEdgeCont &ec, NBDistrictCont &dc, SUMOReal rampLength, bool dontSplit)
Builds an off-ramp ending at the given node.
NBDistrictCont & getDistrictCont()
Returns the districts container.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
NBNode * getFromNode() const
Returns the origin node of the edge.