SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBNode.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // The representation of a single node
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <map>
36 #include <cassert>
37 #include <algorithm>
38 #include <vector>
39 #include <deque>
40 #include <set>
41 #include <cmath>
42 #include <iterator>
46 #include <utils/geom/Line.h>
47 #include <utils/geom/GeomHelper.h>
48 #include <utils/geom/bezier.h>
50 #include <utils/common/StdDefs.h>
51 #include <utils/common/ToString.h>
54 #include <iomanip>
55 #include "NBNode.h"
56 #include "NBNodeCont.h"
57 #include "NBNodeShapeComputer.h"
58 #include "NBEdgeCont.h"
59 #include "NBTypeCont.h"
60 #include "NBHelpers.h"
61 #include "NBDistrict.h"
62 #include "NBContHelper.h"
63 #include "NBRequest.h"
64 #include "NBOwnTLDef.h"
66 
67 #ifdef CHECK_MEMORY_LEAKS
68 #include <foreign/nvwa/debug_new.h>
69 #endif // CHECK_MEMORY_LEAKS
70 
71 
72 // ===========================================================================
73 // static members
74 // ===========================================================================
75 
76 // ===========================================================================
77 // method definitions
78 // ===========================================================================
79 /* -------------------------------------------------------------------------
80  * NBNode::ApproachingDivider-methods
81  * ----------------------------------------------------------------------- */
83  EdgeVector* approaching, NBEdge* currentOutgoing) :
84  myApproaching(approaching), myCurrentOutgoing(currentOutgoing) {
85  // check whether origin lanes have been given
86  assert(myApproaching != 0);
87 }
88 
89 
91 
92 
93 void
94 NBNode::ApproachingDivider::execute(const unsigned int src, const unsigned int dest) {
95  assert(myApproaching->size() > src);
96  // get the origin edge
97  NBEdge* incomingEdge = (*myApproaching)[src];
98  if (incomingEdge->getStep() == NBEdge::LANES2LANES_DONE || incomingEdge->getStep() == NBEdge::LANES2LANES_USER) {
99  return;
100  }
101  std::vector<int> approachingLanes =
102  incomingEdge->getConnectionLanes(myCurrentOutgoing);
103  assert(approachingLanes.size() != 0);
104  std::deque<int> *approachedLanes = spread(approachingLanes, dest);
105  assert(approachedLanes->size() <= myCurrentOutgoing->getNumLanes());
106  // set lanes
107  for (unsigned int i = 0; i < approachedLanes->size(); i++) {
108  unsigned int approached = (*approachedLanes)[i];
109  assert(approachedLanes->size() > i);
110  assert(approachingLanes.size() > i);
111  incomingEdge->setConnection((unsigned int) approachingLanes[i], myCurrentOutgoing,
112  approached, NBEdge::L2L_COMPUTED);
113  }
114  delete approachedLanes;
115 }
116 
117 
118 std::deque<int> *
119 NBNode::ApproachingDivider::spread(const std::vector<int> &approachingLanes,
120  int dest) const {
121  std::deque<int> *ret = new std::deque<int>();
122  unsigned int noLanes = (unsigned int) approachingLanes.size();
123  // when only one lane is approached, we check, whether the SUMOReal-value
124  // is assigned more to the left or right lane
125  if (noLanes == 1) {
126  ret->push_back(dest);
127  return ret;
128  }
129 
130  unsigned int noOutgoingLanes = myCurrentOutgoing->getNumLanes();
131  //
132  ret->push_back(dest);
133  unsigned int noSet = 1;
134  int roffset = 1;
135  int loffset = 1;
136  while (noSet < noLanes) {
137  // It may be possible, that there are not enough lanes the source
138  // lanes may be divided on
139  // In this case, they remain unset
140  // !!! this is only a hack. It is possible, that this yields in
141  // uncommon divisions
142  if (noOutgoingLanes == noSet) {
143  return ret;
144  }
145 
146  // as due to the conversion of SUMOReal->uint the numbers will be lower
147  // than they should be, we try to append to the left side first
148  //
149  // check whether the left boundary of the approached street has
150  // been overridden; if so, move all lanes to the right
151  if (dest + loffset >= static_cast<int>(noOutgoingLanes)) {
152  loffset -= 1;
153  roffset += 1;
154  for (unsigned int i = 0; i < ret->size(); i++) {
155  (*ret)[i] = (*ret)[i] - 1;
156  }
157  }
158  // append the next lane to the left of all edges
159  // increase the position (destination edge)
160  ret->push_back(dest + loffset);
161  noSet++;
162  loffset += 1;
163 
164  // as above
165  if (noOutgoingLanes == noSet) {
166  return ret;
167  }
168 
169  // now we try to append the next lane to the right side, when needed
170  if (noSet < noLanes) {
171  // check whether the right boundary of the approached street has
172  // been overridden; if so, move all lanes to the right
173  if (dest < roffset) {
174  loffset += 1;
175  roffset -= 1;
176  for (unsigned int i = 0; i < ret->size(); i++) {
177  (*ret)[i] = (*ret)[i] + 1;
178  }
179  }
180  ret->push_front(dest - roffset);
181  noSet++;
182  roffset += 1;
183  }
184  }
185  return ret;
186 }
187 
188 
189 
190 
191 /* -------------------------------------------------------------------------
192  * NBNode-methods
193  * ----------------------------------------------------------------------- */
194 NBNode::NBNode(const std::string& id, const Position& position) :
195  Named(StringUtils::convertUmlaute(id)),
196  myPosition(position),
198 { }
199 
200 
201 NBNode::NBNode(const std::string& id, const Position& position,
202  SumoXMLNodeType type) :
203  Named(StringUtils::convertUmlaute(id)),
204  myPosition(position),
205  myType(type), myDistrict(0), myRequest(0)
206 { }
207 
208 
209 NBNode::NBNode(const std::string& id, const Position& position, NBDistrict* district) :
210  Named(StringUtils::convertUmlaute(id)),
211  myPosition(position),
212  myType(NODETYPE_DISTRICT), myDistrict(district), myRequest(0)
213 { }
214 
215 
217  delete myRequest;
218 }
219 
220 
221 void
223  bool updateEdgeGeometries) {
224  myPosition = position;
225  // patch type
226  myType = type;
229  }
230  if (updateEdgeGeometries) {
231  for (EdgeVector::iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
232  PositionVector geom = (*i)->getGeometry();
233  geom[-1] = myPosition;
234  (*i)->setGeometry(geom);
235  }
236  for (EdgeVector::iterator i = myOutgoingEdges.begin(); i != myOutgoingEdges.end(); i++) {
237  PositionVector geom = (*i)->getGeometry();
238  geom[0] = myPosition;
239  (*i)->setGeometry(geom);
240  }
241  }
242 }
243 
244 
245 
246 // ----------- Applying offset
247 void
249  myPosition.add(xoff, yoff, 0);
250  myPoly.add(xoff, yoff, 0);
251 }
252 
253 
254 // ----------- Methods for dealing with assigned traffic lights
255 void
257  myTrafficLights.insert(tlDef);
259 }
260 
261 
262 void
264  tlDef->removeNode(this);
265  myTrafficLights.erase(tlDef);
266 }
267 
268 
269 void
271  std::set<NBTrafficLightDefinition*> trafficLights = myTrafficLights; // make a copy because we will modify the original
272  for (std::set<NBTrafficLightDefinition*>::const_iterator i = trafficLights.begin(); i != trafficLights.end(); ++i) {
273  removeTrafficLight(*i);
274  }
275 }
276 
277 
278 bool
280  if (!isTLControlled()) {
281  return false;
282  }
283  for (std::set<NBTrafficLightDefinition*>::const_iterator i = myTrafficLights.begin(); i != myTrafficLights.end(); ++i) {
284  if ((*i)->getID().find("joined") == 0) {
285  return true;
286  }
287  }
288  return false;
289 }
290 
291 
292 // ----------- Prunning the input
293 unsigned int
295  unsigned int ret = 0;
296  unsigned int pos = 0;
297  EdgeVector::const_iterator j = myIncomingEdges.begin();
298  while (j != myIncomingEdges.end()) {
299  // skip edges which are only incoming and not outgoing
300  if (find(myOutgoingEdges.begin(), myOutgoingEdges.end(), *j) == myOutgoingEdges.end()) {
301  ++j;
302  ++pos;
303  continue;
304  }
305  // an edge with both its origin and destination being the current
306  // node should be removed
307  NBEdge* dummy = *j;
308  WRITE_WARNING(" Removing self-looping edge '" + dummy->getID() + "'");
309  // get the list of incoming edges connected to the self-loop
310  EdgeVector incomingConnected;
311  for (EdgeVector::const_iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
312  if ((*i)->isConnectedTo(dummy) && *i != dummy) {
313  incomingConnected.push_back(*i);
314  }
315  }
316  // get the list of outgoing edges connected to the self-loop
317  EdgeVector outgoingConnected;
318  for (EdgeVector::const_iterator i = myOutgoingEdges.begin(); i != myOutgoingEdges.end(); i++) {
319  if (dummy->isConnectedTo(*i) && *i != dummy) {
320  outgoingConnected.push_back(*i);
321  }
322  }
323  // let the self-loop remap its connections
324  dummy->remapConnections(incomingConnected);
325  remapRemoved(tc, dummy, incomingConnected, outgoingConnected);
326  // delete the self-loop
327  ec.erase(dc, dummy);
328  j = myIncomingEdges.begin() + pos;
329  ++ret;
330  }
331  return ret;
332 }
333 
334 
335 // -----------
336 void
338  assert(edge != 0);
339  if (find(myIncomingEdges.begin(), myIncomingEdges.end(), edge) == myIncomingEdges.end()) {
340  myIncomingEdges.push_back(edge);
341  myAllEdges.push_back(edge);
342  }
343 }
344 
345 
346 void
348  assert(edge != 0);
349  if (find(myOutgoingEdges.begin(), myOutgoingEdges.end(), edge) == myOutgoingEdges.end()) {
350  myOutgoingEdges.push_back(edge);
351  myAllEdges.push_back(edge);
352  }
353 }
354 
355 
356 bool
358  // one in, one out->continuation
359  if (myIncomingEdges.size() == 1 && myOutgoingEdges.size() == 1) {
360  // both must have the same number of lanes
361  return (*(myIncomingEdges.begin()))->getNumLanes() == (*(myOutgoingEdges.begin()))->getNumLanes();
362  }
363  // two in and two out and both in reverse direction
364  if (myIncomingEdges.size() == 2 && myOutgoingEdges.size() == 2) {
365  for (EdgeVector::const_iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
366  NBEdge* in = *i;
367  EdgeVector::const_iterator opposite = find_if(myOutgoingEdges.begin(), myOutgoingEdges.end(), NBContHelper::opposite_finder(in, this));
368  // must have an opposite edge
369  if (opposite == myOutgoingEdges.end()) {
370  return false;
371  }
372  // both must have the same number of lanes
374  if (in->getNumLanes() != (*opposite)->getNumLanes()) {
375  return false;
376  }
377  }
378  return true;
379  }
380  // nope
381  return false;
382 }
383 
384 
387  NBEdge* toE, int toL, int numPoints) const {
388  if (fromL >= (int) fromE->getNumLanes()) {
389  throw ProcessError("Connection '" + fromE->getID() + "_" + toString(fromL) + "->" + toE->getID() + "_" + toString(toL) + "' starts at a not existing lane.");
390  }
391  if (toL >= (int) toE->getNumLanes()) {
392  throw ProcessError("Connection '" + fromE->getID() + "_" + toString(fromL) + "->" + toE->getID() + "_" + toString(toL) + "' yields in a not existing lane.");
393  }
394  bool noSpline = false;
395  PositionVector ret;
396  PositionVector init;
397  Position beg = fromE->getLaneShape(fromL).getEnd();
398  Position end = toE->getLaneShape(toL).getBegin();
399  Position intersection;
400  unsigned int noInitialPoints = 0;
401  if (beg.distanceTo(end) <= POSITION_EPS) {
402  noSpline = true;
403  } else {
404  if (fromE->getTurnDestination() == toE) {
405  // turnarounds:
406  // - end of incoming lane
407  // - position between incoming/outgoing end/begin shifted by the distance orthogonally
408  // - begin of outgoing lane
409  noInitialPoints = 3;
410  init.push_back(beg);
411  Line straightConn(fromE->getLaneShape(fromL)[-1], toE->getLaneShape(toL)[0]);
412  Position straightCenter = straightConn.getPositionAtDistance((SUMOReal) straightConn.length() / (SUMOReal) 2.);
413  Position center = straightCenter;//.add(straightCenter);
414  Line cross(straightConn);
415  cross.sub(cross.p1().x(), cross.p1().y());
416  cross.rotateAtP1(PI / 2);
417  center.sub(cross.p2());
418  init.push_back(center);
419  init.push_back(end);
420  } else {
421  const SUMOReal angle = fabs(fromE->getLaneShape(fromL).getEndLine().atan2Angle() - toE->getLaneShape(toL).getBegLine().atan2Angle());
422  if (angle < PI / 4. || angle > 7. / 4.*PI) {
423  // very low angle: almost straight
424  noInitialPoints = 4;
425  init.push_back(beg);
426  Line begL = fromE->getLaneShape(fromL).getEndLine();
427  begL.extrapolateSecondBy(100);
428  Line endL = toE->getLaneShape(toL).getBegLine();
429  endL.extrapolateFirstBy(100);
430  SUMOReal distance = beg.distanceTo(end);
431  if (distance > 10) {
432  {
433  SUMOReal off1 = fromE->getLaneShape(fromL).getEndLine().length() + (SUMOReal) 5. * (SUMOReal) fromE->getNumLanes();
434  off1 = MIN2(off1, (SUMOReal)(fromE->getLaneShape(fromL).getEndLine().length() + distance / 2.));
435  Position tmp = begL.getPositionAtDistance(off1);
436  init.push_back(tmp);
437  }
438  {
439  SUMOReal off1 = (SUMOReal) 100. - (SUMOReal) 5. * (SUMOReal) toE->getNumLanes();
440  off1 = MAX2(off1, (SUMOReal)(100. - distance / 2.));
441  Position tmp = endL.getPositionAtDistance(off1);
442  init.push_back(tmp);
443  }
444  } else {
445  noSpline = true;
446  }
447  init.push_back(end);
448  } else {
449  // turning
450  // - end of incoming lane
451  // - intersection of the extrapolated lanes
452  // - begin of outgoing lane
453  // attention: if there is no intersection, use a straight line
454  noInitialPoints = 3;
455  init.push_back(beg);
456  Line begL = fromE->getLaneShape(fromL).getEndLine();
457  Line endL = toE->getLaneShape(toL).getBegLine();
458  bool check = !begL.p1().almostSame(begL.p2()) && !endL.p1().almostSame(endL.p2());
459  if (check) {
460  begL.extrapolateSecondBy(100);
461  endL.extrapolateFirstBy(100);
462  } else {
463  WRITE_WARNING("Could not use edge geometry for internal lane, node '" + getID() + "'.");
464  }
465  if (!check || !begL.intersects(endL)) {
466  noSpline = true;
467  } else {
468  init.push_back(begL.intersectsAt(endL));
469  }
470  init.push_back(end);
471  }
472  }
473  }
474  //
475  if (noSpline) {
476  ret.push_back(fromE->getLaneShape(fromL).getEnd());
477  ret.push_back(toE->getLaneShape(toL).getBegin());
478  } else {
479  SUMOReal* def = new SUMOReal[1 + noInitialPoints * 3];
480  for (int i = 0; i < (int) init.size(); ++i) {
481  // starts at index 1
482  def[i * 3 + 1] = init[i].x();
483  def[i * 3 + 2] = 0;
484  def[i * 3 + 3] = init[i].y();
485  }
486  SUMOReal* ret_buf = new SUMOReal[numPoints * 3 + 1];
487  bezier(noInitialPoints, def, numPoints, ret_buf);
488  delete[] def;
489  Position prev;
490  for (int i = 0; i < (int) numPoints; i++) {
491  Position current(ret_buf[i * 3 + 1], ret_buf[i * 3 + 3]);
492  if (prev != current) {
493  ret.push_back(current);
494  }
495  prev = current;
496  }
497  delete[] ret_buf;
498  }
499  const NBEdge::Lane& lane = fromE->getLaneStruct(fromL);
500  if (lane.offset > 0) {
501  PositionVector beg = lane.shape.getSubpart(lane.shape.length() - lane.offset, lane.shape.length());;
502  beg.appendWithCrossingPoint(ret);
503  ret = beg;
504  }
505  return ret;
506 }
507 
508 
509 bool
510 NBNode::needsCont(NBEdge* fromE, NBEdge* toE, NBEdge* otherFromE, NBEdge* otherToE, const NBEdge::Connection& c) const {
512  return false;
513  }
514  if (fromE == otherFromE) {
515  // ignore same edge links
516  return false;
517  }
518  if (!foes(otherFromE, otherToE, fromE, toE)) {
519  // if they do not cross, no waiting place is needed
520  return false;
521  }
522  LinkDirection d1 = getDirection(fromE, toE);
523  LinkDirection d2 = getDirection(otherFromE, otherToE);
524  bool thisLeft = (d1 == LINKDIR_LEFT || d1 == LINKDIR_TURN);
525  bool otherLeft = (d2 == LINKDIR_LEFT || d2 == LINKDIR_TURN);
526  bool bothLeft = thisLeft && otherLeft;
527  if (c.tlID != "" && !bothLeft) {
528  // tls-controlled links will have space
529  return true;
530  }
531  if (fromE->getJunctionPriority(this) > 0 && otherFromE->getJunctionPriority(this) > 0) {
532  return mustBrake(fromE, toE, c.toLane);
533  }
534  return false;
535 }
536 
537 
538 void
540  delete myRequest; // possibly recomputation step
541  myRequest = 0;
542  if (myIncomingEdges.size() == 0 || myOutgoingEdges.size() == 0) {
543  // no logic if nothing happens here
545  return;
546  }
547  // check whether the node was set to be unregulated by the user
548  if (oc.getBool("keep-nodes-unregulated") || oc.isInStringVector("keep-nodes-unregulated.explicit", getID())
549  || (oc.getBool("keep-nodes-unregulated.district-nodes") && (isNearDistrict() || isDistrict()))) {
551  return;
552  }
553  // compute the logic if necessary or split the junction
555  // build the request
556  myRequest = new NBRequest(ec, this,
558  // check whether it is not too large
559  unsigned int numConnections = myRequest->getSizes().second;
560  if (numConnections >= 64) {
561  // yep -> make it untcontrolled, warn
562  WRITE_WARNING("Junction '" + getID() + "' is too complicated (#links>64); will be set to unregulated.");
563  delete myRequest;
564  myRequest = 0;
566  } else if (numConnections == 0) {
567  delete myRequest;
568  myRequest = 0;
570  } else {
572  }
573  }
574 }
575 
576 
577 bool
579  if (myRequest) {
580  myRequest->writeLogic(myID, into);
581  return true;
582  }
583  return false;
584 }
585 
586 
587 void
588 NBNode::computeNodeShape(bool leftHand) {
589  if (myIncomingEdges.size() == 0 && myOutgoingEdges.size() == 0) {
590  return;
591  }
592  try {
593  NBNodeShapeComputer computer(*this);
594  myPoly = computer.compute(leftHand);
595  } catch (InvalidArgument&) {
596  WRITE_WARNING("For node '" + getID() + "': could not compute shape.");
597  }
598 }
599 
600 
601 void
603  // special case a):
604  // one in, one out, the outgoing has one lane more
605  if (myIncomingEdges.size() == 1 && myOutgoingEdges.size() == 1
606  && myIncomingEdges[0]->getNumLanes() == myOutgoingEdges[0]->getNumLanes() - 1
607  && myIncomingEdges[0] != myOutgoingEdges[0]
608  && myIncomingEdges[0]->isConnectedTo(myOutgoingEdges[0])) {
609 
610  NBEdge* incoming = myIncomingEdges[0];
611  NBEdge* outgoing = myOutgoingEdges[0];
612  // check if it's not the turnaround
613  if (incoming->getTurnDestination() == outgoing) {
614  // will be added later or not...
615  return;
616  }
617  for (int i = 0; i < (int) incoming->getNumLanes(); ++i) {
618  incoming->setConnection(i, outgoing, i + 1, NBEdge::L2L_COMPUTED);
619  }
620  incoming->setConnection(0, outgoing, 0, NBEdge::L2L_COMPUTED);
621  return;
622  }
623  // special case b):
624  // two in, one out, the outgoing has the same number of lanes as the sum of the incoming
625  // and a high speed, too
626  // --> highway on-ramp
627  bool check = false;
628  if (myIncomingEdges.size() == 2 && myOutgoingEdges.size() == 1) {
629  check = myIncomingEdges[0]->getNumLanes() + myIncomingEdges[1]->getNumLanes() == myOutgoingEdges[0]->getNumLanes();
630  check &= (myIncomingEdges[0]->getStep() <= NBEdge::LANES2EDGES);
631  check &= (myIncomingEdges[1]->getStep() <= NBEdge::LANES2EDGES);
632  }
633  if (check
634  && myIncomingEdges[0] != myOutgoingEdges[0]
635  && myIncomingEdges[0]->isConnectedTo(myOutgoingEdges[0])) {
636  NBEdge* inc1 = myIncomingEdges[0];
637  NBEdge* inc2 = myIncomingEdges[1];
638  // for internal: check which one is the rightmost
639  SUMOReal a1 = inc1->getAngleAtNode(this);
640  SUMOReal a2 = inc2->getAngleAtNode(this);
643  if (ccw < cw) {
644  std::swap(inc1, inc2);
645  }
646  //
647  inc1->addLane2LaneConnections(0, myOutgoingEdges[0], 0, inc1->getNumLanes(), NBEdge::L2L_VALIDATED, true, true);
648  inc2->addLane2LaneConnections(0, myOutgoingEdges[0], inc1->getNumLanes(), inc2->getNumLanes(), NBEdge::L2L_VALIDATED, true, true);
649  return;
650  }
651 
652  // go through this node's outgoing edges
653  // for every outgoing edge, compute the distribution of the node's
654  // incoming edges on this edge when approaching this edge
655  // the incoming edges' steps will then also be marked as LANE2LANE_RECHECK...
656  EdgeVector::reverse_iterator i;
657  for (i = myOutgoingEdges.rbegin(); i != myOutgoingEdges.rend(); i++) {
658  NBEdge* currentOutgoing = *i;
659  // get the information about edges that do approach this edge
660  EdgeVector* approaching = getEdgesThatApproach(currentOutgoing);
661  if (approaching->size() != 0) {
662  ApproachingDivider divider(approaching, currentOutgoing);
663  Bresenham::compute(&divider, static_cast<unsigned int>(approaching->size()),
664  currentOutgoing->getNumLanes());
665  }
666  delete approaching;
667  }
668  // ... but we may have the case that there are no outgoing edges
669  // In this case, we have to mark the incoming edges as being in state
670  // LANE2LANE( not RECHECK) by hand
671  if (myOutgoingEdges.size() == 0) {
672  for (i = myIncomingEdges.rbegin(); i != myIncomingEdges.rend(); i++) {
673  (*i)->markAsInLane2LaneState();
674  }
675  }
676 }
677 
678 
679 EdgeVector*
681  // get the position of the node to get the approaching nodes of
682  EdgeVector::const_iterator i = find(myAllEdges.begin(),
683  myAllEdges.end(), currentOutgoing);
684  // get the first possible approaching edge
686  // go through the list of edges clockwise and add the edges
687  EdgeVector* approaching = new EdgeVector();
688  for (; *i != currentOutgoing;) {
689  // check only incoming edges
690  if ((*i)->getToNode() == this && (*i)->getTurnDestination() != currentOutgoing) {
691  std::vector<int> connLanes = (*i)->getConnectionLanes(currentOutgoing);
692  if (connLanes.size() != 0) {
693  approaching->push_back(*i);
694  }
695  }
696  NBContHelper::nextCW(myAllEdges, i);
697  }
698  return approaching;
699 }
700 
701 
702 void
703 NBNode::replaceOutgoing(NBEdge* which, NBEdge* by, unsigned int laneOff) {
704  // replace the edge in the list of outgoing nodes
705  EdgeVector::iterator i = find(myOutgoingEdges.begin(), myOutgoingEdges.end(), which);
706  if (i != myOutgoingEdges.end()) {
707  (*i) = by;
708  i = find(myAllEdges.begin(), myAllEdges.end(), which);
709  (*i) = by;
710  }
711  // replace the edge in connections of incoming edges
712  for (i = myIncomingEdges.begin(); i != myIncomingEdges.end(); ++i) {
713  (*i)->replaceInConnections(which, by, laneOff);
714  }
715  // replace within the connetion prohibition dependencies
716  replaceInConnectionProhibitions(which, by, 0, laneOff);
717 }
718 
719 
720 void
722  // replace edges
723  unsigned int laneOff = 0;
724  for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
725  replaceOutgoing(*i, by, laneOff);
726  laneOff += (*i)->getNumLanes();
727  }
728  // removed SUMOReal occurences
730  // check whether this node belongs to a district and the edges
731  // must here be also remapped
732  if (myDistrict != 0) {
733  myDistrict->replaceOutgoing(which, by);
734  }
735 }
736 
737 
738 void
739 NBNode::replaceIncoming(NBEdge* which, NBEdge* by, unsigned int laneOff) {
740  // replace the edge in the list of incoming nodes
741  EdgeVector::iterator i = find(myIncomingEdges.begin(), myIncomingEdges.end(), which);
742  if (i != myIncomingEdges.end()) {
743  (*i) = by;
744  i = find(myAllEdges.begin(), myAllEdges.end(), which);
745  (*i) = by;
746  }
747  // replace within the connetion prohibition dependencies
748  replaceInConnectionProhibitions(which, by, laneOff, 0);
749 }
750 
751 
752 void
754  // replace edges
755  unsigned int laneOff = 0;
756  for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
757  replaceIncoming(*i, by, laneOff);
758  laneOff += (*i)->getNumLanes();
759  }
760  // removed SUMOReal occurences
762  // check whether this node belongs to a district and the edges
763  // must here be also remapped
764  if (myDistrict != 0) {
765  myDistrict->replaceIncoming(which, by);
766  }
767 }
768 
769 
770 
771 void
773  unsigned int whichLaneOff, unsigned int byLaneOff) {
774  // replace in keys
775  NBConnectionProhibits::iterator j = myBlockedConnections.begin();
776  while (j != myBlockedConnections.end()) {
777  bool changed = false;
778  NBConnection c = (*j).first;
779  if (c.replaceFrom(which, whichLaneOff, by, byLaneOff)) {
780  changed = true;
781  }
782  if (c.replaceTo(which, whichLaneOff, by, byLaneOff)) {
783  changed = true;
784  }
785  if (changed) {
786  myBlockedConnections[c] = (*j).second;
787  myBlockedConnections.erase(j);
788  j = myBlockedConnections.begin();
789  } else {
790  j++;
791  }
792  }
793  // replace in values
794  for (j = myBlockedConnections.begin(); j != myBlockedConnections.end(); j++) {
795  NBConnectionVector& prohibiting = (*j).second;
796  for (NBConnectionVector::iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
797  NBConnection& sprohibiting = *k;
798  sprohibiting.replaceFrom(which, whichLaneOff, by, byLaneOff);
799  sprohibiting.replaceTo(which, whichLaneOff, by, byLaneOff);
800  }
801  }
802 }
803 
804 
805 
806 void
808  unsigned int i, j;
809  // check incoming
810  for (i = 0; myIncomingEdges.size() > 0 && i < myIncomingEdges.size() - 1; i++) {
811  j = i + 1;
812  while (j < myIncomingEdges.size()) {
813  if (myIncomingEdges[i] == myIncomingEdges[j]) {
814  myIncomingEdges.erase(myIncomingEdges.begin() + j);
815  } else {
816  j++;
817  }
818  }
819  }
820  // check outgoing
821  for (i = 0; myOutgoingEdges.size() > 0 && i < myOutgoingEdges.size() - 1; i++) {
822  j = i + 1;
823  while (j < myOutgoingEdges.size()) {
824  if (myOutgoingEdges[i] == myOutgoingEdges[j]) {
825  myOutgoingEdges.erase(myOutgoingEdges.begin() + j);
826  } else {
827  j++;
828  }
829  }
830  }
831  // check all
832  for (i = 0; myAllEdges.size() > 0 && i < myAllEdges.size() - 1; i++) {
833  j = i + 1;
834  while (j < myAllEdges.size()) {
835  if (myAllEdges[i] == myAllEdges[j]) {
836  myAllEdges.erase(myAllEdges.begin() + j);
837  } else {
838  j++;
839  }
840  }
841  }
842 }
843 
844 
845 bool
846 NBNode::hasIncoming(const NBEdge* const e) const {
847  return find(myIncomingEdges.begin(), myIncomingEdges.end(), e) != myIncomingEdges.end();
848 }
849 
850 
851 bool
852 NBNode::hasOutgoing(const NBEdge* const e) const {
853  return find(myOutgoingEdges.begin(), myOutgoingEdges.end(), e) != myOutgoingEdges.end();
854 }
855 
856 
857 NBEdge*
859  EdgeVector edges = myIncomingEdges;
860  if (find(edges.begin(), edges.end(), e) != edges.end()) {
861  edges.erase(find(edges.begin(), edges.end(), e));
862  }
863  if (e->getToNode() == this) {
864  sort(edges.begin(), edges.end(), NBContHelper::edge_opposite_direction_sorter(e, this));
865  } else {
866  sort(edges.begin(), edges.end(), NBContHelper::edge_similar_direction_sorter(e));
867  }
868  return edges[0];
869 }
870 
871 
872 void
874  const NBConnection& mustStop) {
875  if (mayDrive.getFrom() == 0 ||
876  mayDrive.getTo() == 0 ||
877  mustStop.getFrom() == 0 ||
878  mustStop.getTo() == 0) {
879 
880  WRITE_WARNING("Something went wrong during the building of a connection...");
881  return; // !!! mark to recompute connections
882  }
883  NBConnectionVector conn = myBlockedConnections[mustStop];
884  conn.push_back(mayDrive);
885  myBlockedConnections[mustStop] = conn;
886 }
887 
888 
889 NBEdge*
890 NBNode::getPossiblySplittedIncoming(const std::string& edgeid) {
891  unsigned int size = (unsigned int) edgeid.length();
892  for (EdgeVector::iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
893  std::string id = (*i)->getID();
894  if (id.substr(0, size) == edgeid) {
895  return *i;
896  }
897  }
898  return 0;
899 }
900 
901 
902 NBEdge*
903 NBNode::getPossiblySplittedOutgoing(const std::string& edgeid) {
904  unsigned int size = (unsigned int) edgeid.length();
905  for (EdgeVector::iterator i = myOutgoingEdges.begin(); i != myOutgoingEdges.end(); i++) {
906  std::string id = (*i)->getID();
907  if (id.substr(0, size) == edgeid) {
908  return *i;
909  }
910  }
911  return 0;
912 }
913 
914 
915 void
916 NBNode::removeEdge(NBEdge* edge, bool removeFromConnections) {
917  EdgeVector::iterator i = find(myAllEdges.begin(), myAllEdges.end(), edge);
918  if (i != myAllEdges.end()) {
919  myAllEdges.erase(i);
920  i = find(myOutgoingEdges.begin(), myOutgoingEdges.end(), edge);
921  if (i != myOutgoingEdges.end()) {
922  myOutgoingEdges.erase(i);
923  } else {
924  i = find(myIncomingEdges.begin(), myIncomingEdges.end(), edge);
925  if (i != myIncomingEdges.end()) {
926  myIncomingEdges.erase(i);
927  } else {
928  // edge must have been either incoming or outgoing
929  assert(false);
930  }
931  }
932  if (removeFromConnections) {
933  for (i = myAllEdges.begin(); i != myAllEdges.end(); ++i) {
934  (*i)->removeFromConnections(edge);
935  }
936  }
937  }
938 }
939 
940 
941 Position
943  Position pos(0, 0);
944  EdgeVector::const_iterator i;
945  for (i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
946  NBNode* conn = (*i)->getFromNode();
947  Position toAdd = conn->getPosition();
948  toAdd.sub(myPosition);
949  toAdd.mul((SUMOReal) 1.0 / sqrt(toAdd.x()*toAdd.x() + toAdd.y()*toAdd.y()));
950  pos.add(toAdd);
951  }
952  for (i = myOutgoingEdges.begin(); i != myOutgoingEdges.end(); i++) {
953  NBNode* conn = (*i)->getToNode();
954  Position toAdd = conn->getPosition();
955  toAdd.sub(myPosition);
956  toAdd.mul((SUMOReal) 1.0 / sqrt(toAdd.x()*toAdd.x() + toAdd.y()*toAdd.y()));
957  pos.add(toAdd);
958  }
959  pos.mul((SUMOReal) - 1.0 / (myIncomingEdges.size() + myOutgoingEdges.size()));
960  if (pos.x() == 0 && pos.y() == 0) {
961  pos = Position(1, 0);
962  }
963  pos.norm2d();
964  return pos;
965 }
966 
967 
968 
969 void
971  for (EdgeVector::const_iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
972  (*i)->invalidateConnections();
973  }
974 }
975 
976 
977 void
979  for (EdgeVector::const_iterator i = myOutgoingEdges.begin(); i != myOutgoingEdges.end(); i++) {
980  (*i)->invalidateConnections();
981  }
982 }
983 
984 
985 bool
986 NBNode::mustBrake(const NBEdge* const from, const NBEdge* const to, int toLane) const {
987  // check whether it is participant to a traffic light
988  // - controlled links are set by the traffic lights, not the normal
989  // right-of-way rules
990  // - uncontrolled participants (spip lanes etc.) should always break
991  if (myTrafficLights.size() != 0) {
992  // ok, we have a traffic light, return true by now, it will be later
993  // controlled by the tls
994  return true;
995  }
996  // unregulated->does not need to brake
997  if (myRequest == 0) {
998  return false;
999  }
1000  // vehicles which do not have a following lane must always decelerate to the end
1001  if (to == 0) {
1002  return true;
1003  }
1004  // check whether any other connection on this node prohibits this connection
1005  bool try1 = myRequest->mustBrake(from, to);
1006  if (!try1 || toLane == -1) {
1007  return try1;
1008  }
1009  if (from->getSpeed() < 70. / 3.6) {
1010  return try1;
1011  }
1012  // on highways (on-ramps, in fact):
1013  // check whether any other connection uses the same destination edge
1014  for (EdgeVector::const_iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
1015  if ((*i) == from) {
1016  continue;
1017  }
1018  const std::vector<NBEdge::Connection> &connections = (*i)->getConnections();
1019  for (std::vector<NBEdge::Connection>::const_iterator j = connections.begin(); j != connections.end(); ++j) {
1020  if ((*j).toEdge == to && ((*j).toLane < 0 || (*j).toLane == toLane)) {
1021  return true;
1022  }
1023  }
1024  }
1025  return false;
1026 }
1027 
1028 
1029 bool
1030 NBNode::isLeftMover(const NBEdge* const from, const NBEdge* const to) const {
1031  // when the junction has only one incoming edge, there are no
1032  // problems caused by left blockings
1033  if (myIncomingEdges.size() == 1 || myOutgoingEdges.size() == 1) {
1034  return false;
1035  }
1036  SUMOReal fromAngle = from->getAngleAtNode(this);
1037  SUMOReal toAngle = to->getAngleAtNode(this);
1038  SUMOReal cw = GeomHelper::getCWAngleDiff(fromAngle, toAngle);
1039  SUMOReal ccw = GeomHelper::getCCWAngleDiff(fromAngle, toAngle);
1040  std::vector<NBEdge*>::const_iterator i = std::find(myAllEdges.begin(), myAllEdges.end(), from);
1041  do {
1043  } while ((!hasOutgoing(*i) || from->isTurningDirectionAt(this, *i)) && *i != from);
1044  return cw < ccw && (*i) == to && myOutgoingEdges.size() > 2;
1045 }
1046 
1047 
1048 bool
1049 NBNode::forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
1050  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
1051  bool regardNonSignalisedLowerPriority) const {
1052  return myRequest != 0 && myRequest->forbids(possProhibitorFrom, possProhibitorTo,
1053  possProhibitedFrom, possProhibitedTo,
1054  regardNonSignalisedLowerPriority);
1055 }
1056 
1057 
1058 bool
1059 NBNode::foes(const NBEdge* const from1, const NBEdge* const to1,
1060  const NBEdge* const from2, const NBEdge* const to2) const {
1061  return myRequest != 0 && myRequest->foes(from1, to1, from2, to2);
1062 }
1063 
1064 
1065 void
1067  NBEdge* removed, const EdgeVector& incoming,
1068  const EdgeVector& outgoing) {
1069  assert(find(incoming.begin(), incoming.end(), removed) == incoming.end());
1070  bool changed = true;
1071  while (changed) {
1072  changed = false;
1073  NBConnectionProhibits blockedConnectionsTmp = myBlockedConnections;
1074  NBConnectionProhibits blockedConnectionsNew;
1075  // remap in connections
1076  for (NBConnectionProhibits::iterator i = blockedConnectionsTmp.begin(); i != blockedConnectionsTmp.end(); i++) {
1077  const NBConnection& blocker = (*i).first;
1078  const NBConnectionVector& blocked = (*i).second;
1079  // check the blocked connections first
1080  // check whether any of the blocked must be changed
1081  bool blockedChanged = false;
1082  NBConnectionVector newBlocked;
1083  NBConnectionVector::const_iterator j;
1084  for (j = blocked.begin(); j != blocked.end(); j++) {
1085  const NBConnection& sblocked = *j;
1086  if (sblocked.getFrom() == removed || sblocked.getTo() == removed) {
1087  blockedChanged = true;
1088  }
1089  }
1090  // adapt changes if so
1091  for (j = blocked.begin(); blockedChanged && j != blocked.end(); j++) {
1092  const NBConnection& sblocked = *j;
1093  if (sblocked.getFrom() == removed && sblocked.getTo() == removed) {
1094  /* for(EdgeVector::const_iterator k=incoming.begin(); k!=incoming.end(); k++) {
1095  !!! newBlocked.push_back(NBConnection(*k, *k));
1096  }*/
1097  } else if (sblocked.getFrom() == removed) {
1098  assert(sblocked.getTo() != removed);
1099  for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1100  newBlocked.push_back(NBConnection(*k, sblocked.getTo()));
1101  }
1102  } else if (sblocked.getTo() == removed) {
1103  assert(sblocked.getFrom() != removed);
1104  for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1105  newBlocked.push_back(NBConnection(sblocked.getFrom(), *k));
1106  }
1107  } else {
1108  newBlocked.push_back(NBConnection(sblocked.getFrom(), sblocked.getTo()));
1109  }
1110  }
1111  if (blockedChanged) {
1112  blockedConnectionsNew[blocker] = newBlocked;
1113  changed = true;
1114  }
1115  // if the blocked were kept
1116  else {
1117  if (blocker.getFrom() == removed && blocker.getTo() == removed) {
1118  changed = true;
1119  /* for(EdgeVector::const_iterator k=incoming.begin(); k!=incoming.end(); k++) {
1120  !!! blockedConnectionsNew[NBConnection(*k, *k)] = blocked;
1121  }*/
1122  } else if (blocker.getFrom() == removed) {
1123  assert(blocker.getTo() != removed);
1124  changed = true;
1125  for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1126  blockedConnectionsNew[NBConnection(*k, blocker.getTo())] = blocked;
1127  }
1128  } else if (blocker.getTo() == removed) {
1129  assert(blocker.getFrom() != removed);
1130  changed = true;
1131  for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1132  blockedConnectionsNew[NBConnection(blocker.getFrom(), *k)] = blocked;
1133  }
1134  } else {
1135  blockedConnectionsNew[blocker] = blocked;
1136  }
1137  }
1138  }
1139  myBlockedConnections = blockedConnectionsNew;
1140  }
1141  // remap in traffic lights
1142  tc.remapRemoved(removed, incoming, outgoing);
1143 }
1144 
1145 
1147 NBNode::getDirection(const NBEdge* const incoming, const NBEdge* const outgoing) const {
1148  // ok, no connection at all -> dead end
1149  if (outgoing == 0) {
1150  return LINKDIR_NODIR;
1151  }
1152  // turning direction
1153  if (incoming->isTurningDirectionAt(this, outgoing)) {
1154  return LINKDIR_TURN;
1155  }
1156  // get the angle between incoming/outgoing at the junction
1157  SUMOReal angle =
1158  NBHelpers::normRelAngle(incoming->getAngleAtNode(this), outgoing->getAngleAtNode(this));
1159  // ok, should be a straight connection
1160  if (abs((int) angle) + 1 < 45) {
1161  return LINKDIR_STRAIGHT;
1162  }
1163 
1164  // check for left and right, first
1165  if (angle > 0) {
1166  // check whether any other edge goes further to the right
1167  EdgeVector::const_iterator i =
1168  find(myAllEdges.begin(), myAllEdges.end(), outgoing);
1170  while ((*i) != incoming) {
1171  if ((*i)->getFromNode() == this) {
1172  return LINKDIR_PARTRIGHT;
1173  }
1174  NBContHelper::nextCW(myAllEdges, i);
1175  }
1176  return LINKDIR_RIGHT;
1177  }
1178  // check whether any other edge goes further to the left
1179  EdgeVector::const_iterator i =
1180  find(myAllEdges.begin(), myAllEdges.end(), outgoing);
1182  while ((*i) != incoming) {
1183  if ((*i)->getFromNode() == this && !incoming->isTurningDirectionAt(this, *i)) {
1184  return LINKDIR_PARTLEFT;
1185  }
1186  NBContHelper::nextCCW(myAllEdges, i);
1187  }
1188  return LINKDIR_LEFT;
1189 }
1190 
1191 
1192 std::string
1193 NBNode::stateCode(const NBEdge* incoming, NBEdge* outgoing, int fromlane, bool mayDefinitelyPass) const {
1194  if (outgoing == 0) { // always off
1196  }
1198  return toString(LINKSTATE_EQUAL); // all the same
1199  }
1200  if ((!incoming->isInnerEdge() && mustBrake(incoming, outgoing, fromlane)) && !mayDefinitelyPass) {
1201  return toString(LINKSTATE_MINOR); // minor road
1202  }
1203  // traffic lights are not regardedm here
1204  return toString(LINKSTATE_MAJOR);
1205 }
1206 
1207 
1208 bool
1210  // check whether this node is included in a traffic light
1211  if (myTrafficLights.size() != 0) {
1212  return false;
1213  }
1214  EdgeVector::const_iterator i;
1215  // one in, one out -> just a geometry ...
1216  if (myOutgoingEdges.size() == 1 && myIncomingEdges.size() == 1) {
1217  // ... if types match ...
1218  if (!myIncomingEdges[0]->expandableBy(myOutgoingEdges[0])) {
1219  return false;
1220  }
1221  //
1222  return myIncomingEdges[0]->getFromNode() != myOutgoingEdges[0]->getToNode();
1223  }
1224  // two in, two out -> may be something else
1225  if (myOutgoingEdges.size() == 2 && myIncomingEdges.size() == 2) {
1226  // check whether the origin nodes of the incoming edges differ
1227  std::set<NBNode*> origSet;
1228  for (i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
1229  origSet.insert((*i)->getFromNode());
1230  }
1231  if (origSet.size() < 2) {
1232  return false;
1233  }
1234  // check whether this node is an intermediate node of
1235  // a two-directional street
1236  for (i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
1237  // try to find the opposite direction
1238  NBNode* origin = (*i)->getFromNode();
1239  // find the back direction of the current edge
1240  EdgeVector::const_iterator j =
1241  find_if(myOutgoingEdges.begin(), myOutgoingEdges.end(),
1243  // check whether the back direction exists
1244  if (j != myOutgoingEdges.end()) {
1245  // check whether the edge from the backdirection (must be
1246  // the counter-clockwise one) may be joined with the current
1248  // check whether the types allow joining
1249  if (!(*i)->expandableBy(*j)) {
1250  return false;
1251  }
1252  } else {
1253  // ok, at least one outgoing edge is not an opposite
1254  // of an incoming one
1255  return false;
1256  }
1257  }
1258  return true;
1259  }
1260  // ok, a real node
1261  return false;
1262 }
1263 
1264 
1265 std::vector<std::pair<NBEdge*, NBEdge*> >
1267  assert(checkIsRemovable());
1268  std::vector<std::pair<NBEdge*, NBEdge*> > ret;
1269  // one in, one out-case
1270  if (myOutgoingEdges.size() == 1 && myIncomingEdges.size() == 1) {
1271  ret.push_back(
1272  std::pair<NBEdge*, NBEdge*>(
1274  return ret;
1275  }
1276  // two in, two out-case
1277  for (EdgeVector::const_iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
1278  NBNode* origin = (*i)->getFromNode();
1279  EdgeVector::const_iterator j =
1280  find_if(myOutgoingEdges.begin(), myOutgoingEdges.end(),
1283  ret.push_back(std::pair<NBEdge*, NBEdge*>(*i, *j));
1284  }
1285  return ret;
1286 }
1287 
1288 
1289 const PositionVector&
1291  return myPoly;
1292 }
1293 
1294 
1295 SUMOReal
1297  EdgeVector::const_iterator i = myAllEdges.begin();
1298  assert(i != myAllEdges.end());
1299  SUMOReal ret = (*i)->width();
1300  ++i;
1301  for (; i != myAllEdges.end(); i++) {
1302  ret = ret > (*i)->width() ? ret : (*i)->width();
1303  }
1304  return ret;
1305 }
1306 
1307 
1308 NBEdge*
1310  for (EdgeVector::const_iterator i = myOutgoingEdges.begin(); i != myOutgoingEdges.end(); i++) {
1311  if ((*i)->getToNode() == n) {
1312  return (*i);
1313  }
1314  }
1315  return 0;
1316 }
1317 
1318 
1319 bool
1321  if (isDistrict()) {
1322  return false;
1323  }
1324  EdgeVector edges;
1325  copy(getIncomingEdges().begin(), getIncomingEdges().end(),
1326  back_inserter(edges));
1327  copy(getOutgoingEdges().begin(), getOutgoingEdges().end(),
1328  back_inserter(edges));
1329  for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
1330  NBEdge* t = *j;
1331  NBNode* other = 0;
1332  if (t->getToNode() == this) {
1333  other = t->getFromNode();
1334  } else {
1335  other = t->getToNode();
1336  }
1337  EdgeVector edges2;
1338  copy(other->getIncomingEdges().begin(), other->getIncomingEdges().end(), back_inserter(edges2));
1339  copy(other->getOutgoingEdges().begin(), other->getOutgoingEdges().end(), back_inserter(edges2));
1340  for (EdgeVector::const_iterator k = edges2.begin(); k != edges2.end(); ++k) {
1341  if ((*k)->getFromNode()->isDistrict() || (*k)->getToNode()->isDistrict()) {
1342  return true;
1343  }
1344  }
1345  }
1346  return false;
1347 }
1348 
1349 
1350 bool
1352  return myType == NODETYPE_DISTRICT;
1353 }
1354 
1355 
1356 void
1358  unsigned int noInternalNoSplits = 0;
1359  for (EdgeVector::const_iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
1360  const std::vector<NBEdge::Connection> &elv = (*i)->getConnections();
1361  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
1362  if ((*k).toEdge == 0) {
1363  continue;
1364  }
1365  noInternalNoSplits++;
1366  }
1367  }
1368  unsigned int lno = 0;
1369  unsigned int splitNo = 0;
1370  for (EdgeVector::const_iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
1371  (*i)->buildInnerEdges(*this, noInternalNoSplits, lno, splitNo);
1372  }
1373 }
1374 
1375 
1376 /****************************************************************************/
1377