SUMO - Simulation of Urban MObility
NBNetBuilder.cpp
Go to the documentation of this file.
1 /****************************************************************************/
12 // Instance responsible for building networks
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
15 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <fstream>
38 #include "NBNetBuilder.h"
39 #include "NBNodeCont.h"
40 #include "NBEdgeCont.h"
42 #include "NBDistrictCont.h"
43 #include "NBDistrict.h"
44 #include "NBDistribution.h"
45 #include "NBRequest.h"
46 #include "NBTypeCont.h"
52 #include <utils/common/SysUtils.h>
53 #include <utils/common/ToString.h>
55 #include "NBAlgorithms.h"
56 #include "NBAlgorithms_Ramps.h"
57 #include "NBHeightMapper.h"
58 
59 #ifdef CHECK_MEMORY_LEAKS
60 #include <foreign/nvwa/debug_new.h>
61 #endif // CHECK_MEMORY_LEAKS
62 
63 
64 // ===========================================================================
65 // method definitions
66 // ===========================================================================
68  myEdgeCont(myTypeCont),
69  myHaveLoadedNetworkWithoutInternalEdges(false) {
70 }
71 
72 
74 
75 
76 void
78  // apply options to type control
79  myTypeCont.setDefaults(oc.getInt("default.lanenumber"), oc.getFloat("default.lanewidth"), oc.getFloat("default.speed"),
80  oc.getInt("default.priority"), parseVehicleClasses("", oc.getString("default.disallow")));
81  // apply options to edge control
83  // apply options to traffic light logics control
85 }
86 
87 
88 void
90  const std::set<std::string>& explicitTurnarounds,
91  bool removeElements) {
93 
94 
95  const bool lefthand = oc.getBool("lefthand");
96  if (lefthand) {
97  mirrorX();
98  };
99 
100  // MODIFYING THE SETS OF NODES AND EDGES
101 
102  // Removes edges that are connecting the same node
103  long before = SysUtils::getCurrentMillis();
104  PROGRESS_BEGIN_MESSAGE("Removing self-loops");
106  PROGRESS_TIME_MESSAGE(before);
107  //
108  if (oc.exists("remove-edges.isolated") && oc.getBool("remove-edges.isolated")) {
109  before = SysUtils::getCurrentMillis();
110  PROGRESS_BEGIN_MESSAGE("Finding isolated roads");
112  PROGRESS_TIME_MESSAGE(before);
113  }
114  //
115  if (oc.exists("keep-edges.postload") && oc.getBool("keep-edges.postload")) {
116  if (oc.isSet("keep-edges.explicit") || oc.isSet("keep-edges.input-file")) {
117  before = SysUtils::getCurrentMillis();
118  PROGRESS_BEGIN_MESSAGE("Removing unwished edges");
120  PROGRESS_TIME_MESSAGE(before);
121  }
122  }
123  if (oc.getBool("junctions.join") || (oc.exists("ramps.guess") && oc.getBool("ramps.guess"))) {
124  // preliminary geometry computations to determine the length of edges
125  // This depends on turning directions and sorting of edge list
126  // in case junctions are joined geometry computations have to be repeated
127  // preliminary roundabout computations to avoid damaging roundabouts via junctions.join or ramps.guess
133  if (oc.getBool("roundabouts.guess")) {
135  }
136  const std::set<EdgeSet>& roundabouts = myEdgeCont.getRoundabouts();
137  for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
138  it_round != roundabouts.end(); ++it_round) {
139  std::vector<std::string> nodeIDs;
140  for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
141  nodeIDs.push_back((*it_edge)->getToNode()->getID());
142  }
143  myNodeCont.addJoinExclusion(nodeIDs);
144  }
145  }
146  // join junctions (may create new "geometry"-nodes so it needs to come before removing these
147  if (oc.exists("junctions.join-exclude") && oc.isSet("junctions.join-exclude")) {
148  myNodeCont.addJoinExclusion(oc.getStringVector("junctions.join-exclude"));
149  }
151  if (oc.getBool("junctions.join")) {
152  before = SysUtils::getCurrentMillis();
153  PROGRESS_BEGIN_MESSAGE("Joining junction clusters");
154  numJoined += myNodeCont.joinJunctions(oc.getFloat("junctions.join-dist"), myDistrictCont, myEdgeCont, myTLLCont);
155  PROGRESS_TIME_MESSAGE(before);
156  }
157  if (oc.getBool("junctions.join") || (oc.exists("ramps.guess") && oc.getBool("ramps.guess"))) {
158  // reset geometry to avoid influencing subsequent steps (ramps.guess)
160  }
161  if (numJoined > 0) {
162  // bit of a misnomer since we're already done
163  WRITE_MESSAGE(" Joined " + toString(numJoined) + " junction cluster(s).");
164  }
165  //
166  if (removeElements) {
167  int no = 0;
168  const bool removeGeometryNodes = oc.exists("geometry.remove") && oc.getBool("geometry.remove");
169  before = SysUtils::getCurrentMillis();
170  PROGRESS_BEGIN_MESSAGE("Removing empty nodes" + std::string(removeGeometryNodes ? " and geometry nodes" : ""));
171  // removeUnwishedNodes needs turnDirections. @todo: try to call this less often
174  PROGRESS_TIME_MESSAGE(before);
175  WRITE_MESSAGE(" " + toString(no) + " nodes removed.");
176  }
177 
178  // MOVE TO ORIGIN
179  // compute new boundary after network modifications have taken place
180  Boundary boundary;
181  for (std::map<std::string, NBNode*>::const_iterator it = myNodeCont.begin(); it != myNodeCont.end(); ++it) {
182  boundary.add(it->second->getPosition());
183  }
184  for (std::map<std::string, NBEdge*>::const_iterator it = myEdgeCont.begin(); it != myEdgeCont.end(); ++it) {
185  boundary.add(it->second->getGeometry().getBoxBoundary());
186  }
187  geoConvHelper.setConvBoundary(boundary);
188 
189  if (!oc.getBool("offset.disable-normalization") && oc.isDefault("offset.x") && oc.isDefault("offset.y")) {
190  moveToOrigin(geoConvHelper, lefthand);
191  }
192  geoConvHelper.computeFinal(lefthand); // information needed for location element fixed at this point
193 
194  if (oc.exists("geometry.min-dist") && !oc.isDefault("geometry.min-dist")) {
195  before = SysUtils::getCurrentMillis();
196  PROGRESS_BEGIN_MESSAGE("Reducing geometries");
197  myEdgeCont.reduceGeometries(oc.getFloat("geometry.min-dist"));
198  PROGRESS_TIME_MESSAGE(before);
199  }
200  // @note: removing geometry can create similar edges so joinSimilarEdges must come afterwards
201  // @note: likewise splitting can destroy similarities so joinSimilarEdges must come before
202  if (removeElements && oc.getBool("edges.join")) {
203  before = SysUtils::getCurrentMillis();
204  PROGRESS_BEGIN_MESSAGE("Joining similar edges");
206  PROGRESS_TIME_MESSAGE(before);
207  }
208  if (oc.getBool("opposites.guess")) {
209  PROGRESS_BEGIN_MESSAGE("guessing opposite direction edges");
212  }
213  //
214  if (oc.exists("geometry.split") && oc.getBool("geometry.split")) {
215  before = SysUtils::getCurrentMillis();
216  PROGRESS_BEGIN_MESSAGE("Splitting geometry edges");
218  PROGRESS_TIME_MESSAGE(before);
219  }
220  // turning direction
221  before = SysUtils::getCurrentMillis();
222  PROGRESS_BEGIN_MESSAGE("Computing turning directions");
224  PROGRESS_TIME_MESSAGE(before);
225  // correct edge geometries to avoid overlap
227  // guess ramps
228  if ((oc.exists("ramps.guess") && oc.getBool("ramps.guess")) || (oc.exists("ramps.set") && oc.isSet("ramps.set"))) {
229  before = SysUtils::getCurrentMillis();
230  PROGRESS_BEGIN_MESSAGE("Guessing and setting on-/off-ramps");
233  PROGRESS_TIME_MESSAGE(before);
234  }
235  // guess sidewalks
236  if (oc.getBool("sidewalks.guess") || oc.getBool("sidewalks.guess.from-permissions")) {
237  const int sidewalks = myEdgeCont.guessSidewalks(oc.getFloat("default.sidewalk-width"),
238  oc.getFloat("sidewalks.guess.min-speed"),
239  oc.getFloat("sidewalks.guess.max-speed"),
240  oc.getBool("sidewalks.guess.from-permissions"));
241  WRITE_MESSAGE("Guessed " + toString(sidewalks) + " sidewalks.");
242  }
243 
244  // check whether any not previously setable connections may be set now
246 
247  // remap ids if wished
248  if (oc.getBool("numerical-ids")) {
249  int numChangedEdges = myEdgeCont.mapToNumericalIDs();
250  int numChangedNodes = myNodeCont.mapToNumericalIDs();
251  if (numChangedEdges + numChangedNodes > 0) {
252  WRITE_MESSAGE("Remapped " + toString(numChangedEdges) + " edge IDs and " + toString(numChangedNodes) + " node IDs.");
253  }
254  }
255 
256  //
257  if (oc.exists("geometry.max-angle")) {
259  DEG2RAD(oc.getFloat("geometry.max-angle")),
260  oc.getFloat("geometry.min-radius"),
261  oc.getBool("geometry.min-radius.fix"));
262  }
263 
264  // GEOMETRY COMPUTATION
265  //
266  before = SysUtils::getCurrentMillis();
267  PROGRESS_BEGIN_MESSAGE("Sorting nodes' edges");
269  PROGRESS_TIME_MESSAGE(before);
271  //
272  // PABLO PARTE IMPORTANTE
273  before = SysUtils::getCurrentMillis();
274  PROGRESS_BEGIN_MESSAGE("Computing node shapes");
275  if (oc.exists("geometry.junction-mismatch-threshold")) {
276  myNodeCont.computeNodeShapes(oc.getFloat("geometry.junction-mismatch-threshold"));
277  } else {
279  }
280  PROGRESS_TIME_MESSAGE(before);
281  //
282  before = SysUtils::getCurrentMillis();
283  PROGRESS_BEGIN_MESSAGE("Computing edge shapes");
285  PROGRESS_TIME_MESSAGE(before);
286  // resort edges based on the node and edge shapes
289 
290  // APPLY SPEED MODIFICATIONS
291  if (oc.exists("speed.offset")) {
292  const SUMOReal speedOffset = oc.getFloat("speed.offset");
293  const SUMOReal speedFactor = oc.getFloat("speed.factor");
294  if (speedOffset != 0 || speedFactor != 1) {
295  const SUMOReal speedMin = oc.getFloat("speed.minimum");
296  before = SysUtils::getCurrentMillis();
297  PROGRESS_BEGIN_MESSAGE("Applying speed modifications");
298  for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) {
299  (*i).second->setSpeed(-1, MAX2((*i).second->getSpeed() * speedFactor + speedOffset, speedMin));
300  }
301  PROGRESS_TIME_MESSAGE(before);
302  }
303  }
304 
305  // CONNECTIONS COMPUTATION
306  //
307  before = SysUtils::getCurrentMillis();
308  PROGRESS_BEGIN_MESSAGE("Computing node types");
310  PROGRESS_TIME_MESSAGE(before);
311  //
312  bool haveCrossings = false;
313  if (oc.getBool("crossings.guess")) {
314  haveCrossings = true;
315  int crossings = 0;
316  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
317  crossings += (*i).second->guessCrossings();
318  }
319  WRITE_MESSAGE("Guessed " + toString(crossings) + " pedestrian crossings.");
320  }
321  if (!haveCrossings) {
322  // recheck whether we had crossings in the input
323  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
324  if (i->second->getCrossings().size() > 0) {
325  haveCrossings = true;
326  break;
327  }
328  }
329  }
330 
331  if (oc.isDefault("no-internal-links") && !haveCrossings && myHaveLoadedNetworkWithoutInternalEdges) {
332  oc.set("no-internal-links", "true");
333  }
334 
335  //
336  before = SysUtils::getCurrentMillis();
337  PROGRESS_BEGIN_MESSAGE("Computing priorities");
339  PROGRESS_TIME_MESSAGE(before);
340  //
341  before = SysUtils::getCurrentMillis();
342  PROGRESS_BEGIN_MESSAGE("Computing approached edges");
343  myEdgeCont.computeEdge2Edges(oc.getBool("no-left-connections"));
344  PROGRESS_TIME_MESSAGE(before);
345  //
346  if (oc.getBool("roundabouts.guess")) {
347  before = SysUtils::getCurrentMillis();
348  PROGRESS_BEGIN_MESSAGE("Guessing and setting roundabouts");
349  const int numGuessed = myEdgeCont.guessRoundabouts();
350  if (numGuessed > 0) {
351  WRITE_MESSAGE(" Guessed " + toString(numGuessed) + " roundabout(s).");
352  }
353  PROGRESS_TIME_MESSAGE(before);
354  }
356  //
357  before = SysUtils::getCurrentMillis();
358  PROGRESS_BEGIN_MESSAGE("Computing approaching lanes");
360  PROGRESS_TIME_MESSAGE(before);
361  //
362  before = SysUtils::getCurrentMillis();
363  PROGRESS_BEGIN_MESSAGE("Dividing of lanes on approached lanes");
366  PROGRESS_TIME_MESSAGE(before);
367  //
368  before = SysUtils::getCurrentMillis();
369  PROGRESS_BEGIN_MESSAGE("Processing turnarounds");
370  if (!oc.getBool("no-turnarounds")) {
371  myEdgeCont.appendTurnarounds(oc.getBool("no-turnarounds.tls"));
372  } else {
373  myEdgeCont.appendTurnarounds(explicitTurnarounds, oc.getBool("no-turnarounds.tls"));
374  }
375  PROGRESS_TIME_MESSAGE(before);
376  //
377  before = SysUtils::getCurrentMillis();
378  PROGRESS_BEGIN_MESSAGE("Rechecking of lane endings");
380  PROGRESS_TIME_MESSAGE(before);
381 
382  if (haveCrossings && !oc.getBool("no-internal-links")) {
383  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
384  i->second->buildCrossingsAndWalkingAreas();
385  }
386  }
387 
388  // GUESS TLS POSITIONS
389  before = SysUtils::getCurrentMillis();
390  PROGRESS_BEGIN_MESSAGE("Assigning nodes to traffic lights");
391  if (oc.isSet("tls.set")) {
392  std::vector<std::string> tlControlledNodes = oc.getStringVector("tls.set");
394  for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) {
395  NBNode* node = myNodeCont.retrieve(*i);
396  if (node == 0) {
397  WRITE_WARNING("Building a tl-logic for junction '" + *i + "' is not possible." + "\n The junction '" + *i + "' is not known.");
398  } else {
400  }
401  }
402  }
404  PROGRESS_TIME_MESSAGE(before);
405  //
406  if (oc.getBool("tls.join")) {
407  before = SysUtils::getCurrentMillis();
408  PROGRESS_BEGIN_MESSAGE("Joining traffic light nodes");
409  myNodeCont.joinTLS(myTLLCont, oc.getFloat("tls.join-dist"));
410  PROGRESS_TIME_MESSAGE(before);
411  }
412 
413 
414  // COMPUTING RIGHT-OF-WAY AND TRAFFIC LIGHT PROGRAMS
415  //
416  before = SysUtils::getCurrentMillis();
417  PROGRESS_BEGIN_MESSAGE("Computing traffic light control information");
419  PROGRESS_TIME_MESSAGE(before);
420  //
421  before = SysUtils::getCurrentMillis();
422  PROGRESS_BEGIN_MESSAGE("Computing node logics");
424  PROGRESS_TIME_MESSAGE(before);
425  //
426  before = SysUtils::getCurrentMillis();
427  PROGRESS_BEGIN_MESSAGE("Computing traffic light logics");
428  std::pair<int, int> numbers = myTLLCont.computeLogics(oc);
429  PROGRESS_TIME_MESSAGE(before);
430  std::string progCount = "";
431  if (numbers.first != numbers.second) {
432  progCount = "(" + toString(numbers.second) + " programs) ";
433  }
434  WRITE_MESSAGE(" " + toString(numbers.first) + " traffic light(s) " + progCount + "computed.");
435  //
436  if (oc.isSet("street-sign-output")) {
437  before = SysUtils::getCurrentMillis();
438  PROGRESS_BEGIN_MESSAGE("Generating street signs");
440  PROGRESS_TIME_MESSAGE(before);
441  }
442 
443  // FINISHING INNER EDGES
444  if (!oc.getBool("no-internal-links")) {
445  before = SysUtils::getCurrentMillis();
446  PROGRESS_BEGIN_MESSAGE("Building inner edges");
447  for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) {
448  (*i).second->sortOutgoingConnectionsByIndex();
449  }
450  // walking areas shall only be built if crossings are wished as well
451  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
452  (*i).second->buildInnerEdges();
453  }
454  PROGRESS_TIME_MESSAGE(before);
455  }
456  // PATCH NODE SHAPES
457  if (OptionsCont::getOptions().getFloat("junctions.scurve-stretch") > 0) {
458  // @note: notes have collected correction hints in buildInnerEdges()
459  before = SysUtils::getCurrentMillis();
460  PROGRESS_BEGIN_MESSAGE("stretching junctions to smooth geometries");
464  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
465  (*i).second->buildInnerEdges();
466  }
467  PROGRESS_TIME_MESSAGE(before);
468  }
469  if (lefthand) {
470  mirrorX();
471  };
472 
473  // report
474  WRITE_MESSAGE("-----------------------------------------------------");
475  WRITE_MESSAGE("Summary:");
477  WRITE_MESSAGE(" Network boundaries:");
478  WRITE_MESSAGE(" Original boundary : " + toString(geoConvHelper.getOrigBoundary()));
479  WRITE_MESSAGE(" Applied offset : " + toString(geoConvHelper.getOffsetBase()));
480  WRITE_MESSAGE(" Converted boundary : " + toString(geoConvHelper.getConvBoundary()));
481  WRITE_MESSAGE("-----------------------------------------------------");
483  // report on very large networks
484  if (MAX2(geoConvHelper.getConvBoundary().xmax(), geoConvHelper.getConvBoundary().ymax()) > 1000000 ||
485  MIN2(geoConvHelper.getConvBoundary().xmin(), geoConvHelper.getConvBoundary().ymin()) < -1000000) {
486  WRITE_WARNING("Network contains very large coordinates and will probably flicker in the GUI. Check for outlying nodes and make sure the network is shifted to the coordinate origin");
487  }
488 }
489 
490 
491 void
492 NBNetBuilder::moveToOrigin(GeoConvHelper& geoConvHelper, bool lefthand) {
493  long before = SysUtils::getCurrentMillis();
494  PROGRESS_BEGIN_MESSAGE("Moving network to origin");
495  Boundary boundary = geoConvHelper.getConvBoundary();
496  const SUMOReal x = -boundary.xmin();
497  const SUMOReal y = -(lefthand ? boundary.ymax() : boundary.ymin());
498  //if (lefthand) {
499  // y = boundary.ymax();
500  //}
501  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
502  (*i).second->reshiftPosition(x, y);
503  }
504  for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) {
505  (*i).second->reshiftPosition(x, y);
506  }
507  for (std::map<std::string, NBDistrict*>::const_iterator i = myDistrictCont.begin(); i != myDistrictCont.end(); ++i) {
508  (*i).second->reshiftPosition(x, y);
509  }
510  geoConvHelper.moveConvertedBy(x, y);
511  PROGRESS_TIME_MESSAGE(before);
512 }
513 
514 
515 void
517  // mirror the network along the X-axis
518  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
519  (*i).second->mirrorX();
520  }
521  for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) {
522  (*i).second->mirrorX();
523  }
524  for (std::map<std::string, NBDistrict*>::const_iterator i = myDistrictCont.begin(); i != myDistrictCont.end(); ++i) {
525  (*i).second->mirrorX();
526  }
527 }
528 
529 
530 bool
531 NBNetBuilder::transformCoordinates(Position& from, bool includeInBoundary, GeoConvHelper* from_srs) {
532  Position orig(from);
533  bool ok = GeoConvHelper::getProcessing().x2cartesian(from, includeInBoundary);
534  if (ok) {
535  const NBHeightMapper& hm = NBHeightMapper::get();
536  if (hm.ready()) {
537  if (from_srs != 0 && from_srs->usingGeoProjection()) {
538  from_srs->cartesian2geo(orig);
539  }
540  SUMOReal z = hm.getZ(orig);
541  from = Position(from.x(), from.y(), z);
542  }
543  }
544  return ok;
545 }
546 
547 
548 bool
549 NBNetBuilder::transformCoordinates(PositionVector& from, bool includeInBoundary, GeoConvHelper* from_srs) {
550  const SUMOReal maxLength = OptionsCont::getOptions().getFloat("geometry.max-segment-length");
551  if (maxLength > 0 && from.size() > 1) {
552  // transformation to cartesian coordinates must happen before we can check segment length
553  PositionVector copy = from;
554  for (int i = 0; i < (int) from.size(); i++) {
555  transformCoordinates(copy[i], false);
556  }
557  // check lengths and insert new points where needed (in the original
558  // coordinate system)
559  int inserted = 0;
560  for (int i = 0; i < (int)copy.size() - 1; i++) {
561  Position start = from[i + inserted];
562  Position end = from[i + inserted + 1];
563  SUMOReal length = copy[i].distanceTo(copy[i + 1]);
564  const Position step = (end - start) * (maxLength / length);
565  int steps = 0;
566  while (length > maxLength) {
567  length -= maxLength;
568  steps++;
569  from.insert(from.begin() + i + inserted + 1, start + (step * steps));
570  inserted++;
571  }
572  }
573  // now perform the transformation again so that height mapping can be
574  // performed for the new points
575  }
576  bool ok = true;
577  for (int i = 0; i < (int) from.size(); i++) {
578  ok = ok && transformCoordinates(from[i], includeInBoundary, from_srs);
579  }
580  return ok;
581 }
582 
583 /****************************************************************************/
NBNetBuilder()
Constructor.
NBTypeCont myTypeCont
The used container for street types.
Definition: NBNetBuilder.h:229
SUMOReal getZ(const Position &geo) const
returns height for the given geo coordinate (WGS84)
int guessSidewalks(SUMOReal width, SUMOReal minSpeed, SUMOReal maxSpeed, bool fromPermissions)
add sidwalks to edges within the given limits or permissions and return the number of edges affected ...
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:110
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins edges connecting the same nodes.
Definition: NBNodeCont.cpp:181
void removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes self-loop edges (edges where the source and the destination node are the same) ...
Definition: NBNodeCont.cpp:169
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
Definition: NBEdgeCont.cpp:586
void markRoundabouts()
mark edge priorities and prohibit turn-arounds for all roundabout edges
void setConvBoundary(const Boundary &boundary)
sets the converted boundary
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
Definition: NBNodeCont.h:126
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
Definition: NBNodeCont.cpp:450
const Boundary & getConvBoundary() const
Returns the converted boundary.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
Definition: NBNodeCont.h:134
int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, bool removeGeometryNodes)
Removes "unwished" nodes.
Definition: NBNodeCont.cpp:320
void mirrorX()
mirror the network along the X-axis
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
Definition: NBEdgeCont.cpp:881
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool removeElements=true)
Performs the network building steps.
static void computeFinal(bool lefthand=false)
compute the location attributes which will be used for output based on the loaded location data...
~NBNetBuilder()
Destructor.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:98
bool x2cartesian(Position &from, bool includeInBoundary=true)
std::map< std::string, NBDistrict * >::const_iterator end() const
Returns the pointer to the end of the stored districts.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
void guessOpposites()
Sets opposite lane information for geometrically close edges.
Definition: NBEdgeCont.cpp:753
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:142
int joinLoadedClusters(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins loaded junction clusters (see NIXMLNodesHandler)
Definition: NBNodeCont.cpp:484
T MAX2(T a, T b)
Definition: StdDefs.h:75
const Boundary & getOrigBoundary() const
Returns the original boundary.
void generateStreetSigns()
assigns street signs to edges based on toNode types
void recheckPostProcessConnections()
Try to set any stored connections.
Definition: NBEdgeCont.cpp:810
int mapToNumericalIDs()
ensure that all node ids are integers
void guessTLs(OptionsCont &oc, NBTrafficLightLogicCont &tlc)
Guesses which junctions or junction clusters shall be controlled by tls.
Definition: NBNodeCont.cpp:839
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
Definition: NBEdgeCont.h:198
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:148
void avoidOverlap()
fix overlap
Definition: NBNodeCont.cpp:390
std::map< std::string, NBDistrict * >::const_iterator begin() const
Returns the pointer to the begin of the stored districts.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
void setDefaults(int defaultNumLanes, SUMOReal defaultLaneWidth, SUMOReal defaultSpeed, int defaultPriority, SVCPermissions defaultPermissions)
Sets the default values.
Definition: NBTypeCont.cpp:51
int mapToNumericalIDs()
ensure that all edge ids are integers
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node&#39;s edges clockwise regarding driving direction.
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
Definition: NBEdgeCont.cpp:602
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:130
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void checkGeometries(const SUMOReal maxAngle, const SUMOReal minRadius, bool fix)
Definition: NBEdgeCont.cpp:567
void computeLogics(const NBEdgeCont &ec, OptionsCont &oc)
build the list of outgoing edges and lanes
static const NBHeightMapper & get()
return the singleton instance (maybe 0)
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
static void reportWarnings()
reports warnings if any occured
Definition: NBRequest.cpp:778
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
#define PROGRESS_TIME_MESSAGE(before)
Definition: MsgHandler.h:204
void reduceGeometries(const SUMOReal minDist)
Definition: NBEdgeCont.cpp:559
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
Definition: NBEdgeCont.h:190
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:60
void computeLanes2Lanes()
divides the incoming lanes on outgoing lanes
int joinJunctions(SUMOReal maxDist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins junctions that are very close together.
Definition: NBNodeCont.cpp:508
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
Definition: NBEdgeCont.cpp:531
void joinTLS(NBTrafficLightLogicCont &tlc, SUMOReal maxdist)
Builds clusters of tls-controlled junctions and joins the control if possible.
static StringBijection< TrafficLightType > TrafficLightTypes
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
static void computeEdgePriorities(NBNodeCont &nc)
Computes edge priorities within a node.
A list of positions.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
Definition: NBEdgeCont.cpp:82
NBEdgeCont myEdgeCont
The used container for edges.
Definition: NBNetBuilder.h:232
T get(const std::string &str) const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
Definition: NBEdgeCont.cpp:594
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
Definition: NBEdgeCont.cpp:658
NBTrafficLightLogicCont myTLLCont
The used container for traffic light logics.
Definition: NBNetBuilder.h:235
bool exists(const std::string &name) const
Returns the information whether the named option is known.
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:69
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition: MsgHandler.h:202
void splitGeometry(NBNodeCont &nc)
Splits edges into multiple if they have a complex geometry.
Definition: NBEdgeCont.cpp:548
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
Definition: NBEdgeCont.cpp:988
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
#define DEG2RAD(x)
Definition: GeomHelper.h:45
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
void setAsTLControlled(NBNode *node, NBTrafficLightLogicCont &tlc, TrafficLightType type, std::string id="")
Sets the given node as being controlled by a tls.
static void computeRamps(NBNetBuilder &nb, OptionsCont &oc)
Computes highway on-/off-ramps (if wished)
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
void appendTurnarounds(bool noTLSControlled)
Appends turnarounds to all edges stored in the container.
Definition: NBEdgeCont.cpp:634
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:136
static void computeNodeTypes(NBNodeCont &nc)
Computes node types.
void moveToOrigin(GeoConvHelper &geoConvHelper, bool lefthand)
shift network so its lower left corner is at 0,0
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:90
void removeIsolatedRoads(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes sequences of edges that are not connected with a junction. Simple roads without junctions som...
Definition: NBNodeCont.cpp:226
A storage for options typed value containers)
Definition: OptionsCont.h:99
const Position getOffsetBase() const
Returns the network base.
void computeNodeShapes(SUMOReal mismatchThreshold=-1)
Compute the junction shape for this node.
void computeEdgeShapes()
Computes the shapes of all edges stored in the container.
Definition: NBEdgeCont.cpp:650
Represents a single node (junction) during network building.
Definition: NBNode.h:74
static void computeTurnDirections(NBNodeCont &nc, bool warn=true)
Computes turnaround destinations for all edges (if exist)
NBDistrictCont myDistrictCont
The used container for districts.
Definition: NBNetBuilder.h:238
#define SUMOReal
Definition: config.h:213
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
Definition: NBEdgeCont.cpp:610
static long getCurrentMillis()
Returns the current time in milliseconds.
Definition: SysUtils.cpp:50
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:203
bool myHaveLoadedNetworkWithoutInternalEdges
whether a .net.xml without internal edges was loaded
Definition: NBNetBuilder.h:241
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
NBNodeCont myNodeCont
The used container for nodes.
Definition: NBNetBuilder.h:226
void setTLControllingInformation(const NBEdgeCont &ec, const NBNodeCont &nc)
Informs the edges about being controlled by a tls.
std::pair< int, int > computeLogics(OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
bool ready() const
returns whether the NBHeightMapper has data
Set z-values for all network positions based on data from a height map.
void moveConvertedBy(SUMOReal x, SUMOReal y)
Shifts the converted boundary by the given amounts.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
TrafficLightType