SUMO - Simulation of Urban MObility
NBEdgeCont.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 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 /****************************************************************************/
18 // Storage for edges, including some functionality operating on multiple edges
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <vector>
28 #include <string>
29 #include <cassert>
30 #include <algorithm>
31 #include <cmath>
32 #include <utils/geom/Boundary.h>
33 #include <utils/geom/GeomHelper.h>
36 #include <utils/common/ToString.h>
44 #include "NBNetBuilder.h"
45 #include "NBEdgeCont.h"
46 #include "NBNodeCont.h"
47 #include "NBHelpers.h"
48 #include "NBCont.h"
50 #include "NBDistrictCont.h"
51 #include "NBTypeCont.h"
52 
53 
54 // ===========================================================================
55 // method definitions
56 // ===========================================================================
58  myTypeCont(tc),
59  myEdgesSplit(0),
60  myVehicleClasses2Keep(0),
61  myVehicleClasses2Remove(0),
62  myNeedGeoTransformedPruningBoundary(false) {
63 }
64 
65 
67  clear();
68 }
69 
70 
71 void
73  // set edges dismiss/accept options
74  myEdgesMinSpeed = oc.getFloat("keep-edges.min-speed");
75  myRemoveEdgesAfterJoining = oc.exists("keep-edges.postload") && oc.getBool("keep-edges.postload");
76  // we possibly have to load the edges to keep/remove
77  if (oc.isSet("keep-edges.input-file")) {
78  NBHelpers::loadEdgesFromFile(oc.getString("keep-edges.input-file"), myEdges2Keep);
79  }
80  if (oc.isSet("remove-edges.input-file")) {
81  NBHelpers::loadEdgesFromFile(oc.getString("remove-edges.input-file"), myEdges2Remove);
82  }
83  if (oc.isSet("keep-edges.explicit")) {
84  const std::vector<std::string> edges = oc.getStringVector("keep-edges.explicit");
85  myEdges2Keep.insert(edges.begin(), edges.end());
86  }
87  if (oc.isSet("remove-edges.explicit")) {
88  const std::vector<std::string> edges = oc.getStringVector("remove-edges.explicit");
89  myEdges2Remove.insert(edges.begin(), edges.end());
90  }
91  if (oc.exists("keep-edges.by-vclass") && oc.isSet("keep-edges.by-vclass")) {
92  myVehicleClasses2Keep = parseVehicleClasses(oc.getStringVector("keep-edges.by-vclass"));
93  }
94  if (oc.exists("remove-edges.by-vclass") && oc.isSet("remove-edges.by-vclass")) {
95  myVehicleClasses2Remove = parseVehicleClasses(oc.getStringVector("remove-edges.by-vclass"));
96  }
97  if (oc.exists("keep-edges.by-type") && oc.isSet("keep-edges.by-type")) {
98  const std::vector<std::string> types = oc.getStringVector("keep-edges.by-type");
99  myTypes2Keep.insert(types.begin(), types.end());
100  }
101  if (oc.exists("remove-edges.by-type") && oc.isSet("remove-edges.by-type")) {
102  const std::vector<std::string> types = oc.getStringVector("remove-edges.by-type");
103  myTypes2Remove.insert(types.begin(), types.end());
104  }
105 
106  if (oc.isSet("keep-edges.in-boundary") || oc.isSet("keep-edges.in-geo-boundary")) {
107  std::vector<std::string> polyS = oc.getStringVector(oc.isSet("keep-edges.in-boundary") ?
108  "keep-edges.in-boundary" : "keep-edges.in-geo-boundary");
109  // !!! throw something if length<4 || length%2!=0?
110  std::vector<double> poly;
111  for (std::vector<std::string>::iterator i = polyS.begin(); i != polyS.end(); ++i) {
112  poly.push_back(StringUtils::toDouble((*i))); // !!! may throw something anyhow...
113  }
114  if (poly.size() < 4) {
115  throw ProcessError("Invalid boundary: need at least 2 coordinates");
116  } else if (poly.size() % 2 != 0) {
117  throw ProcessError("Invalid boundary: malformed coordinate");
118  } else if (poly.size() == 4) {
119  // prunning boundary (box)
120  myPruningBoundary.push_back(Position(poly[0], poly[1]));
121  myPruningBoundary.push_back(Position(poly[2], poly[1]));
122  myPruningBoundary.push_back(Position(poly[2], poly[3]));
123  myPruningBoundary.push_back(Position(poly[0], poly[3]));
124  } else {
125  for (std::vector<double>::iterator j = poly.begin(); j != poly.end();) {
126  double x = *j++;
127  double y = *j++;
128  myPruningBoundary.push_back(Position(x, y));
129  }
130  }
131  myNeedGeoTransformedPruningBoundary = oc.isSet("keep-edges.in-geo-boundary");
132  }
133 }
134 
135 
136 void
138  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
139  delete((*i).second);
140  }
141  myEdges.clear();
142  for (EdgeCont::iterator i = myExtractedEdges.begin(); i != myExtractedEdges.end(); i++) {
143  delete((*i).second);
144  }
145  myExtractedEdges.clear();
146 }
147 
148 
149 
150 // ----- edge access methods
151 bool
152 NBEdgeCont::insert(NBEdge* edge, bool ignorePrunning) {
153  if (myEdges.count(edge->getID()) != 0) {
154  return false;
155  }
156  if (!ignorePrunning && ignoreFilterMatch(edge)) {
157  edge->getFromNode()->removeEdge(edge);
158  edge->getToNode()->removeEdge(edge);
159  myIgnoredEdges.insert(edge->getID());
160  delete edge;
161  } else {
163  if (oc.exists("dismiss-vclasses") && oc.getBool("dismiss-vclasses")) {
165  }
166  myEdges[edge->getID()] = edge;
167  }
168  return true;
169 }
170 
171 
172 bool
174  // remove edges which allow a speed below a set one (set using "keep-edges.min-speed")
175  if (edge->getSpeed() < myEdgesMinSpeed) {
176  return true;
177  }
178  // check whether the edge is a named edge to keep
179  if (!myRemoveEdgesAfterJoining && myEdges2Keep.size() != 0) {
180  if (find(myEdges2Keep.begin(), myEdges2Keep.end(), edge->getID()) == myEdges2Keep.end()) {
181  // explicit whitelisting may be combined additively with other filters
183  && myTypes2Keep.size() == 0 && myTypes2Remove.size() == 0
184  && myPruningBoundary.size() == 0) {
185  return true;
186  }
187  } else {
188  // explicit whitelisting overrides other filters
189  return false;
190  }
191  }
192  // check whether the edge is a named edge to remove
193  if (myEdges2Remove.size() != 0) {
194  if (find(myEdges2Remove.begin(), myEdges2Remove.end(), edge->getID()) != myEdges2Remove.end()) {
195  return true;
196  }
197  }
198  // check whether the edge shall be removed because it does not allow any of the wished classes
199  if (myVehicleClasses2Keep != 0 && (myVehicleClasses2Keep & edge->getPermissions()) == 0) {
200  return true;
201  }
202  // check whether the edge shall be removed due to allowing unwished classes only
204  return true;
205  }
206  // check whether the edge shall be removed because it does not have one of the requested types
207  if (myTypes2Keep.size() != 0) {
208  if (myTypes2Keep.count(edge->getTypeID()) == 0) {
209  return true;
210  }
211  }
212  // check whether the edge shall be removed because it has one of the forbidden types
213  if (myTypes2Remove.size() != 0) {
214  if (myTypes2Remove.count(edge->getTypeID()) > 0) {
215  return true;
216  }
217  }
218  // check whether the edge is within the pruning boundary
219  if (myPruningBoundary.size() != 0) {
223  } else if (GeoConvHelper::getLoaded().usingGeoProjection()) {
224  // XXX what if input file with different projections are loaded?
225  for (int i = 0; i < (int) myPruningBoundary.size(); i++) {
227  }
228  } else {
229  WRITE_ERROR("Cannot prune edges using a geo-boundary because no projection has been loaded");
230  }
232  }
234  return true;
235  }
236  }
238  return true;
239  }
240  return false;
241 }
242 
243 
244 NBEdge*
245 NBEdgeCont::retrieve(const std::string& id, bool retrieveExtracted) const {
246  EdgeCont::const_iterator i = myEdges.find(id);
247  if (i == myEdges.end()) {
248  if (retrieveExtracted) {
249  i = myExtractedEdges.find(id);
250  if (i == myExtractedEdges.end()) {
251  return nullptr;
252  }
253  } else {
254  return nullptr;
255  }
256  }
257  return (*i).second;
258 }
259 
260 // FIXME: This can't work
261 /*
262 NBEdge*
263 NBEdgeCont::retrievePossiblySplit(const std::string& id, bool downstream) const {
264  NBEdge* edge = retrieve(id);
265  if (edge == 0) {
266  return 0;
267  }
268  const EdgeVector* candidates = downstream ? &edge->getToNode()->getOutgoingEdges() : &edge->getFromNode()->getIncomingEdges();
269  while (candidates->size() == 1) {
270  const std::string& nextID = candidates->front()->getID();
271  if (nextID.find(id) != 0 || nextID.size() <= id.size() + 1 || (nextID[id.size()] != '.' && nextID[id.size()] != '-')) {
272  break;
273  }
274  edge = candidates->front();
275  candidates = downstream ? &edge->getToNode()->getOutgoingEdges() : &edge->getFromNode()->getIncomingEdges();
276  }
277  return edge;
278 }*/
279 
280 NBEdge*
281 NBEdgeCont::retrievePossiblySplit(const std::string& id, bool downstream) const {
282  NBEdge* edge = retrieve(id);
283  if (edge != nullptr) {
284  return edge;
285  }
286  // NOTE: (TODO) for multiply split edges (e.g. 15[0][0]) one could try recursion
287  if ((retrieve(id + "[0]") != nullptr) && (retrieve(id + "[1]") != nullptr)) {
288  // Edge was split during the netbuilding process
289  if (downstream == true) {
290  return retrieve(id + "[1]");
291  } else {
292  return retrieve(id + "[0]");
293  }
294  }
295  return edge;
296 }
297 
298 
299 NBEdge*
300 NBEdgeCont::retrievePossiblySplit(const std::string& id, const std::string& hint, bool incoming) const {
301  // try to retrieve using the given name (iterative)
302  NBEdge* edge = retrieve(id);
303  if (edge != nullptr) {
304  return edge;
305  }
306  // now, we did not find it; we have to look over all possibilities
307  EdgeVector hints;
308  // check whether at least the hint was not splitted
309  NBEdge* hintedge = retrieve(hint);
310  if (hintedge == nullptr) {
311  hints = getGeneratedFrom(hint);
312  } else {
313  hints.push_back(hintedge);
314  }
315  EdgeVector candidates = getGeneratedFrom(id);
316  for (EdgeVector::iterator i = hints.begin(); i != hints.end(); i++) {
317  NBEdge* hintedge = (*i);
318  for (EdgeVector::iterator j = candidates.begin(); j != candidates.end(); j++) {
319  NBEdge* poss_searched = (*j);
320  NBNode* node = incoming
321  ? poss_searched->myTo : poss_searched->myFrom;
322  const EdgeVector& cont = incoming
323  ? node->getOutgoingEdges() : node->getIncomingEdges();
324  if (find(cont.begin(), cont.end(), hintedge) != cont.end()) {
325  return poss_searched;
326  }
327  }
328  }
329  return nullptr;
330 }
331 
332 
333 NBEdge*
334 NBEdgeCont::retrievePossiblySplit(const std::string& id, double pos) const {
335  // check whether the edge was not split, yet
336  NBEdge* edge = retrieve(id);
337  if (edge != nullptr) {
338  return edge;
339  }
340  int maxLength = 0;
341  std::string tid = id + "[";
342  for (EdgeCont::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
343  if ((*i).first.find(tid) == 0) {
344  maxLength = MAX2(maxLength, (int)(*i).first.length());
345  }
346  }
347  // find the part of the edge which matches the position
348  double seen = 0;
349  std::vector<std::string> names;
350  names.push_back(id + "[1]");
351  names.push_back(id + "[0]");
352  while (names.size() > 0) {
353  // retrieve the first subelement (to follow)
354  std::string cid = names.back();
355  names.pop_back();
356  edge = retrieve(cid);
357  // The edge was splitted; check its subparts within the
358  // next step
359  if (edge == nullptr) {
360  if ((int)cid.length() + 3 < maxLength) {
361  names.push_back(cid + "[1]");
362  names.push_back(cid + "[0]");
363  }
364  }
365  // an edge with the name was found,
366  // check whether the position lies within it
367  else {
368  seen += edge->getLength();
369  if (seen >= pos) {
370  return edge;
371  }
372  }
373  }
374  return nullptr;
375 }
376 
377 
378 void
380  extract(dc, edge);
381  delete edge;
382 }
383 
384 
385 void
386 NBEdgeCont::extract(NBDistrictCont& dc, NBEdge* edge, bool remember) {
387  if (remember) {
388  myExtractedEdges[edge->getID()] = edge;
389  }
390  myEdges.erase(edge->getID());
391  edge->myFrom->removeEdge(edge);
392  edge->myTo->removeEdge(edge);
393  dc.removeFromSinksAndSources(edge);
394 }
395 
396 
397 void
398 NBEdgeCont::rename(NBEdge* edge, const std::string& newID) {
399  if (myEdges.count(newID) != 0) {
400  throw ProcessError("Attempt to rename edge using existing id '" + newID + "'");
401  }
402  myEdges.erase(edge->getID());
403  edge->setID(newID);
404  myEdges[newID] = edge;
405 }
406 
407 
408 // ----- explicit edge manipulation methods
409 
410 void
411 NBEdgeCont::processSplits(NBEdge* e, std::vector<Split> splits,
413  if (splits.size() == 0) {
414  return;
415  }
416  const std::string origID = e->getID();
417  std::vector<Split>::iterator i;
418  sort(splits.begin(), splits.end(), split_sorter());
419  int noLanesMax = e->getNumLanes();
420  // compute the node positions and sort the lanes
421  for (i = splits.begin(); i != splits.end(); ++i) {
422  sort((*i).lanes.begin(), (*i).lanes.end());
423  noLanesMax = MAX2(noLanesMax, (int)(*i).lanes.size());
424  }
425  // split the edge
426  std::vector<int> currLanes;
427  for (int l = 0; l < e->getNumLanes(); ++l) {
428  currLanes.push_back(l);
429  }
430  if (e->getNumLanes() != (int)splits.back().lanes.size()) {
431  // invalidate traffic light definitions loaded from a SUMO network
432  e->getToNode()->invalidateTLS(tlc, true, true);
433  // if the number of lanes changes the connections should be
434  // recomputed
435  e->invalidateConnections(true);
436  }
437 
438  std::string firstID = "";
439  double seen = 0;
440  for (i = splits.begin(); i != splits.end(); ++i) {
441  const Split& exp = *i;
442  assert(exp.lanes.size() != 0);
443  if (exp.pos > 0 && e->getGeometry().length() + seen > exp.pos && exp.pos > seen) {
444  nc.insert(exp.node);
445  nc.markAsSplit(exp.node);
446  // split the edge
447  std::string idBefore = exp.idBefore == "" ? e->getID() : exp.idBefore;
448  std::string idAfter = exp.idAfter == "" ? exp.nameID : exp.idAfter;
449  if (firstID == "") {
450  firstID = idBefore;
451  }
452  const bool ok = splitAt(dc, e, exp.pos - seen, exp.node,
453  idBefore, idAfter, e->getNumLanes(), (int) exp.lanes.size(), exp.speed);
454  if (!ok) {
455  WRITE_WARNING("Error on parsing a split (edge '" + origID + "').");
456  }
457  seen = exp.pos;
458  std::vector<int> newLanes = exp.lanes;
459  NBEdge* pe = retrieve(idBefore);
460  NBEdge* ne = retrieve(idAfter);
461  // reconnect lanes
462  pe->invalidateConnections(true);
463  // new on right
464  int rightMostP = currLanes[0];
465  int rightMostN = newLanes[0];
466  for (int l = 0; l < (int) rightMostP - (int) rightMostN; ++l) {
467  pe->addLane2LaneConnection(0, ne, l, NBEdge::L2L_VALIDATED, true);
468  }
469  // new on left
470  int leftMostP = currLanes.back();
471  int leftMostN = newLanes.back();
472  for (int l = 0; l < (int) leftMostN - (int) leftMostP; ++l) {
473  pe->addLane2LaneConnection(pe->getNumLanes() - 1, ne, leftMostN - l - rightMostN, NBEdge::L2L_VALIDATED, true);
474  }
475  // all other connected
476  for (int l = 0; l < noLanesMax; ++l) {
477  if (find(currLanes.begin(), currLanes.end(), l) == currLanes.end()) {
478  continue;
479  }
480  if (find(newLanes.begin(), newLanes.end(), l) == newLanes.end()) {
481  continue;
482  }
483  pe->addLane2LaneConnection(l - rightMostP, ne, l - rightMostN, NBEdge::L2L_VALIDATED, true);
484  }
485  // if there are edges at this node which are not connected
486  // we can assume that this split was attached to an
487  // existing node. Reset all connections to let the default
488  // algorithm recompute them
489  if (exp.node->getIncomingEdges().size() > 1 || exp.node->getOutgoingEdges().size() > 1) {
490  for (NBEdge* in : exp.node->getIncomingEdges()) {
491  in->invalidateConnections(true);
492  }
493  }
494  // move to next
495  e = ne;
496  currLanes = newLanes;
497  } else if (exp.pos == 0) {
498  const int laneCountDiff = e->getNumLanes() - (int)exp.lanes.size();
499  if (laneCountDiff < 0) {
500  e->incLaneNo(-laneCountDiff);
501  } else {
502  e->decLaneNo(laneCountDiff);
503  }
504  currLanes = exp.lanes;
505  // invalidate traffic light definition loaded from a SUMO network
506  // XXX it would be preferable to reconstruct the phase definitions heuristically
507  e->getFromNode()->invalidateTLS(tlc, true, true);
508  } else {
509  WRITE_WARNING("Split at '" + toString(exp.pos) + "' lies beyond the edge's length (edge '" + origID + "').");
510  }
511  }
512  // patch lane offsets
513  e = retrieve(firstID);
514  if (splits.front().pos != 0) {
515  // add a dummy split at the beginning to ensure correct offset
516  Split start;
517  start.pos = 0;
518  for (int lane = 0; lane < (int)e->getNumLanes(); ++lane) {
519  start.lanes.push_back(lane);
520  }
521  start.offset = splits.front().offset;
522  start.offsetFactor = splits.front().offsetFactor;
523  splits.insert(splits.begin(), start);
524  }
525  i = splits.begin();
526  if (e != nullptr) {
527  for (; i != splits.end(); ++i) {
528  int maxLeft = (*i).lanes.back();
529  double offset = (*i).offset;
530  if (maxLeft < noLanesMax) {
532  offset += (*i).offsetFactor * SUMO_const_laneWidthAndOffset * (noLanesMax - 1 - maxLeft);
533  } else {
534  offset += (*i).offsetFactor * SUMO_const_halfLaneAndOffset * (noLanesMax - 1 - maxLeft);
535  }
536  }
537  int maxRight = (*i).lanes.front();
538  if (maxRight > 0 && e->getLaneSpreadFunction() == LANESPREAD_CENTER) {
539  offset -= (*i).offsetFactor * SUMO_const_halfLaneAndOffset * maxRight;
540  }
541  //std::cout << " processSplits " << origID << " splitOffset=" << (*i).offset << " offset=" << offset << "\n";
542  if (offset != 0) {
543  PositionVector g = e->getGeometry();
544  g.move2side(offset);
545  e->setGeometry(g);
546  }
547  if (e->getToNode()->getOutgoingEdges().size() != 0) {
548  e = e->getToNode()->getOutgoingEdges()[0];
549  }
550  }
551  }
552 }
553 
554 
555 bool
557  return splitAt(dc, edge, node, edge->getID() + "[0]", edge->getID() + "[1]",
558  (int) edge->myLanes.size(), (int) edge->myLanes.size());
559 }
560 
561 
562 bool
564  const std::string& firstEdgeName,
565  const std::string& secondEdgeName,
566  int noLanesFirstEdge, int noLanesSecondEdge,
567  const double speed,
568  const int changedLeft) {
569  double pos;
570  pos = edge->getGeometry().nearest_offset_to_point2D(node->getPosition());
571  if (pos <= 0) {
573  edge->myFrom->getPosition(), edge->myTo->getPosition(),
574  node->getPosition());
575  }
576  if (pos <= 0 || pos + POSITION_EPS > edge->getGeometry().length()) {
577  return false;
578  }
579  return splitAt(dc, edge, pos, node, firstEdgeName, secondEdgeName,
580  noLanesFirstEdge, noLanesSecondEdge, speed, changedLeft);
581 }
582 
583 
584 bool
586  NBEdge* edge, double pos, NBNode* node,
587  const std::string& firstEdgeName,
588  const std::string& secondEdgeName,
589  int noLanesFirstEdge, int noLanesSecondEdge,
590  const double speed,
591  const int changedLeft
592  ) {
593  // there must be at least some overlap between first and second edge
594  assert(changedLeft > -((int)noLanesFirstEdge));
595  assert(changedLeft < (int)noLanesSecondEdge);
596 
597  // build the new edges' geometries
598  std::pair<PositionVector, PositionVector> geoms =
599  edge->getGeometry().splitAt(pos);
600  if (geoms.first[-1] != node->getPosition()) {
601  geoms.first.pop_back();
602  geoms.first.push_back(node->getPosition());
603  }
604 
605  if (geoms.second[0] != node->getPosition()) {
606  geoms.second[0] = node->getPosition();
607  }
608  // build and insert the edges
609  NBEdge* one = new NBEdge(firstEdgeName, edge->myFrom, node, edge, geoms.first, noLanesFirstEdge);
610  NBEdge* two = new NBEdge(secondEdgeName, node, edge->myTo, edge, geoms.second, noLanesSecondEdge);
611  if (OptionsCont::getOptions().getBool("output.original-names")) {
612  const std::string origID = edge->getLaneStruct(0).getParameter(SUMO_PARAM_ORIGID, edge->getID());
613  if (firstEdgeName != origID) {
614  one->setOrigID(origID);
615  }
616  if (secondEdgeName != origID) {
617  two->setOrigID(origID);
618  }
619  }
620  two->copyConnectionsFrom(edge);
621  if (speed != -1.) {
622  two->setSpeed(-1, speed);
623  }
624  // replace information about this edge within the nodes
625  edge->myFrom->replaceOutgoing(edge, one, 0);
626  edge->myTo->replaceIncoming(edge, two, 0);
627  // patch tls
628  std::set<NBTrafficLightDefinition*> fromTLS = edge->myFrom->getControllingTLS();
629  for (std::set<NBTrafficLightDefinition*>::iterator i = fromTLS.begin(); i != fromTLS.end(); ++i) {
630  (*i)->replaceRemoved(edge, -1, one, -1);
631  }
632  std::set<NBTrafficLightDefinition*> toTLS = edge->myTo->getControllingTLS();
633  for (std::set<NBTrafficLightDefinition*>::iterator i = toTLS.begin(); i != toTLS.end(); ++i) {
634  (*i)->replaceRemoved(edge, -1, two, -1);
635  }
636  // the edge is now occuring twice in both nodes...
637  // clean up
638  edge->myFrom->removeDoubleEdges();
639  edge->myTo->removeDoubleEdges();
640  // add connections from the first to the second edge
641  // there will be as many connections as there are lanes on the second edge
642  // by default lanes will be added / discontinued on the right side
643  // (appropriate for highway on-/off-ramps)
644  const int offset = (int)one->getNumLanes() - (int)two->getNumLanes() + changedLeft;
645  for (int i2 = 0; i2 < (int)two->getNumLanes(); i2++) {
646  const int i1 = MIN2(MAX2((int)0, i2 + offset), (int)one->getNumLanes());
647  if (!one->addLane2LaneConnection(i1, two, i2, NBEdge::L2L_COMPUTED)) {
648  throw ProcessError("Could not set connection!");
649  }
650  }
652  if (find(myEdges2Keep.begin(), myEdges2Keep.end(), edge->getID()) != myEdges2Keep.end()) {
653  myEdges2Keep.insert(one->getID());
654  myEdges2Keep.insert(two->getID());
655  }
656  if (find(myEdges2Remove.begin(), myEdges2Remove.end(), edge->getID()) != myEdges2Remove.end()) {
657  myEdges2Remove.insert(one->getID());
658  myEdges2Remove.insert(two->getID());
659  }
660  }
661  // erase the splitted edge
662  patchRoundabouts(edge, one, two, myRoundabouts);
663  patchRoundabouts(edge, one, two, myGuessedRoundabouts);
664  erase(dc, edge);
665  insert(one, true);
666  insert(two, true);
667  myEdgesSplit++;
668  return true;
669 }
670 
671 
672 void
673 NBEdgeCont::patchRoundabouts(NBEdge* orig, NBEdge* part1, NBEdge* part2, std::set<EdgeSet>& roundabouts) {
674  std::set<EdgeSet> addLater;
675  for (std::set<EdgeSet>::iterator it = roundabouts.begin(); it != roundabouts.end(); ++it) {
676  EdgeSet roundaboutSet = *it;
677  if (roundaboutSet.count(orig) > 0) {
678  roundaboutSet.erase(orig);
679  roundaboutSet.insert(part1);
680  roundaboutSet.insert(part2);
681  }
682  addLater.insert(roundaboutSet);
683  }
684  roundabouts.clear();
685  roundabouts.insert(addLater.begin(), addLater.end());
686 }
687 
688 
689 // ----- container access methods
690 std::vector<std::string>
692  std::vector<std::string> ret;
693  for (EdgeCont::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
694  ret.push_back((*i).first);
695  }
696  return ret;
697 }
698 
699 
700 // ----- Adapting the input
701 void
703  EdgeVector toRemove;
704  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
705  NBEdge* edge = (*i).second;
706  if (!myEdges2Keep.count(edge->getID())) {
707  edge->getFromNode()->removeEdge(edge);
708  edge->getToNode()->removeEdge(edge);
709  toRemove.push_back(edge);
710  }
711  }
712  for (EdgeVector::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
713  erase(dc, *j);
714  }
715 }
716 
717 
718 void
720  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
721  if ((*i).second->getGeometry().size() < 3) {
722  continue;
723  }
724  (*i).second->splitGeometry(*this, nc);
725  }
726 }
727 
728 
729 void
730 NBEdgeCont::reduceGeometries(const double minDist) {
731  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
732  (*i).second->reduceGeometry(minDist);
733  }
734 }
735 
736 
737 void
738 NBEdgeCont::checkGeometries(const double maxAngle, const double minRadius, bool fix) {
739  if (maxAngle > 0 || minRadius > 0) {
740  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
741  (*i).second->checkGeometry(maxAngle, minRadius, fix);
742  }
743  }
744 }
745 
746 
747 // ----- processing methods
748 void
750  for (EdgeCont::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
751  (*i).second->clearControllingTLInformation();
752  }
753 }
754 
755 
756 void
758  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
759  (*i).second->sortOutgoingConnectionsByAngle();
760  }
761 }
762 
763 
764 void
765 NBEdgeCont::computeEdge2Edges(bool noLeftMovers) {
766  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
767  (*i).second->computeEdge2Edges(noLeftMovers);
768  }
769 }
770 
771 
772 void
774  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
775  (*i).second->computeLanes2Edges();
776  }
777 }
778 
779 
780 void
782  const bool fixOppositeLengths = OptionsCont::getOptions().getBool("opposites.guess.fix-lengths");
783  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
784  NBEdge* edge = i->second;
785  edge->recheckLanes();
786  // check opposites
787  if (edge->getNumLanes() > 0) {
788  const std::string& oppositeID = edge->getLanes().back().oppositeID;
789  if (oppositeID != "" && oppositeID != "-") {
790  NBEdge* oppEdge = retrieve(oppositeID.substr(0, oppositeID.rfind("_")));
791  if (oppEdge == nullptr || oppEdge->getLaneID(oppEdge->getNumLanes() - 1) != oppositeID) {
792  WRITE_WARNING("Removing unknown opposite lane '" + oppositeID + "' for edge '" + edge->getID() + "'.");
793  edge->getLaneStruct(edge->getNumLanes() - 1).oppositeID = "";
794  continue;
795  }
796  if (fabs(oppEdge->getLoadedLength() - edge->getLoadedLength()) > NUMERICAL_EPS) {
797  if (fixOppositeLengths) {
798  const double avgLength = 0.5 * (edge->getFinalLength() + oppEdge->getFinalLength());
799  WRITE_WARNING("Averaging edge lengths for lane '" + oppositeID + "' (length " + toString(oppEdge->getLoadedLength()) + ") and edge '" + edge->getID() + "' (length "
800  + toString(edge->getLoadedLength()) + ").");
801  edge->setLoadedLength(avgLength);
802  oppEdge->setLoadedLength(avgLength);
803  } else {
804  WRITE_ERROR("Opposite lane '" + oppositeID + "' (length " + toString(oppEdge->getLoadedLength()) + ") differs in length from edge '" + edge->getID() + "' (length "
805  + toString(edge->getLoadedLength()) + "). Set --opposites.guess.fix-lengths to fix this.");
806  edge->getLaneStruct(edge->getNumLanes() - 1).oppositeID = "";
807  continue;
808  }
809  }
810  if (oppEdge->getFromNode() != edge->getToNode() || oppEdge->getToNode() != edge->getFromNode()) {
811  WRITE_ERROR("Opposite lane '" + oppositeID + "' does not connect the same nodes as edge '" + edge->getID() + "'!");
812  edge->getLaneStruct(edge->getNumLanes() - 1).oppositeID = "";
813  }
814  }
815  }
816  }
817 }
818 
819 
820 void
821 NBEdgeCont::appendTurnarounds(bool noTLSControlled, bool onlyDeadends) {
822  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
823  (*i).second->appendTurnaround(noTLSControlled, onlyDeadends, true);
824  }
825 }
826 
827 
828 void
829 NBEdgeCont::appendTurnarounds(const std::set<std::string>& ids, bool noTLSControlled) {
830  for (std::set<std::string>::const_iterator it = ids.begin(); it != ids.end(); it++) {
831  myEdges[*it]->appendTurnaround(noTLSControlled, false, false);
832  }
833 }
834 
835 
836 void
838  std::set<std::string> stopEdgeIDs;
839  for (auto& stopItem : sc.getStops()) {
840  stopEdgeIDs.insert(stopItem.second->getEdgeId());
841  }
842  for (auto& item : myEdges) {
843  NBEdge* edge = item.second;
844  if (edge->isBidiRail()
845  && (stopEdgeIDs.count(item.first) > 0 ||
846  stopEdgeIDs.count(edge->getTurnDestination(true)->getID()) > 0)) {
847  NBEdge* to = edge->getTurnDestination(true);
848  assert(to != 0);
849  edge->setConnection(edge->getNumLanes() - 1,
850  to, to->getNumLanes() - 1, NBEdge::L2L_VALIDATED, false, false, true,
853  }
854  }
855 }
856 
857 void
858 NBEdgeCont::computeEdgeShapes(double smoothElevationThreshold) {
859  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
860  (*i).second->computeEdgeShape(smoothElevationThreshold);
861  }
862 }
863 
864 
865 void
867  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
868  (*i).second->computeLaneShapes();
869  }
870 }
871 
872 
873 void
876  EdgeVector edges) {
877  // !!! Attention!
878  // No merging of the geometry to come is being done
879  // The connections are moved from one edge to another within
880  // the replacement where the edge is a node's incoming edge.
881 
882  // count the number of lanes, the speed and the id
883  int nolanes = 0;
884  double speed = 0;
885  int priority = 0;
886  std::string id;
887  sort(edges.begin(), edges.end(), NBContHelper::same_connection_edge_sorter());
888  // retrieve the connected nodes
889  NBEdge* tpledge = *(edges.begin());
890  NBNode* from = tpledge->getFromNode();
891  NBNode* to = tpledge->getToNode();
892  EdgeVector::const_iterator i;
893  for (i = edges.begin(); i != edges.end(); i++) {
894  // some assertions
895  assert((*i)->getFromNode() == from);
896  assert((*i)->getToNode() == to);
897  // ad the number of lanes the current edge has
898  nolanes += (*i)->getNumLanes();
899  // build the id
900  if (i != edges.begin()) {
901  id += "+";
902  }
903  id += (*i)->getID();
904  // compute the speed
905  speed += (*i)->getSpeed();
906  // build the priority
907  priority = MAX2(priority, (*i)->getPriority());
908  }
909  speed /= edges.size();
910  // build the new edge
911  NBEdge* newEdge = new NBEdge(id, from, to, "", speed, nolanes, priority,
913  tpledge->getStreetName(), tpledge->myLaneSpreadFunction);
914  // copy lane attributes
915  int laneIndex = 0;
916  for (i = edges.begin(); i != edges.end(); ++i) {
917  const std::vector<NBEdge::Lane>& lanes = (*i)->getLanes();
918  for (int j = 0; j < (int)lanes.size(); ++j) {
919  newEdge->setPermissions(lanes[j].permissions, laneIndex);
920  newEdge->setLaneWidth(laneIndex, lanes[j].width);
921  newEdge->setEndOffset(laneIndex, lanes[j].endOffset);
922  laneIndex++;
923  }
924  }
925  insert(newEdge, true);
926  // replace old edge by current within the nodes
927  // and delete the old
928  from->replaceOutgoing(edges, newEdge);
929  to->replaceIncoming(edges, newEdge);
930  // patch connections
931  // add edge2edge-information
932  for (i = edges.begin(); i != edges.end(); i++) {
933  EdgeVector ev = (*i)->getConnectedEdges();
934  for (EdgeVector::iterator j = ev.begin(); j != ev.end(); j++) {
935  newEdge->addEdge2EdgeConnection(*j);
936  }
937  }
938  // copy outgoing connections to the new edge
939  int currLane = 0;
940  for (i = edges.begin(); i != edges.end(); i++) {
941  newEdge->moveOutgoingConnectionsFrom(*i, currLane);
942  currLane += (*i)->getNumLanes();
943  }
944  // patch tl-information
945  currLane = 0;
946  for (i = edges.begin(); i != edges.end(); i++) {
947  int noLanes = (*i)->getNumLanes();
948  for (int j = 0; j < noLanes; j++, currLane++) {
949  // replace in traffic lights
950  tlc.replaceRemoved(*i, j, newEdge, currLane);
951  }
952  }
953  // delete joined edges
954  for (i = edges.begin(); i != edges.end(); i++) {
955  extract(dc, *i, true);
956  }
957 }
958 
959 
960 void
962  //@todo magic values
963  const double distanceThreshold = 7;
964  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
965  NBEdge* edge = i->second;
966  const int numLanes = edge->getNumLanes();
967  if (numLanes > 0) {
968  NBEdge::Lane& lastLane = edge->getLaneStruct(numLanes - 1);
969  if (lastLane.oppositeID == "") {
970  NBEdge* opposite = nullptr;
971  //double minOppositeDist = std::numeric_limits<double>::max();
972  for (EdgeVector::const_iterator j = edge->getToNode()->getOutgoingEdges().begin(); j != edge->getToNode()->getOutgoingEdges().end(); ++j) {
973  if ((*j)->getToNode() == edge->getFromNode() && !(*j)->getLanes().empty()) {
974  const double distance = VectorHelper<double>::maxValue(lastLane.shape.distances((*j)->getLanes().back().shape));
975  if (distance < distanceThreshold) {
976  //minOppositeDist = distance;
977  opposite = *j;
978  }
979  }
980  }
981  if (opposite != nullptr) {
982  lastLane.oppositeID = opposite->getLaneID(opposite->getNumLanes() - 1);
983  }
984  }
985  }
986  }
987 }
988 
989 
990 void
992  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
993  NBEdge* opposite = getOppositeByID(i->first);
994  if (opposite != nullptr) {
995  i->second->setLaneSpreadFunction(LANESPREAD_RIGHT);
997  } else {
998  i->second->setLaneSpreadFunction(LANESPREAD_CENTER);
999  }
1000  }
1001 }
1002 
1003 
1004 NBEdge*
1005 NBEdgeCont::getOppositeByID(const std::string& edgeID) const {
1006  const std::string oppositeID = edgeID[0] == '-' ? edgeID.substr(1) : "-" + edgeID;
1007  EdgeCont::const_iterator it = myEdges.find(oppositeID);
1008  return it != myEdges.end() ? it->second : (NBEdge*)nullptr;
1009 }
1010 
1011 NBEdge*
1012 NBEdgeCont::getByID(const std::string& edgeID) const {
1013  EdgeCont::const_iterator it = myEdges.find(edgeID);
1014  return it != myEdges.end() ? it->second : (NBEdge*)nullptr;
1015 }
1016 
1017 // ----- other
1018 void
1019 NBEdgeCont::addPostProcessConnection(const std::string& from, int fromLane, const std::string& to, int toLane, bool mayDefinitelyPass,
1020  bool keepClear, double contPos, double visibility, double speed,
1021  const PositionVector& customShape, bool warnOnly) {
1022  myConnections.push_back(PostProcessConnection(from, fromLane, to, toLane, mayDefinitelyPass, keepClear, contPos, visibility, speed, customShape, warnOnly));
1023 }
1024 
1025 
1026 void
1028  const bool warnOnly = OptionsCont::getOptions().exists("ignore-errors.connections") && OptionsCont::getOptions().getBool("ignore-errors.connections");
1029  for (std::vector<PostProcessConnection>::const_iterator i = myConnections.begin(); i != myConnections.end(); ++i) {
1030  NBEdge* from = retrievePossiblySplit((*i).from, true);
1031  NBEdge* to = retrievePossiblySplit((*i).to, false);
1032  if (from == nullptr || to == nullptr ||
1033  !from->addLane2LaneConnection((*i).fromLane, to, (*i).toLane, NBEdge::L2L_USER, true, (*i).mayDefinitelyPass,
1034  (*i).keepClear, (*i).contPos, (*i).visibility, (*i).speed, (*i).customShape)) {
1035  const std::string msg = "Could not insert connection between '" + (*i).from + "' and '" + (*i).to + "' after build.";
1036  if (warnOnly || (*i).warnOnly) {
1037  WRITE_WARNING(msg);
1038  } else {
1039  WRITE_ERROR(msg);
1040  }
1041  }
1042  }
1043  // during loading we also kept some ambiguous connections in hope they might be valid after processing
1044  // we need to make sure that all invalid connections are removed now
1045  for (EdgeCont::iterator it = myEdges.begin(); it != myEdges.end(); ++it) {
1046  NBEdge* edge = it->second;
1047  NBNode* to = edge->getToNode();
1048  // make a copy because we may delete connections
1049  std::vector<NBEdge::Connection> connections = edge->getConnections();
1050  for (std::vector<NBEdge::Connection>::iterator it_con = connections.begin(); it_con != connections.end(); ++it_con) {
1051  NBEdge::Connection& c = *it_con;
1052  if (c.toEdge != nullptr && c.toEdge->getFromNode() != to) {
1053  WRITE_WARNING("Found and removed invalid connection from edge '" + edge->getID() +
1054  "' to edge '" + c.toEdge->getID() + "' via junction '" + to->getID() + "'.");
1055  edge->removeFromConnections(c.toEdge);
1056  }
1057  }
1058  }
1059 }
1060 
1061 
1062 EdgeVector
1063 NBEdgeCont::getGeneratedFrom(const std::string& id) const {
1064  int len = (int)id.length();
1065  EdgeVector ret;
1066  for (EdgeCont::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
1067  std::string curr = (*i).first;
1068  // the next check makes it possibly faster - we don not have
1069  // to compare the names
1070  if ((int)curr.length() <= len) {
1071  continue;
1072  }
1073  // the name must be the same as the given id but something
1074  // beginning with a '[' must be appended to it
1075  if (curr.substr(0, len) == id && curr[len] == '[') {
1076  ret.push_back((*i).second);
1077  continue;
1078  }
1079  // ok, maybe the edge is a compound made during joining of edges
1080  std::string::size_type pos = curr.find(id);
1081  // surely not
1082  if (pos == std::string::npos) {
1083  continue;
1084  }
1085  // check leading char
1086  if (pos > 0) {
1087  if (curr[pos - 1] != ']' && curr[pos - 1] != '+') {
1088  // actually, this is another id
1089  continue;
1090  }
1091  }
1092  if (pos + id.length() < curr.length()) {
1093  if (curr[pos + id.length()] != '[' && curr[pos + id.length()] != '+') {
1094  // actually, this is another id
1095  continue;
1096  }
1097  }
1098  ret.push_back((*i).second);
1099  }
1100  return ret;
1101 }
1102 
1103 
1104 int
1106  myGuessedRoundabouts.clear();
1107  std::set<NBEdge*> loadedRoundaboutEdges;
1108  for (std::set<EdgeSet>::const_iterator it = myRoundabouts.begin(); it != myRoundabouts.end(); ++it) {
1109  loadedRoundaboutEdges.insert(it->begin(), it->end());
1110  }
1111  // step 1: keep only those edges which have no turnarounds and which are not
1112  // part of a loaded roundabout
1113  std::set<NBEdge*> candidates;
1114  for (EdgeCont::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
1115  NBEdge* e = (*i).second;
1116  NBNode* const to = e->getToNode();
1117  if (e->getTurnDestination() == nullptr && to->getConnectionTo(e->getFromNode()) == nullptr && loadedRoundaboutEdges.count(e) == 0) {
1118  candidates.insert(e);
1119  }
1120  }
1121 
1122  // step 2:
1123  std::set<NBEdge*> visited;
1124  for (std::set<NBEdge*>::const_iterator i = candidates.begin(); i != candidates.end(); ++i) {
1125  EdgeVector loopEdges;
1126  // start with a random edge (this doesn't have to be a roundabout edge)
1127  // loop over connected edges (using always the leftmost one)
1128  // and keep the list in loopEdges
1129  // continue until we loop back onto a loopEdges and extract the loop
1130  NBEdge* e = (*i);
1131  if (visited.count(e) > 0) {
1132  // already seen
1133  continue;
1134  }
1135  loopEdges.push_back(e);
1136  bool doLoop = true;
1137  do {
1138  visited.insert(e);
1139  const EdgeVector& edges = e->getToNode()->getEdges();
1140  if (edges.size() < 2) {
1141  doLoop = false;
1142  break;
1143  }
1144  if (e->getTurnDestination() != nullptr || e->getToNode()->getConnectionTo(e->getFromNode()) != nullptr) {
1145  // do not follow turn-arounds while in a (tentative) loop
1146  doLoop = false;
1147  break;
1148  }
1149  EdgeVector::const_iterator me = find(edges.begin(), edges.end(), e);
1150  NBContHelper::nextCW(edges, me);
1151  NBEdge* left = *me;
1152  double angle = fabs(NBHelpers::relAngle(e->getAngleAtNode(e->getToNode()), left->getAngleAtNode(e->getToNode())));
1153  if (angle >= 90) {
1154  // roundabouts do not have sharp turns (or they wouldn't be called 'round')
1155  doLoop = false;
1156  break;
1157  }
1158  EdgeVector::const_iterator loopClosed = find(loopEdges.begin(), loopEdges.end(), left);
1159  const int loopSize = (int)(loopEdges.end() - loopClosed);
1160  if (loopSize > 0) {
1161  // loop found
1162  if (loopSize < 3) {
1163  doLoop = false; // need at least 3 edges for a roundabout
1164  } else if (loopSize < (int)loopEdges.size()) {
1165  // remove initial edges not belonging to the loop
1166  EdgeVector(loopEdges.begin() + (loopEdges.size() - loopSize), loopEdges.end()).swap(loopEdges);
1167  }
1168  // count attachments to the outside. need at least 3 or a roundabout doesn't make much sense
1169  int attachments = 0;
1170  for (EdgeVector::const_iterator j = loopEdges.begin(); j != loopEdges.end(); ++j) {
1171  if ((*j)->getToNode()->getEdges().size() > 2) {
1172  attachments++;
1173  }
1174  }
1175  if (attachments < 3) {
1176  doLoop = false;
1177  }
1178  break;
1179  }
1180  if (visited.count(left) > 0) {
1181  doLoop = false;
1182  } else {
1183  // keep going
1184  loopEdges.push_back(left);
1185  e = left;
1186  }
1187  } while (doLoop);
1188  if (doLoop) {
1189  // check form factor to avoid elongated shapes (circle: 1, square: ~0.79)
1190  if (formFactor(loopEdges) > 0.6) {
1191  // collected edges are marked in markRoundabouts
1192  myGuessedRoundabouts.insert(EdgeSet(loopEdges.begin(), loopEdges.end()));
1193  }
1194  }
1195  }
1196  return (int)myGuessedRoundabouts.size();
1197 }
1198 
1199 
1200 double
1202  PositionVector points;
1203  for (EdgeVector::const_iterator it = loopEdges.begin(); it != loopEdges.end(); ++it) {
1204  points.append((*it)->getGeometry());
1205  }
1206  double circumference = points.length2D();
1207  return 4 * M_PI * points.area() / (circumference * circumference);
1208 }
1209 
1210 
1211 const std::set<EdgeSet>
1213  std::set<EdgeSet> result = myRoundabouts;
1214  result.insert(myGuessedRoundabouts.begin(), myGuessedRoundabouts.end());
1215  return result;
1216 }
1217 
1218 
1219 void
1221  if (roundabout.size() > 0) {
1222  if (find(myRoundabouts.begin(), myRoundabouts.end(), roundabout) != myRoundabouts.end()) {
1223  WRITE_WARNING("Ignoring duplicate roundabout: " + toString(roundabout));
1224  } else {
1225  myRoundabouts.insert(roundabout);
1226  }
1227  }
1228 }
1229 
1230 
1231 void
1233  const std::set<EdgeSet> roundabouts = getRoundabouts();
1234  for (std::set<EdgeSet>::const_iterator it = roundabouts.begin(); it != roundabouts.end(); ++it) {
1235  const EdgeSet roundaboutSet = *it;
1236  for (std::set<NBEdge*>::const_iterator j = roundaboutSet.begin(); j != roundaboutSet.end(); ++j) {
1237  // disable turnarounds on incoming edges
1238  NBNode* node = (*j)->getToNode();
1239  const EdgeVector& incoming = node->getIncomingEdges();
1240  for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
1241  NBEdge* inEdge = *k;
1242  if (roundaboutSet.count(inEdge) > 0) {
1243  continue;
1244  }
1245  if ((inEdge)->getStep() >= NBEdge::LANES2LANES_USER) {
1246  continue;
1247  }
1248  inEdge->removeFromConnections(inEdge->getTurnDestination(), -1);
1249  }
1250  // let the connections to succeeding roundabout edge have a higher priority
1251  (*j)->setJunctionPriority(node, NBEdge::ROUNDABOUT);
1252  (*j)->setJunctionPriority((*j)->getFromNode(), NBEdge::ROUNDABOUT);
1253  node->setRoundabout();
1254  }
1255  }
1256 }
1257 
1258 void
1260  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
1261  NBEdge* e = i->second;
1262  const double offset = MAX2(0., e->getLength() - 3);
1263  if (e->getToNode()->isSimpleContinuation(false)) {
1264  // not a "real" junction?
1265  continue;
1266  }
1267  const SumoXMLNodeType nodeType = e->getToNode()->getType();
1268  switch (nodeType) {
1269  case NODETYPE_PRIORITY:
1270  // yield or major?
1271  if (e->getJunctionPriority(e->getToNode()) > 0) {
1273  } else {
1274  e->addSign(NBSign(NBSign::SIGN_TYPE_YIELD, offset));
1275  }
1276  break;
1278  // yield or major?
1279  if (e->getJunctionPriority(e->getToNode()) > 0) {
1281  } else {
1282  e->addSign(NBSign(NBSign::SIGN_TYPE_STOP, offset));
1283  }
1284  break;
1285  case NODETYPE_ALLWAY_STOP:
1287  break;
1290  break;
1291  default:
1292  break;
1293  }
1294  }
1295 }
1296 
1297 
1298 int
1299 NBEdgeCont::guessSidewalks(double width, double minSpeed, double maxSpeed, bool fromPermissions) {
1300  int sidewalksCreated = 0;
1301  const std::vector<std::string> edges = OptionsCont::getOptions().getStringVector("sidewalks.guess.exclude");
1302  std::set<std::string> exclude(edges.begin(), edges.end());
1303  for (EdgeCont::iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1304  NBEdge* edge = it->second;
1305  if (// not excluded
1306  exclude.count(edge->getID()) == 0
1307  // does not yet have a sidewalk
1308  && edge->getPermissions(0) != SVC_PEDESTRIAN
1309  && (
1310  // guess.from-permissions
1311  (fromPermissions && (edge->getPermissions() & SVC_PEDESTRIAN) != 0)
1312  // guess from speed
1313  || (!fromPermissions && edge->getSpeed() > minSpeed && edge->getSpeed() <= maxSpeed)
1314  )) {
1315  edge->addSidewalk(width);
1316  sidewalksCreated += 1;
1317  }
1318  }
1319  return sidewalksCreated;
1320 }
1321 
1322 
1323 int
1324 NBEdgeCont::remapIDs(bool numericaIDs, bool reservedIDs, const std::string& prefix, NBPTStopCont& sc) {
1325  std::vector<std::string> avoid = getAllNames();
1326  std::set<std::string> reserve;
1327  if (reservedIDs) {
1328  NBHelpers::loadPrefixedIDsFomFile(OptionsCont::getOptions().getString("reserved-ids"), "edge:", reserve);
1329  avoid.insert(avoid.end(), reserve.begin(), reserve.end());
1330  }
1331  IDSupplier idSupplier("", avoid);
1332  std::set<NBEdge*, ComparatorIdLess> toChange;
1333  for (EdgeCont::iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1334  if (numericaIDs) {
1335  try {
1336  StringUtils::toLong(it->first);
1337  } catch (NumberFormatException&) {
1338  toChange.insert(it->second);
1339  }
1340  }
1341  if (reservedIDs && reserve.count(it->first) > 0) {
1342  toChange.insert(it->second);
1343  }
1344  }
1345 
1346  std::map<std::string, std::vector<NBPTStop*> > stopsOnEdge;
1347  for (const auto& item : sc.getStops()) {
1348  stopsOnEdge[item.second->getEdgeId()].push_back(item.second);
1349  }
1350 
1351  const bool origNames = OptionsCont::getOptions().getBool("output.original-names");
1352  for (std::set<NBEdge*, ComparatorIdLess>::iterator it = toChange.begin(); it != toChange.end(); ++it) {
1353  NBEdge* edge = *it;
1354  const std::string origID = edge->getID();
1355  myEdges.erase(origID);
1356  if (origNames) {
1357  edge->setOrigID(origID);
1358  }
1359  edge->setID(idSupplier.getNext());
1360  myEdges[edge->getID()] = edge;
1361  for (NBPTStop* stop : stopsOnEdge[origID]) {
1362  stop->setEdgeId(prefix + edge->getID(), *this);
1363  }
1364  }
1365  if (prefix.empty()) {
1366  return (int)toChange.size();
1367  } else {
1368  int renamed = 0;
1369  // make a copy because we will modify the map
1370  auto oldEdges = myEdges;
1371  for (auto item : oldEdges) {
1372  if (!StringUtils::startsWith(item.first, prefix)) {
1373  rename(item.second, prefix + item.first);
1374  renamed++;
1375  }
1376  }
1377  return renamed;
1378  }
1379 }
1380 
1381 
1382 void
1383 NBEdgeCont::checkOverlap(double threshold, double zThreshold) const {
1384  for (EdgeCont::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1385  const NBEdge* e1 = it->second;
1386  Boundary b1 = e1->getGeometry().getBoxBoundary();
1387  b1.grow(e1->getTotalWidth());
1388  PositionVector outline1 = e1->getCCWBoundaryLine(*e1->getFromNode());
1389  outline1.append(e1->getCCWBoundaryLine(*e1->getToNode()));
1390  // check is symmetric. only check once per pair
1391  for (EdgeCont::const_iterator it2 = it; it2 != myEdges.end(); it2++) {
1392  const NBEdge* e2 = it2->second;
1393  if (e1 == e2) {
1394  continue;
1395  }
1396  Boundary b2 = e2->getGeometry().getBoxBoundary();
1397  b2.grow(e2->getTotalWidth());
1398  if (b1.overlapsWith(b2)) {
1399  PositionVector outline2 = e2->getCCWBoundaryLine(*e2->getFromNode());
1400  outline2.append(e2->getCCWBoundaryLine(*e2->getToNode()));
1401  const double overlap = outline1.getOverlapWith(outline2, zThreshold);
1402  if (overlap > threshold) {
1403  WRITE_WARNING("Edge '" + e1->getID() + "' overlaps with edge '" + e2->getID() + "' by " + toString(overlap) + ".");
1404  }
1405  }
1406  }
1407  }
1408 }
1409 
1410 
1411 void
1412 NBEdgeCont::checkGrade(double threshold) const {
1413  for (EdgeCont::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1414  const NBEdge* edge = it->second;
1415  for (int i = 0; i < (int)edge->getNumLanes(); i++) {
1416  double maxJump = 0;
1417  const double grade = edge->getLaneShape(i).getMaxGrade(maxJump);
1418  if (maxJump > 0.01) {
1419  WRITE_WARNING("Edge '" + edge->getID() + "' has a vertical jump of " + toString(maxJump) + "m.");
1420  } else if (grade > threshold) {
1421  WRITE_WARNING("Edge '" + edge->getID() + "' has a grade of " + toString(grade * 100) + "%.");
1422  break;
1423  }
1424  }
1425  const std::vector<NBEdge::Connection>& connections = edge->getConnections();
1426  for (std::vector<NBEdge::Connection>::const_iterator it_con = connections.begin(); it_con != connections.end(); ++it_con) {
1427  const NBEdge::Connection& c = *it_con;
1428  double maxJump = 0;
1429  const double grade = MAX2(c.shape.getMaxGrade(maxJump), c.viaShape.getMaxGrade(maxJump));
1430  if (maxJump > 0.01) {
1431  WRITE_WARNING("Connection '" + c.getDescription(edge) + "' has a vertical jump of " + toString(maxJump) + "m.");
1432  } else if (grade > threshold) {
1433  WRITE_WARNING("Connection '" + c.getDescription(edge) + "' has a grade of " + toString(grade * 100) + "%.");
1434  break;
1435  }
1436  }
1437  }
1438 }
1439 
1440 
1441 EdgeVector
1443  EdgeVector result;
1444  for (auto item : myEdges) {
1445  item.second->setNumericalID((int)result.size());
1446  result.push_back(item.second);
1447  }
1448  return result;
1449 }
1450 
1451 /****************************************************************************/
static double relAngle(double angle1, double angle2)
computes the relative angle between the two angles
Definition: NBHelpers.cpp:47
~NBEdgeCont()
Destructor.
Definition: NBEdgeCont.cpp:66
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge&#39;s lanes&#39; lateral offset is computed.
Definition: NBEdge.h:704
void invalidateConnections(bool reallowSetting=false)
invalidate current connections of edge
Definition: NBEdge.cpp:1348
std::vector< Lane > myLanes
Lane information.
Definition: NBEdge.h:1513
double getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:488
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
double length2D() const
Returns the length.
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:160
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
Definition: NBEdgeCont.cpp:757
void markRoundabouts()
mark edge priorities and prohibit turn-arounds for all roundabout edges
void setRoundabout()
update the type of this node as a roundabout
Definition: NBNode.cpp:2913
A class representing a single street sign.
Definition: NBSign.h:44
EdgeVector getGeneratedFrom(const std::string &id) const
Returns the edges which have been built by splitting the edge of the given id.
PositionVector shape
The lane&#39;s shape.
Definition: NBEdge.h:121
is a pedestrian
void append(const PositionVector &v, double sameThreshold=2.0)
void appendTurnarounds(bool noTLSControlled, bool onlyDeadends)
Appends turnarounds to all edges stored in the container.
Definition: NBEdgeCont.cpp:821
void addSign(NBSign sign)
add Sign
Definition: NBEdge.h:1238
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:185
void reduceGeometries(const double minDist)
Definition: NBEdgeCont.cpp:730
static void loadPrefixedIDsFomFile(const std::string &file, const std::string prefix, std::set< std::string > &into)
Add prefixed ids defined in file.
Definition: NBHelpers.cpp:106
NBNode * myTo
Definition: NBEdge.h:1454
static const double UNSPECIFIED_VISIBILITY_DISTANCE
unspecified foe visibility for connections
Definition: NBEdge.h:270
A structure which describes changes of lane number or speed along the road.
Definition: NBEdgeCont.h:206
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3222
bool setConnection(int lane, NBEdge *destEdge, int destLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE, double speed=UNSPECIFIED_SPEED, const PositionVector &customShape=PositionVector::EMPTY, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED)
Adds a connection to a certain lane of a certain edge.
Definition: NBEdge.cpp:1042
double getMaxGrade(double &maxJump) const
void markAsSplit(const NBNode *node)
mark a node as being created form a split
Definition: NBNodeCont.h:310
A container for traffic light definitions and built programs.
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
bool myRemoveEdgesAfterJoining
Whether edges shall be joined first, then removed.
Definition: NBEdgeCont.h:676
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3272
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
Definition: NBEdge.cpp:1781
NBEdge * getOppositeByID(const std::string &edgeID) const
Returns the edge with negated id if it exists.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:84
void removeEdge(NBEdge *edge, bool removeFromConnections=true)
Removes edge from this node and optionally removes connections as well.
Definition: NBNode.cpp:1460
const std::string & getTypeID() const
get ID of type
Definition: NBEdge.h:1004
std::string nameID
the default node id
Definition: NBEdgeCont.h:221
const double SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:56
std::pair< PositionVector, PositionVector > splitAt(double where, bool use2D=false) const
Returns the two lists made when this list vector is splitted at the given point.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
The representation of a single edge during network building.
Definition: NBEdge.h:65
const double SUMO_const_laneWidthAndOffset
Definition: StdDefs.h:55
void guessOpposites()
Sets opposite lane information for geometrically close edges.
Definition: NBEdgeCont.cpp:961
bool isBidiRail(bool ignoreSpread=false) const
whether this edge is part of a bidirectional railway
Definition: NBEdge.cpp:668
A container for districts.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:261
static GeoConvHelper & getLoaded()
the coordinate transformation that was loaded fron an input file
Definition: GeoConvHelper.h:89
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false, const bool adaptToLaneRemoval=false)
Removes the specified connection(s)
Definition: NBEdge.cpp:1281
void removeDoubleEdges()
remove duble edges
Definition: NBNode.cpp:1349
T MAX2(T a, T b)
Definition: StdDefs.h:76
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:3013
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
Definition: NBEdge.cpp:3303
void setLoadedLength(double val)
set loaded lenght
Definition: NBEdge.cpp:3346
void generateStreetSigns()
assigns street signs to edges based on toNode types
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:589
void rename(NBEdge *edge, const std::string &newID)
Renames the edge. Throws exception if newID already exists.
Definition: NBEdgeCont.cpp:398
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:556
void recheckPostProcessConnections()
Try to set any stored connections.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
std::string idAfter
The id for the edge after the split.
Definition: NBEdgeCont.h:219
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:192
static void nextCW(const EdgeVector &edges, EdgeVector::const_iterator &from)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
Definition: Named.h:78
The representation of a single pt stop.
Definition: NBPTStop.h:45
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1206
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:182
std::vector< double > distances(const PositionVector &s, bool perpendicular=false) const
distances of all my points to s and all of s points to myself
static void loadEdgesFromFile(const std::string &file, std::set< std::string > &into)
Add edge ids defined in file (either ID or edge:ID per line) into the given set.
Definition: NBHelpers.cpp:88
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
Definition: NBEdgeCont.cpp:773
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connctions
Definition: NBEdge.cpp:3458
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge&#39;s geometry
Definition: NBEdge.cpp:559
std::string getDescription(const NBEdge *parent) const
get string describing this connection
Definition: NBEdge.cpp:86
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:258
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
std::vector< PostProcessConnection > myConnections
The list of connections to recheck.
Definition: NBEdgeCont.h:651
void replaceOutgoing(NBEdge *which, NBEdge *by, int laneOff)
Replaces occurences of the first edge within the list of outgoing by the second Connections are remap...
Definition: NBNode.cpp:1245
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:241
The connection was computed and validated.
Definition: NBEdge.h:109
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
void checkGeometries(const double maxAngle, const double minRadius, bool fix)
Definition: NBEdgeCont.cpp:738
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges (The edges which start at this node)
Definition: NBNode.h:255
void checkOverlap(double threshold, double zThreshold) const
check whether edges overlap
double area() const
Returns the area (0 for non-closed)
void checkGrade(double threshold) const
check whether edges are to steep
PositionVector myPruningBoundary
Boundary within which an edge must be located in order to be kept.
Definition: NBEdgeCont.h:697
PositionVector shape
shape of Connection
Definition: NBEdge.h:218
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE, double speed=UNSPECIFIED_SPEED, const PositionVector &customShape=PositionVector::EMPTY, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED)
Adds a connection between the specified this edge&#39;s lane and an approached one.
Definition: NBEdge.cpp:998
double pos
The position of this change.
Definition: NBEdgeCont.h:211
NBEdgeCont(NBTypeCont &tc)
Constructor.
Definition: NBEdgeCont.cpp:57
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
Definition: NBNode.cpp:1997
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:116
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void invalidateTLS(NBTrafficLightLogicCont &tlCont, bool removedConnections, bool addedConnections)
causes the traffic light to be computed anew
Definition: NBNode.cpp:363
bool addEdge2EdgeConnection(NBEdge *dest)
Adds a connection to another edge.
Definition: NBEdge.cpp:974
void incLaneNo(int by)
increment lane
Definition: NBEdge.cpp:3085
NBNode * node
The new node that is created for this split.
Definition: NBEdgeCont.h:215
SVCPermissions myVehicleClasses2Keep
Set of vehicle types which must be allowed on edges in order to keep them.
Definition: NBEdgeCont.h:685
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:68
static double nearest_offset_on_line_to_point2D(const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
Definition: GeomHelper.cpp:89
double myEdgesMinSpeed
The minimum speed an edge may have in order to be kept (default: -1)
Definition: NBEdgeCont.h:673
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
Definition: NBEdge.h:96
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:46
void patchRoundabouts(NBEdge *orig, NBEdge *part1, NBEdge *part2, std::set< EdgeSet > &roundabouts)
fix roundabout information after splitting an edge
Definition: NBEdgeCont.cpp:673
std::string getNext()
Returns the next id.
Definition: IDSupplier.cpp:52
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:152
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
NBEdge * retrievePossiblySplit(const std::string &id, bool downstream) const
Tries to retrieve an edge, even if it is splitted.
Definition: NBEdgeCont.cpp:281
int offsetFactor
direction in which to apply the offset (used by netgenerate for lefthand networks) ...
Definition: NBEdgeCont.h:225
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
Definition: NBEdgeCont.cpp:702
void decLaneNo(int by)
decrement lane
Definition: NBEdge.cpp:3116
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
std::string getLaneID(int lane) const
get Lane ID (Secure)
Definition: NBEdge.cpp:3022
void extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
Definition: NBEdgeCont.cpp:386
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:420
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A list of positions.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
Definition: NBEdgeCont.cpp:72
void setOrigID(const std::string origID)
set origID for all lanes
Definition: NBEdge.cpp:3588
void moveOutgoingConnectionsFrom(NBEdge *e, int laneOff)
move outgoing connection
Definition: NBEdge.cpp:2711
static const double UNSPECIFIED_CONTPOS
unspecified internal junction position
Definition: NBEdge.h:267
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
std::set< std::string > myEdges2Keep
Set of ids of edges which shall explicitly be kept.
Definition: NBEdgeCont.h:679
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
Definition: NBEdgeCont.cpp:765
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
Definition: NBEdgeCont.cpp:866
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node) ...
Definition: NBNode.h:260
bool exists(const std::string &name) const
Returns the information whether the named option is known.
void clearControllingTLInformation() const
Clears information about controlling traffic lights for all connenections of all edges.
Definition: NBEdgeCont.cpp:749
static double formFactor(const EdgeVector &loopEdges)
compute the form factor for a loop of edges
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) ...
T MIN2(T a, T b)
Definition: StdDefs.h:70
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
Definition: NBEdgeCont.cpp:411
void splitGeometry(NBNodeCont &nc)
Splits edges into multiple if they have a complex geometry.
Definition: NBEdgeCont.cpp:719
EdgeCont myEdges
The instance of the dictionary (id->edge)
Definition: NBEdgeCont.h:658
#define POSITION_EPS
Definition: config.h:172
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge&#39;s geometry at the given node.
Definition: NBEdge.cpp:1801
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
std::vector< int > lanes
The lanes after this change.
Definition: NBEdgeCont.h:209
void clear()
Deletes all edges.
Definition: NBEdgeCont.cpp:137
EdgeCont myExtractedEdges
The extracted nodes which are kept for reference.
Definition: NBEdgeCont.h:661
The connection was given by the user.
Definition: NBEdge.h:107
std::set< EdgeSet > myGuessedRoundabouts
Edges marked as belonging to a roundabout after guessing.
Definition: NBEdgeCont.h:706
std::set< EdgeSet > myRoundabouts
Edges marked as belonging to a roundabout by the user (each EdgeVector is a roundabout) ...
Definition: NBEdgeCont.h:704
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:3331
double getFinalLength() const
get length that will be assigned to the lanes in the final network
Definition: NBEdge.cpp:3575
void move2side(double amount)
move position vector to side using certain ammount
bool recheckLanes()
recheck whether all lanes within the edge are all right and optimises the connections once again ...
Definition: NBEdge.cpp:2135
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
Definition: NBEdgeCont.cpp:874
double getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:514
SVCPermissions myVehicleClasses2Remove
Set of vehicle types which need not be supported (edges which allow ONLY these are removed) ...
Definition: NBEdgeCont.h:688
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:622
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:247
const std::map< std::string, NBPTStop * > & getStops() const
Definition: NBPTStopCont.h:62
std::set< std::string > myTypes2Keep
Set of edges types which shall be kept.
Definition: NBEdgeCont.h:691
int guessSidewalks(double width, double minSpeed, double maxSpeed, bool fromPermissions)
add sidwalks to edges within the given limits or permissions and return the number of edges affected ...
EdgeVector getAllEdges() const
return all edges
void setID(const std::string &newID)
resets the id
Definition: Named.h:86
double length() const
Returns the length.
PositionVector viaShape
shape of via
Definition: NBEdge.h:230
std::string oppositeID
An opposite lane ID, if given.
Definition: NBEdge.h:143
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
Definition: NBEdge.cpp:855
const EdgeVector & getIncomingEdges() const
Returns this node&#39;s incoming edges (The edges which yield in this node)
Definition: NBNode.h:250
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:867
void replaceIncoming(NBEdge *which, NBEdge *by, int laneOff)
Replaces occurences of the first edge within the list of incoming by the second Connections are remap...
Definition: NBNode.cpp:1281
#define M_PI
Definition: odrSpiral.cpp:40
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node) ...
Definition: NBNode.h:308
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
void addPostProcessConnection(const std::string &from, int fromLane, const std::string &to, int toLane, bool mayDefinitelyPass, bool keepClear, double contPos, double visibility, double speed, const PositionVector &customShape, bool warnOnly=false)
Adds a connection which could not be set during loading.
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter, which
double getTotalWidth() const
Returns the combined width of all lanes of this edge.
Definition: NBEdge.cpp:3198
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:245
bool myNeedGeoTransformedPruningBoundary
whether a geo transform has been applied to the pruning boundary
Definition: NBEdgeCont.h:700
A storage for options typed value containers)
Definition: OptionsCont.h:92
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:267
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:379
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:79
const std::string SUMO_PARAM_ORIGID
A structure representing a connection between two lanes.
Definition: NBEdgeCont.h:607
double speed
The speed after this change.
Definition: NBEdgeCont.h:213
Sorts splits by their position (increasing)
Definition: NBEdgeCont.h:711
void appendRailwayTurnarounds(const NBPTStopCont &sc)
Appends turnarounds to all bidiRail edges with stops.
Definition: NBEdgeCont.cpp:837
The connection was computed.
Definition: NBEdge.h:105
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:60
const Position & getPosition() const
Definition: NBNode.h:242
Represents a single node (junction) during network building.
Definition: NBNode.h:68
void dismissVehicleClassInformation()
dimiss vehicle class information
Definition: NBEdge.cpp:3352
NBTypeCont & myTypeCont
The network builder; used to obtain type information.
Definition: NBEdgeCont.h:602
void recheckLaneSpread()
Rechecks whether the lane spread is proper.
Definition: NBEdgeCont.cpp:991
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
#define NUMERICAL_EPS
Definition: config.h:148
void computeEdgeShapes(double smoothElevationThreshold=-1)
Computes the shapes of all edges stored in the container.
Definition: NBEdgeCont.cpp:858
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:434
void removeFromSinksAndSources(NBEdge *const e)
Removes the given edge from the lists of sources and sinks in all stored districts.
std::set< std::string > myTypes2Remove
Set of edges types which shall be removed.
Definition: NBEdgeCont.h:694
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
Definition: NBEdgeCont.cpp:781
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
PositionVector getCCWBoundaryLine(const NBNode &n) const
get the outer boundary of this edge when going counter-clock-wise around the given node ...
Definition: NBEdge.cpp:2851
static T maxValue(const std::vector< T > &v)
Definition: VectorHelper.h:91
std::set< std::string > myIgnoredEdges
The ids of ignored edges.
Definition: NBEdgeCont.h:664
double getOverlapWith(const PositionVector &poly, double zThreshold) const
Returns the maximum overlaps between this and the given polygon (when not separated by at least zThre...
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces occurences of the removed edge/lane in all definitions by the given edge.
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:497
void setLaneSpreadFunction(LaneSpreadFunction spread)
(Re)sets how the lanes lateral offset shall be computed
Definition: NBEdge.cpp:861
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:691
int remapIDs(bool numericaIDs, bool reservedIDs, const std::string &prefix, NBPTStopCont &sc)
remap node IDs accoring to options –numerical-ids and –reserved-ids
NBNode * myFrom
The source and the destination node.
Definition: NBEdge.h:1454
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:441
std::string idBefore
The id for the edge before the split.
Definition: NBEdgeCont.h:217
bool isSimpleContinuation(bool checkLaneNumbers=true) const
check if node is a simple continuation
Definition: NBNode.cpp:447
void copyConnectionsFrom(NBEdge *src)
copy connections from antoher edge
Definition: NBEdge.cpp:1435
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3174
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
Definition: NBEdgeCont.cpp:173
A storage for available types of edges.
Definition: NBTypeCont.h:55
double offset
lateral offset to edge geometry
Definition: NBEdgeCont.h:223
int myEdgesSplit
the number of splits of edges during the building
Definition: NBEdgeCont.h:667
std::set< std::string > myEdges2Remove
Set of ids of edges which shall explicitly be removed.
Definition: NBEdgeCont.h:682