Eclipse SUMO - Simulation of Urban MObility
NBAlgorithms.cpp
Go to the documentation of this file.
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 /****************************************************************************/
15 // Algorithms for network computation
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include <sstream>
25 #include <iostream>
26 #include <cassert>
27 #include <algorithm>
29 #include <utils/common/ToString.h>
31 #include "NBEdge.h"
32 #include "NBOwnTLDef.h"
34 #include "NBNodeCont.h"
35 #include "NBTypeCont.h"
36 #include "NBNode.h"
37 #include "NBAlgorithms.h"
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
43 // ---------------------------------------------------------------------------
44 // NBTurningDirectionsComputer
45 // ---------------------------------------------------------------------------
46 void
48  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
49  computeTurnDirectionsForNode(i->second, warn);
50  }
51 }
52 
53 void
55  const std::vector<NBEdge*>& incoming = node->getIncomingEdges();
56  const std::vector<NBEdge*>& outgoing = node->getOutgoingEdges();
57  // reset turning directions since this may be called multiple times
58  for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
59  (*k)->setTurningDestination(nullptr);
60  }
61  std::vector<Combination> combinations;
62  const bool geometryLike = node->geometryLike();
63  for (std::vector<NBEdge*>::const_iterator j = outgoing.begin(); j != outgoing.end(); ++j) {
64  NBEdge* outedge = *j;
65  for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
66  NBEdge* e = *k;
67  // @todo: check whether NBHelpers::relAngle is properly defined and whether it should really be used, here
68  const double signedAngle = NBHelpers::normRelAngle(e->getAngleAtNode(node), outedge->getAngleAtNode(node));
69  if (signedAngle > 0 && signedAngle < 177 && e->getGeometry().back().distanceTo2D(outedge->getGeometry().front()) < POSITION_EPS) {
70  // backwards curving edges can only be turnaround when there are
71  // non-default endpoints
72  continue;
73  }
74  double angle = fabs(signedAngle);
75  // std::cout << "incoming=" << e->getID() << " outgoing=" << outedge->getID() << " relAngle=" << NBHelpers::relAngle(e->getAngleAtNode(node), outedge->getAngleAtNode(node)) << "\n";
76  const bool badPermissions = ((outedge->getPermissions() & e->getPermissions() & ~SVC_PEDESTRIAN) == 0
77  && !geometryLike
78  && outedge->getPermissions() != e->getPermissions());
79  if (e->getFromNode() == outedge->getToNode() && angle > 120 && !badPermissions) {
80  // they connect the same nodes; should be the turnaround direction
81  // we'll assign a maximum number
82  //
83  // @todo: indeed, we have observed some pathological intersections
84  // see "294831560" in OSM/adlershof. Here, several edges are connecting
85  // same nodes. We have to do the angle check before...
86  //
87  // @todo: and well, there are some other as well, see plain import
88  // of delphi_muenchen (elmar), intersection "59534191". Not that it would
89  // be realistic in any means; we will warn, here.
90  angle += 360;
91  }
92  if (angle < 160) {
93  continue;
94  }
95  if (badPermissions) {
96  // penalty
97  angle -= 90;
98  }
99  Combination c;
100  c.from = e;
101  c.to = outedge;
102  c.angle = angle;
103  combinations.push_back(c);
104  }
105  }
106  // sort combinations so that the ones with the highest angle are at the begin
107  std::sort(combinations.begin(), combinations.end(), combination_by_angle_sorter());
108  std::set<NBEdge*> seen;
109  //std::cout << "check combinations at " << node->getID() << "\n";
110  for (std::vector<Combination>::const_iterator j = combinations.begin(); j != combinations.end(); ++j) {
111  //std::cout << " from=" << (*j).from->getID() << " to=" << (*j).to->getID() << " a=" << (*j).angle << "\n";
112  if (seen.find((*j).from) != seen.end() || seen.find((*j).to) != seen.end()) {
113  // do not regard already set edges
114  if ((*j).angle > 360 && warn) {
115  WRITE_WARNINGF("Ambiguity in turnarounds computation at junction '%'.", node->getID());
116  //std::cout << " already seen: " << toString(seen) << "\n";
117  warn = false;
118  }
119  continue;
120  }
121  // mark as seen
122  seen.insert((*j).from);
123  seen.insert((*j).to);
124  // set turnaround information
125  bool onlyPossible = (*j).from->getConnections().size() != 0 && !(*j).from->isConnectedTo((*j).to);
126  //std::cout << " setTurningDestination from=" << (*j).from->getID() << " to=" << (*j).to->getID() << " onlyPossible=" << onlyPossible << "\n";
127  (*j).from->setTurningDestination((*j).to, onlyPossible);
128  }
129 }
130 
131 
132 // ---------------------------------------------------------------------------
133 // NBNodesEdgesSorter
134 // ---------------------------------------------------------------------------
135 void
137  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
138  i->second->sortEdges(useNodeShape);
139  }
140 }
141 
142 
143 void
145  const std::vector<NBEdge*>::iterator& i1,
146  const std::vector<NBEdge*>::iterator& i2) {
147  NBEdge* e1 = *i1;
148  NBEdge* e2 = *i2;
149  // @todo: The difference between "isTurningDirectionAt" and "isTurnaround"
150  // is not nice. Maybe we could get rid of it if we would always mark edges
151  // as turnarounds, even if they do not have to be added, as mentioned in
152  // notes on NBTurningDirectionsComputer::computeTurnDirectionsForNode
153  if (e2->getToNode() == n && e2->isTurningDirectionAt(e1)) {
154  std::swap(*i1, *i2);
155  }
156 }
157 
158 
159 // ---------------------------------------------------------------------------
160 // NBNodeTypeComputer
161 // ---------------------------------------------------------------------------
162 void
164  validateRailCrossings(nc, tlc);
165  const OptionsCont& oc = OptionsCont::getOptions();
166  const double rightBeforeLeftSpeed = oc.getFloat("junctions.right-before-left.speed-threshold");
167  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
168  NBNode* const n = (*i).second;
169  // the type may already be set from the data
170  if (n->myType != NODETYPE_UNKNOWN && n->myType != NODETYPE_DEAD_END) {
171  n->myTypeWasGuessed = false;
172  continue;
173  }
174  // check whether the node was set to be unregulated by the user
175  if (oc.getBool("keep-nodes-unregulated") || oc.isInStringVector("keep-nodes-unregulated.explicit", n->getID())
176  || (oc.getBool("keep-nodes-unregulated.district-nodes") && (n->isNearDistrict() || n->isDistrict()))) {
178  continue;
179  }
180  // check whether the node is a waterway node. Set to unregulated by default
181  bool waterway = true;
182  for (NBEdge* e : n->getEdges()) {
183  if (!isWaterway(e->getPermissions())) {
184  waterway = false;
185  break;
186  }
187  }
188  if (waterway && (n->myType == NODETYPE_UNKNOWN || n->myType == NODETYPE_DEAD_END)) {
190  continue;
191  }
192 
193  // check whether the junction is not a real junction
194  if (n->myIncomingEdges.size() == 1) {
196  continue;
197  }
198  // @todo "isSimpleContinuation" should be revalidated
199  if (n->isSimpleContinuation()) {
201  continue;
202  }
203  if (isRailwayNode(n)) {
204  // priority instead of unregulated to ensure that collisions can be detected
206  continue;
207  }
208  // determine the type
210  for (EdgeVector::const_iterator i = n->myIncomingEdges.begin(); i != n->myIncomingEdges.end(); i++) {
211  for (EdgeVector::const_iterator j = i + 1; j != n->myIncomingEdges.end(); j++) {
212  // @todo "getOppositeIncoming" should probably be refactored into something the edge knows
213  if (n->getOppositeIncoming(*j) == *i && n->myIncomingEdges.size() > 2) {
214  continue;
215  }
216  // @todo check against a legal document
217  // @todo figure out when NODETYPE_PRIORITY_STOP is appropriate
218  const double s1 = (*i)->getSpeed();
219  const double s2 = (*j)->getSpeed();
220  const int p1 = (*i)->getPriority();
221  const int p2 = (*j)->getPriority();
222  if (fabs(s1 - s2) > (9.5 / 3.6) || MAX2(s1, s2) >= rightBeforeLeftSpeed || p1 != p2) {
223  type = NODETYPE_PRIORITY;
224  break;
225  }
226  }
227  }
228  // save type
229  n->myType = type;
230  n->myTypeWasGuessed = true;
231  }
232 }
233 
234 
235 void
237  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
238  NBNode* n = (*i).second;
239  if (n->myType == NODETYPE_RAIL_CROSSING) {
240  // check if it really is a rail crossing
241  int numRailway = 0;
242  int numNonRailway = 0;
243  int numNonRailwayNonPed = 0;
244  for (NBEdge* e : n->getIncomingEdges()) {
245  if ((e->getPermissions() & ~SVC_RAIL_CLASSES) != 0) {
246  numNonRailway++;
247  if (e->getPermissions() != SVC_PEDESTRIAN) {
248  numNonRailwayNonPed++;
249  }
250  } else if ((e->getPermissions() & SVC_RAIL_CLASSES) != 0) {
251  numRailway++;
252  }
253  }
254  for (NBEdge* e : n->getOutgoingEdges()) {
255  if (e->getPermissions() == SVC_PEDESTRIAN) {
256  numNonRailway++;
257  }
258  }
259  if (numNonRailway == 0 || numRailway == 0) {
260  // not a crossing (maybe unregulated or rail_signal)
262  } else if (numNonRailwayNonPed > 2) {
263  // does not look like a rail crossing (roads in conflict). maybe a traffic light?
264  WRITE_WARNINGF("Converting invalid rail_crossing to traffic_light at junction '%'.", n->getID());
266  NBTrafficLightDefinition* tlDef = new NBOwnTLDef(n->getID(), n, 0, type);
268  if (!tlc.insert(tlDef)) {
269  // actually, nothing should fail here
270  n->removeTrafficLight(tlDef);
272  delete tlDef;
273  WRITE_WARNINGF("Could not allocate tls '%'.", n->getID());
274  }
275  }
276  }
277  }
278 }
279 
280 
281 bool
283  int numRailway = 0;
284  int numNonRailway = 0;
285  for (NBEdge* e : n->getIncomingEdges()) {
286  if ((e->getPermissions() & ~SVC_RAIL_CLASSES) != 0) {
287  numNonRailway++;
288  } else if ((e->getPermissions() & SVC_RAIL_CLASSES) != 0) {
289  numRailway++;
290  }
291  }
292  return numRailway > 0 && numNonRailway == 0;
293 }
294 
295 // ---------------------------------------------------------------------------
296 // NBEdgePriorityComputer
297 // ---------------------------------------------------------------------------
298 void
300  for (const auto& node : nc) {
301  // preset all junction's edge priorities to zero
302  for (NBEdge* const edge : node.second->myAllEdges) {
303  edge->setJunctionPriority(node.second, NBEdge::MINOR_ROAD);
304  }
305  node.second->markBentPriority(false);
306  // check if the junction is not a real junction
307  if (node.second->myIncomingEdges.size() == 1 && node.second->myOutgoingEdges.size() == 1) {
308  continue;
309  }
310  // compute the priorities on junction when needed
311  if (node.second->getType() != NODETYPE_RIGHT_BEFORE_LEFT && node.second->getType() != NODETYPE_ALLWAY_STOP && node.second->getType() != NODETYPE_NOJUNCTION) {
312  if (node.second->getRightOfWay() == RIGHT_OF_WAY_EDGEPRIORITY) {
313  for (NBEdge* e : node.second->getIncomingEdges()) {
314  e->setJunctionPriority(node.second, e->getPriority());
315  }
316  } else {
317  setPriorityJunctionPriorities(*node.second);
318  }
319  }
320  }
321 }
322 
323 
324 void
326  if (n.myIncomingEdges.size() == 0 || n.myOutgoingEdges.size() == 0) {
327  return;
328  }
329  EdgeVector incoming = n.myIncomingEdges;
330  EdgeVector outgoing = n.myOutgoingEdges;
331  // what we do want to have is to extract the pair of roads that are
332  // the major roads for this junction
333  // let's get the list of incoming edges with the highest priority
334  std::sort(incoming.begin(), incoming.end(), NBContHelper::edge_by_priority_sorter());
335  EdgeVector bestIncoming;
336  NBEdge* best = incoming[0];
337  while (incoming.size() > 0 && samePriority(best, incoming[0])) {
338  bestIncoming.push_back(*incoming.begin());
339  incoming.erase(incoming.begin());
340  }
341  // now, let's get the list of best outgoing
342  assert(outgoing.size() != 0);
343  sort(outgoing.begin(), outgoing.end(), NBContHelper::edge_by_priority_sorter());
344  EdgeVector bestOutgoing;
345  best = outgoing[0];
346  while (outgoing.size() > 0 && samePriority(best, outgoing[0])) { //->getPriority()==best->getPriority()) {
347  bestOutgoing.push_back(*outgoing.begin());
348  outgoing.erase(outgoing.begin());
349  }
350  // special case: user input makes mainDirection unambiguous
351  const bool mainDirectionExplicit = (
352  bestIncoming.size() == 1 && n.myIncomingEdges.size() <= 2
353  && (incoming.size() == 0 || bestIncoming[0]->getPriority() > incoming[0]->getPriority())
354  && bestOutgoing.size() == 1 && n.myOutgoingEdges.size() <= 2
355  && (outgoing.size() == 0 || bestOutgoing[0]->getPriority() > outgoing[0]->getPriority())
356  && !bestIncoming[0]->isTurningDirectionAt(bestOutgoing[0]));
357  // now, let's compute for each of the best incoming edges
358  // the incoming which is most opposite
359  // the outgoing which is most opposite
360  EdgeVector::iterator i;
361  std::map<NBEdge*, NBEdge*> counterIncomingEdges;
362  std::map<NBEdge*, NBEdge*> counterOutgoingEdges;
363  incoming = n.myIncomingEdges;
364  outgoing = n.myOutgoingEdges;
365  for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
366  std::sort(incoming.begin(), incoming.end(), NBContHelper::edge_opposite_direction_sorter(*i, &n, true));
367  counterIncomingEdges[*i] = *incoming.begin();
368  std::sort(outgoing.begin(), outgoing.end(), NBContHelper::edge_opposite_direction_sorter(*i, &n, true));
369  counterOutgoingEdges[*i] = *outgoing.begin();
370  }
371  //std::cout << "n=" << n.getID() << " best=" << best->getID() << " bestIncoming=" << toString(bestIncoming) << "\n incoming=" << toString(incoming) << "\n outgoing=" << toString(outgoing) << "\n mainExplicit=" << mainDirectionExplicit << " counterBest=" << counterIncomingEdges.find(bestIncoming[0])->second->getID() << "\n";
372  // ok, let's try
373  // 1) there is one best incoming road
374  if (bestIncoming.size() == 1) {
375  // let's mark this road as the best
376  NBEdge* best1 = extractAndMarkFirst(n, bestIncoming);
377  if (!mainDirectionExplicit && counterIncomingEdges.find(best1) != counterIncomingEdges.end()) {
378  // ok, look, what we want is the opposit of the straight continuation edge
379  // but, what if such an edge does not exist? By now, we'll determine it
380  // geometrically
381  NBEdge* s = counterIncomingEdges.find(best1)->second;
382  const double minAngleDiff = GeomHelper::getMinAngleDiff(best1->getAngleAtNode(&n), s->getAngleAtNode(&n));
383  if (minAngleDiff > 180 - 45
384  || (minAngleDiff > 75 && s->getPriority() == best1->getPriority() && hasDifferentPriorities(incoming, best1))) {
386  }
387  }
388  markBestParallel(n, best1, nullptr);
389  assert(bestOutgoing.size() != 0);
390  // mark the best outgoing as the continuation
391  sort(bestOutgoing.begin(), bestOutgoing.end(), NBContHelper::edge_similar_direction_sorter(best1));
392  // assign extra priority if the priorities are unambiguous (regardless of geometry)
393  NBEdge* bestOut = extractAndMarkFirst(n, bestOutgoing);
394  if (!mainDirectionExplicit && counterOutgoingEdges.find(bestOut) != counterOutgoingEdges.end()) {
395  NBEdge* s = counterOutgoingEdges.find(bestOut)->second;
396  if (GeomHelper::getMinAngleDiff(bestOut->getAngleAtNode(&n), s->getAngleAtNode(&n)) > 180 - 45) {
397  s->setJunctionPriority(&n, 1);
398  }
399  }
400  n.markBentPriority(n.getDirection(best1, bestOut) != LINKDIR_STRAIGHT);
401  return;
402  }
403 
404  // ok, what we want to do in this case is to determine which incoming
405  // has the best continuation...
406  // This means, when several incoming roads have the same priority,
407  // we want a (any) straight connection to be more priorised than a turning
408  double bestAngle = 0;
409  NBEdge* bestFirst = nullptr;
410  NBEdge* bestSecond = nullptr;
411  bool hadBest = false;
412  for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
413  EdgeVector::iterator j;
414  NBEdge* t1 = *i;
415  double angle1 = t1->getAngleAtNode(&n) + 180;
416  if (angle1 >= 360) {
417  angle1 -= 360;
418  }
419  for (j = i + 1; j != bestIncoming.end(); ++j) {
420  NBEdge* t2 = *j;
421  double angle2 = t2->getAngleAtNode(&n) + 180;
422  if (angle2 >= 360) {
423  angle2 -= 360;
424  }
425  double angle = GeomHelper::getMinAngleDiff(angle1, angle2);
426  if (!hadBest || angle > bestAngle) {
427  bestAngle = angle;
428  bestFirst = *i;
429  bestSecond = *j;
430  hadBest = true;
431  }
432  }
433  }
434  bestFirst->setJunctionPriority(&n, 1);
435  sort(bestOutgoing.begin(), bestOutgoing.end(), NBContHelper::edge_similar_direction_sorter(bestFirst));
436  if (bestOutgoing.size() != 0) {
437  extractAndMarkFirst(n, bestOutgoing);
438  }
439  bestSecond->setJunctionPriority(&n, 1);
440  sort(bestOutgoing.begin(), bestOutgoing.end(), NBContHelper::edge_similar_direction_sorter(bestSecond));
441  if (bestOutgoing.size() != 0) {
442  extractAndMarkFirst(n, bestOutgoing);
443  }
444  n.markBentPriority(GeomHelper::getMinAngleDiff(bestFirst->getAngleAtNode(&n), bestSecond->getAngleAtNode(&n)) < 135);
445  markBestParallel(n, bestFirst, bestSecond);
446 }
447 
448 
449 void
450 NBEdgePriorityComputer::markBestParallel(const NBNode& n, NBEdge* bestFirst, NBEdge* bestSecond) {
451  // edges running parallel to the main direction should also be prioritised
452  const double a1 = bestFirst->getAngleAtNode(&n);
453  const double a2 = bestSecond == nullptr ? a1 : bestSecond->getAngleAtNode(&n);
454  SVCPermissions p1 = bestFirst->getPermissions();
455  SVCPermissions p2 = bestSecond == nullptr ? p1 : bestSecond->getPermissions();
456  for (NBEdge* e : n.getIncomingEdges()) {
457  // @note: this rule might also apply if there are common permissions but
458  // then we would not further rules to resolve the priority between the best edge and its parallel edge
459  SVCPermissions perm = e->getPermissions();
460  if (((GeomHelper::getMinAngleDiff(e->getAngleAtNode(&n), a1) < 10
461  || GeomHelper::getMinAngleDiff(e->getAngleAtNode(&n), a2) < 10))
462  && (p1 & perm) == 0 && (p2 & perm) == 0) {
463  e->setJunctionPriority(&n, 1);
464  }
465  }
466 }
467 
468 
469 NBEdge*
470 NBEdgePriorityComputer::extractAndMarkFirst(NBNode& n, std::vector<NBEdge*>& s, int prio) {
471  if (s.size() == 0) {
472  return nullptr;
473  }
474  NBEdge* ret = s.front();
475  s.erase(s.begin());
476  ret->setJunctionPriority(&n, prio);
477  return ret;
478 }
479 
480 
481 bool
482 NBEdgePriorityComputer::samePriority(const NBEdge* const e1, const NBEdge* const e2) {
483  if (e1 == e2) {
484  return true;
485  }
486  if (e1->getPriority() != e2->getPriority()) {
487  return false;
488  }
489  if ((int) e1->getSpeed() != (int) e2->getSpeed()) {
490  return false;
491  }
492  return (int) e1->getNumLanes() == (int) e2->getNumLanes();
493 }
494 
495 
496 bool
498  if (edges.size() < 2) {
499  return false;
500  }
501  int prio = edges[0] == excluded ? edges[1]->getPriority() : edges[0]->getPriority();
502  for (auto e : edges) {
503  if (e != excluded && e->getPriority() != prio) {
504  return true;
505  }
506  }
507  return false;
508 }
509 
510 
512  // reorder based on getAngleAtNodeToCenter
513  myOrdering = ordering;
515  // let the first edge remain the first
516  rotate(myOrdering.begin(), std::find(myOrdering.begin(), myOrdering.end(), ordering.front()), myOrdering.end());
517 }
518 
519 
520 /****************************************************************************/
521 
NBNodeTypeComputer::validateRailCrossings
static void validateRailCrossings(NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Checks rail_crossing for validity.
Definition: NBAlgorithms.cpp:236
NODETYPE_PRIORITY
@ NODETYPE_PRIORITY
Definition: SUMOXMLDefinitions.h:1061
SVC_PEDESTRIAN
@ SVC_PEDESTRIAN
pedestrian
Definition: SUMOVehicleClass.h:156
ToString.h
NBTurningDirectionsComputer::Combination::to
NBEdge * to
Definition: NBAlgorithms.h:69
NBTurningDirectionsComputer::Combination::from
NBEdge * from
Definition: NBAlgorithms.h:68
NBEdgePriorityComputer::extractAndMarkFirst
static NBEdge * extractAndMarkFirst(NBNode &n, std::vector< NBEdge * > &s, int prio=1)
Sets the priorites in case of a priority junction.
Definition: NBAlgorithms.cpp:470
NBEdgePriorityComputer::samePriority
static bool samePriority(const NBEdge *const e1, const NBEdge *const e2)
Returns whether both edges have the same priority.
Definition: NBAlgorithms.cpp:482
NBNodesEdgesSorter::crossing_by_junction_angle_sorter::crossing_by_junction_angle_sorter
crossing_by_junction_angle_sorter(const NBNode *node, const EdgeVector &ordering)
Definition: NBAlgorithms.cpp:511
NBContHelper::edge_similar_direction_sorter
Definition: NBContHelper.h:217
NBTrafficLightLogicCont
A container for traffic light definitions and built programs.
Definition: NBTrafficLightLogicCont.h:57
NBNode::myType
SumoXMLNodeType myType
The type of the junction.
Definition: NBNode.h:831
NBNodeCont::end
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
Definition: NBNodeCont.h:120
NBEdgePriorityComputer::setPriorityJunctionPriorities
static void setPriorityJunctionPriorities(NBNode &n)
Sets the priorites in case of a priority junction.
Definition: NBAlgorithms.cpp:325
NBNodesEdgesSorter::swapWhenReversed
static void swapWhenReversed(const NBNode *const n, const std::vector< NBEdge * >::iterator &i1, const std::vector< NBEdge * >::iterator &i2)
Assures correct order for same-angle opposite-direction edges.
Definition: NBAlgorithms.cpp:144
OptionsCont.h
NBEdge::setJunctionPriority
void setJunctionPriority(const NBNode *const node, int prio)
Sets the junction priority of the edge.
Definition: NBEdge.cpp:1826
GeomHelper::getMinAngleDiff
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
Definition: GeomHelper.cpp:174
MsgHandler.h
EdgeVector
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
NBEdge::isTurningDirectionAt
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
Definition: NBEdge.cpp:2756
NBNode::getOutgoingEdges
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
Definition: NBNode.h:260
TrafficLightType
TrafficLightType
Definition: SUMOXMLDefinitions.h:1197
NBNodesEdgesSorter::crossing_by_junction_angle_sorter::myOrdering
EdgeVector myOrdering
Definition: NBAlgorithms.h:138
NBEdge::MINOR_ROAD
@ MINOR_ROAD
Definition: NBEdge.h:346
NBNodeCont::begin
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
Definition: NBNodeCont.h:115
NBHelpers::normRelAngle
static double normRelAngle(double angle1, double angle2)
ensure that reverse relAngles (>=179.999) always count as turnarounds (-180)
Definition: NBHelpers.cpp:59
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:222
NBOwnTLDef
A traffic light logics which must be computed (only nodes/edges are given)
Definition: NBOwnTLDef.h:46
NODETYPE_UNKNOWN
@ NODETYPE_UNKNOWN
Definition: SUMOXMLDefinitions.h:1055
NBEdgePriorityComputer::markBestParallel
static void markBestParallel(const NBNode &n, NBEdge *bestFirst, NBEdge *bestSecond)
set priority for edges that are parallel to the best edges
Definition: NBAlgorithms.cpp:450
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
NBEdge::getPriority
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:484
NBEdgePriorityComputer::computeEdgePriorities
static void computeEdgePriorities(NBNodeCont &nc)
Computes edge priorities within a node.
Definition: NBAlgorithms.cpp:299
NBNodesEdgesSorter::sortNodesEdges
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node's edges clockwise regarding driving direction.
Definition: NBAlgorithms.cpp:136
WRITE_WARNINGF
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:276
NBEdge::getPermissions
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:3404
RIGHT_OF_WAY_EDGEPRIORITY
@ RIGHT_OF_WAY_EDGEPRIORITY
Definition: SUMOXMLDefinitions.h:1106
NBNodeCont
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:59
NBTurningDirectionsComputer::combination_by_angle_sorter
Sorts "Combination"s by decreasing angle.
Definition: NBAlgorithms.h:77
NBContHelper::edge_by_priority_sorter
Definition: NBContHelper.h:117
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:91
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
NBTurningDirectionsComputer::Combination::angle
double angle
Definition: NBAlgorithms.h:70
NBTurningDirectionsComputer::computeTurnDirectionsForNode
static void computeTurnDirectionsForNode(NBNode *node, bool warn)
Computes turnaround destinations for all incoming edges of the given nodes (if any)
Definition: NBAlgorithms.cpp:54
NODETYPE_ALLWAY_STOP
@ NODETYPE_ALLWAY_STOP
Definition: SUMOXMLDefinitions.h:1064
LINKDIR_STRAIGHT
@ LINKDIR_STRAIGHT
The link is a straight direction.
Definition: SUMOXMLDefinitions.h:1178
NBEdge::getToNode
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:498
NBEdge::getGeometry
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:692
NBNode::getOppositeIncoming
NBEdge * getOppositeIncoming(NBEdge *e) const
returns the opposite incoming edge of certain edge
Definition: NBNode.cpp:1543
NBTurningDirectionsComputer::Combination
Stores the information about the angle between an incoming ("from") and an outgoing ("to") edge.
Definition: NBAlgorithms.h:67
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
SVC_RAIL_CLASSES
@ SVC_RAIL_CLASSES
classes which drive on tracks
Definition: SUMOVehicleClass.h:204
SumoXMLNodeType
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Definition: SUMOXMLDefinitions.h:1054
StringBijection::get
T get(const std::string &str) const
Definition: StringBijection.h:97
NBTypeCont.h
isWaterway
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
Definition: SUMOVehicleClass.cpp:369
NBNode::removeTrafficLight
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
Definition: NBNode.cpp:371
NBNode::getDirection
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream's direction.
Definition: NBNode.cpp:1933
NBEdge::getNumLanes
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:477
OptionsCont::isInStringVector
bool isInStringVector(const std::string &optionName, const std::string &itemName) const
Returns the named option is a list of string values containing the specified item.
Definition: OptionsCont.cpp:920
NBEdge::PRIORITY_ROAD
@ PRIORITY_ROAD
Definition: NBEdge.h:347
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
NBNode::getEdges
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
Definition: NBNode.h:265
NODETYPE_RAIL_CROSSING
@ NODETYPE_RAIL_CROSSING
Definition: SUMOXMLDefinitions.h:1060
NODETYPE_RIGHT_BEFORE_LEFT
@ NODETYPE_RIGHT_BEFORE_LEFT
Definition: SUMOXMLDefinitions.h:1063
NODETYPE_DEAD_END
@ NODETYPE_DEAD_END
Definition: SUMOXMLDefinitions.h:1069
NBContHelper::edge_by_angle_to_nodeShapeCentroid_sorter
Definition: NBContHelper.h:395
NBNode::myOutgoingEdges
EdgeVector myOutgoingEdges
Vector of outgoing edges.
Definition: NBNode.h:816
NBEdge::getIncomingEdges
EdgeVector getIncomingEdges() const
Returns the list of incoming edges unsorted.
Definition: NBEdge.cpp:1211
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:208
NBNode::myTypeWasGuessed
bool myTypeWasGuessed
whether the node type was guessed rather than loaded
Definition: NBNode.h:878
NBNodeCont.h
NBEdgePriorityComputer::hasDifferentPriorities
static bool hasDifferentPriorities(const EdgeVector &edges, const NBEdge *excluded)
return whether the priorite attribute can be used to distinguish the edges
Definition: NBAlgorithms.cpp:497
NBEdge::getSpeed
double getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:571
NBNode::geometryLike
bool geometryLike() const
whether this is structurally similar to a geometry node
Definition: NBNode.cpp:3026
NBNode::getIncomingEdges
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
Definition: NBNode.h:255
NBNode::isSimpleContinuation
bool isSimpleContinuation(bool checkLaneNumbers=true, bool checkWidth=false) const
check if node is a simple continuation
Definition: NBNode.cpp:471
SUMOXMLDefinitions::TrafficLightTypes
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
Definition: SUMOXMLDefinitions.h:1392
NBNodeTypeComputer::isRailwayNode
static bool isRailwayNode(const NBNode *n)
whether the given node only has rail edges
Definition: NBAlgorithms.cpp:282
NBNode::myIncomingEdges
EdgeVector myIncomingEdges
Vector of incoming edges.
Definition: NBNode.h:813
NBContHelper::edge_opposite_direction_sorter
Class to sort edges by their angle in relation to the given edge.
Definition: NBContHelper.h:140
config.h
NBTurningDirectionsComputer::computeTurnDirections
static void computeTurnDirections(NBNodeCont &nc, bool warn=true)
Computes turnaround destinations for all edges (if exist)
Definition: NBAlgorithms.cpp:47
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:67
NBOwnTLDef.h
NBTrafficLightLogicCont.h
NBAlgorithms.h
NBTrafficLightLogicCont::insert
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
Definition: NBTrafficLightLogicCont.cpp:73
NBNode.h
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
NBEdge::getAngleAtNode
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
Definition: NBEdge.cpp:1836
POSITION_EPS
#define POSITION_EPS
Definition: config.h:172
NBNodeTypeComputer::computeNodeTypes
static void computeNodeTypes(NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Computes node types.
Definition: NBAlgorithms.cpp:163
NBEdge::getFromNode
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:491
NBNode::isDistrict
bool isDistrict() const
check if node is a district
Definition: NBNode.cpp:2186
NBTrafficLightDefinition
The base class for traffic light logic definitions.
Definition: NBTrafficLightDefinition.h:67
NBEdge.h
NBNode::markBentPriority
void markBentPriority(bool isBent)
mark whether a priority road turns at this node
Definition: NBNode.h:754
NODETYPE_NOJUNCTION
@ NODETYPE_NOJUNCTION
Definition: SUMOXMLDefinitions.h:1067
NBNode::isNearDistrict
bool isNearDistrict() const
@chech if node is near district
Definition: NBNode.cpp:2169
NODETYPE_TRAFFIC_LIGHT
@ NODETYPE_TRAFFIC_LIGHT
Definition: SUMOXMLDefinitions.h:1056