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"
51 #include <utils/common/SysUtils.h>
52 #include <utils/common/ToString.h>
54 #include "NBAlgorithms.h"
55 #include "NBAlgorithms_Ramps.h"
56 #include "NBHeightMapper.h"
57 
58 #ifdef CHECK_MEMORY_LEAKS
59 #include <foreign/nvwa/debug_new.h>
60 #endif // CHECK_MEMORY_LEAKS
61 
62 
63 // ===========================================================================
64 // method definitions
65 // ===========================================================================
67  myEdgeCont(myTypeCont),
68  myHaveLoadedNetworkWithoutInternalEdges(false) {
69 }
70 
71 
73 
74 
75 void
77  // apply options to type control
78  myTypeCont.setDefaults(oc.getInt("default.lanenumber"), oc.getFloat("default.lanewidth"), oc.getFloat("default.speed"), oc.getInt("default.priority"));
79  // apply options to edge control
81  // apply options to traffic light logics control
83 }
84 
85 
86 void
88  const std::set<std::string>& explicitTurnarounds,
89  bool removeElements) {
91 
92 
93  const bool lefthand = oc.getBool("lefthand");
94  if (lefthand) {
95  mirrorX();
96  };
97 
98  // MODIFYING THE SETS OF NODES AND EDGES
99 
100  // Removes edges that are connecting the same node
101  long before = SysUtils::getCurrentMillis();
102  PROGRESS_BEGIN_MESSAGE("Removing self-loops");
104  PROGRESS_TIME_MESSAGE(before);
105  //
106  if (oc.exists("remove-edges.isolated") && oc.getBool("remove-edges.isolated")) {
107  before = SysUtils::getCurrentMillis();
108  PROGRESS_BEGIN_MESSAGE("Finding isolated roads");
110  PROGRESS_TIME_MESSAGE(before);
111  }
112  //
113  if (oc.exists("keep-edges.postload") && oc.getBool("keep-edges.postload")) {
114  if (oc.isSet("keep-edges.explicit") || oc.isSet("keep-edges.input-file")) {
115  before = SysUtils::getCurrentMillis();
116  PROGRESS_BEGIN_MESSAGE("Removing unwished edges");
118  PROGRESS_TIME_MESSAGE(before);
119  }
120  }
121  if (oc.getBool("junctions.join") || (oc.exists("ramps.guess") && oc.getBool("ramps.guess"))) {
122  // preliminary geometry computations to determine the length of edges
123  // This depends on turning directions and sorting of edge list
124  // in case junctions are joined geometry computations have to be repeated
125  // preliminary roundabout computations to avoid damaging roundabouts via junctions.join or ramps.guess
131  if (oc.getBool("roundabouts.guess")) {
133  }
134  const std::set<EdgeSet>& roundabouts = myEdgeCont.getRoundabouts();
135  for (std::set<EdgeSet>::const_iterator it_round = roundabouts.begin();
136  it_round != roundabouts.end(); ++it_round) {
137  std::vector<std::string> nodeIDs;
138  for (EdgeSet::const_iterator it_edge = it_round->begin(); it_edge != it_round->end(); ++it_edge) {
139  nodeIDs.push_back((*it_edge)->getToNode()->getID());
140  }
141  myNodeCont.addJoinExclusion(nodeIDs);
142  }
143  }
144  // join junctions (may create new "geometry"-nodes so it needs to come before removing these
145  if (oc.exists("junctions.join-exclude") && oc.isSet("junctions.join-exclude")) {
146  myNodeCont.addJoinExclusion(oc.getStringVector("junctions.join-exclude"));
147  }
149  if (oc.getBool("junctions.join")) {
150  before = SysUtils::getCurrentMillis();
151  PROGRESS_BEGIN_MESSAGE("Joining junction clusters");
152  numJoined += myNodeCont.joinJunctions(oc.getFloat("junctions.join-dist"), myDistrictCont, myEdgeCont, myTLLCont);
153  PROGRESS_TIME_MESSAGE(before);
154  }
155  if (oc.getBool("junctions.join") || (oc.exists("ramps.guess") && oc.getBool("ramps.guess"))) {
156  // reset geometry to avoid influencing subsequent steps (ramps.guess)
158  }
159  if (numJoined > 0) {
160  // bit of a misnomer since we're already done
161  WRITE_MESSAGE(" Joined " + toString(numJoined) + " junction cluster(s).");
162  }
163  //
164  if (removeElements) {
165  int no = 0;
166  const bool removeGeometryNodes = oc.exists("geometry.remove") && oc.getBool("geometry.remove");
167  before = SysUtils::getCurrentMillis();
168  PROGRESS_BEGIN_MESSAGE("Removing empty nodes" + std::string(removeGeometryNodes ? " and geometry nodes" : ""));
169  // removeUnwishedNodes needs turnDirections. @todo: try to call this less often
172  PROGRESS_TIME_MESSAGE(before);
173  WRITE_MESSAGE(" " + toString(no) + " nodes removed.");
174  }
175 
176  // MOVE TO ORIGIN
177  // compute new boundary after network modifications have taken place
178  Boundary boundary;
179  for (std::map<std::string, NBNode*>::const_iterator it = myNodeCont.begin(); it != myNodeCont.end(); ++it) {
180  boundary.add(it->second->getPosition());
181  }
182  for (std::map<std::string, NBEdge*>::const_iterator it = myEdgeCont.begin(); it != myEdgeCont.end(); ++it) {
183  boundary.add(it->second->getGeometry().getBoxBoundary());
184  }
185  geoConvHelper.setConvBoundary(boundary);
186 
187  if (!oc.getBool("offset.disable-normalization") && oc.isDefault("offset.x") && oc.isDefault("offset.y")) {
188  moveToOrigin(geoConvHelper, lefthand);
189  }
190  geoConvHelper.computeFinal(lefthand); // information needed for location element fixed at this point
191 
192  if (oc.exists("geometry.min-dist") && oc.isSet("geometry.min-dist")) {
193  before = SysUtils::getCurrentMillis();
194  PROGRESS_BEGIN_MESSAGE("Reducing geometries");
195  myEdgeCont.reduceGeometries(oc.getFloat("geometry.min-dist"));
196  PROGRESS_TIME_MESSAGE(before);
197  }
198  // @note: removing geometry can create similar edges so joinSimilarEdges must come afterwards
199  // @note: likewise splitting can destroy similarities so joinSimilarEdges must come before
200  if (removeElements && oc.getBool("edges.join")) {
201  before = SysUtils::getCurrentMillis();
202  PROGRESS_BEGIN_MESSAGE("Joining similar edges");
204  PROGRESS_TIME_MESSAGE(before);
205  }
206  if (oc.getBool("opposites.guess")) {
207  PROGRESS_BEGIN_MESSAGE("guessing opposite direction edges");
210  }
211  //
212  if (oc.exists("geometry.split") && oc.getBool("geometry.split")) {
213  before = SysUtils::getCurrentMillis();
214  PROGRESS_BEGIN_MESSAGE("Splitting geometry edges");
216  PROGRESS_TIME_MESSAGE(before);
217  }
218  // turning direction
219  before = SysUtils::getCurrentMillis();
220  PROGRESS_BEGIN_MESSAGE("Computing turning directions");
222  PROGRESS_TIME_MESSAGE(before);
223  // correct edge geometries to avoid overlap
225  // guess ramps
226  if ((oc.exists("ramps.guess") && oc.getBool("ramps.guess")) || (oc.exists("ramps.set") && oc.isSet("ramps.set"))) {
227  before = SysUtils::getCurrentMillis();
228  PROGRESS_BEGIN_MESSAGE("Guessing and setting on-/off-ramps");
231  PROGRESS_TIME_MESSAGE(before);
232  }
233  // guess sidewalks
234  if (oc.getBool("sidewalks.guess") || oc.getBool("sidewalks.guess.from-permissions")) {
235  const int sidewalks = myEdgeCont.guessSidewalks(oc.getFloat("default.sidewalk-width"),
236  oc.getFloat("sidewalks.guess.min-speed"),
237  oc.getFloat("sidewalks.guess.max-speed"),
238  oc.getBool("sidewalks.guess.from-permissions"));
239  WRITE_MESSAGE("Guessed " + toString(sidewalks) + " sidewalks.");
240  }
241 
242  // check whether any not previously setable connections may be set now
244 
245  // remap ids if wished
246  if (oc.getBool("numerical-ids")) {
247  int numChangedEdges = myEdgeCont.mapToNumericalIDs();
248  int numChangedNodes = myNodeCont.mapToNumericalIDs();
249  if (numChangedEdges + numChangedNodes > 0) {
250  WRITE_MESSAGE("Remapped " + toString(numChangedEdges) + " edge IDs and " + toString(numChangedNodes) + " node IDs.");
251  }
252  }
253 
254  //
255  if (oc.exists("geometry.max-angle")) {
257  DEG2RAD(oc.getFloat("geometry.max-angle")),
258  oc.getFloat("geometry.min-radius"),
259  oc.getBool("geometry.min-radius.fix"));
260  }
261 
262  // GEOMETRY COMPUTATION
263  //
264  before = SysUtils::getCurrentMillis();
265  PROGRESS_BEGIN_MESSAGE("Sorting nodes' edges");
267  PROGRESS_TIME_MESSAGE(before);
269  //
270  before = SysUtils::getCurrentMillis();
271  PROGRESS_BEGIN_MESSAGE("Computing node shapes");
272  if (oc.exists("geometry.junction-mismatch-threshold")) {
273  myNodeCont.computeNodeShapes(oc.getFloat("geometry.junction-mismatch-threshold"));
274  } else {
276  }
277  PROGRESS_TIME_MESSAGE(before);
278  //
279  before = SysUtils::getCurrentMillis();
280  PROGRESS_BEGIN_MESSAGE("Computing edge shapes");
282  PROGRESS_TIME_MESSAGE(before);
283  // resort edges based on the node and edge shapes
286 
287  // APPLY SPEED MODIFICATIONS
288  if (oc.exists("speed.offset")) {
289  const SUMOReal speedOffset = oc.getFloat("speed.offset");
290  const SUMOReal speedFactor = oc.getFloat("speed.factor");
291  if (speedOffset != 0 || speedFactor != 1 || oc.isSet("speed.minimum")) {
292  const SUMOReal speedMin = oc.isSet("speed.minimum") ? oc.getFloat("speed.minimum") : -std::numeric_limits<SUMOReal>::infinity();
293  before = SysUtils::getCurrentMillis();
294  PROGRESS_BEGIN_MESSAGE("Applying speed modifications");
295  for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) {
296  (*i).second->setSpeed(-1, MAX2((*i).second->getSpeed() * speedFactor + speedOffset, speedMin));
297  }
298  PROGRESS_TIME_MESSAGE(before);
299  }
300  }
301 
302  // CONNECTIONS COMPUTATION
303  //
304  before = SysUtils::getCurrentMillis();
305  PROGRESS_BEGIN_MESSAGE("Computing node types");
307  PROGRESS_TIME_MESSAGE(before);
308  //
309  bool haveCrossings = false;
310  if (oc.getBool("crossings.guess")) {
311  haveCrossings = true;
312  int crossings = 0;
313  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
314  crossings += (*i).second->guessCrossings();
315  }
316  WRITE_MESSAGE("Guessed " + toString(crossings) + " pedestrian crossings.");
317  }
318  if (!haveCrossings) {
319  // recheck whether we had crossings in the input
320  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
321  if (i->second->getCrossings().size() > 0) {
322  haveCrossings = true;
323  break;
324  }
325  }
326  }
327 
328  if (oc.isDefault("no-internal-links") && !haveCrossings && myHaveLoadedNetworkWithoutInternalEdges) {
329  oc.set("no-internal-links", "true");
330  }
331 
332  //
333  before = SysUtils::getCurrentMillis();
334  PROGRESS_BEGIN_MESSAGE("Computing priorities");
336  PROGRESS_TIME_MESSAGE(before);
337  //
338  before = SysUtils::getCurrentMillis();
339  PROGRESS_BEGIN_MESSAGE("Computing approached edges");
340  myEdgeCont.computeEdge2Edges(oc.getBool("no-left-connections"));
341  PROGRESS_TIME_MESSAGE(before);
342  //
343  if (oc.getBool("roundabouts.guess")) {
344  before = SysUtils::getCurrentMillis();
345  PROGRESS_BEGIN_MESSAGE("Guessing and setting roundabouts");
346  const int numGuessed = myEdgeCont.guessRoundabouts();
347  if (numGuessed > 0) {
348  WRITE_MESSAGE(" Guessed " + toString(numGuessed) + " roundabout(s).");
349  }
350  PROGRESS_TIME_MESSAGE(before);
351  }
353  //
354  before = SysUtils::getCurrentMillis();
355  PROGRESS_BEGIN_MESSAGE("Computing approaching lanes");
357  PROGRESS_TIME_MESSAGE(before);
358  //
359  before = SysUtils::getCurrentMillis();
360  PROGRESS_BEGIN_MESSAGE("Dividing of lanes on approached lanes");
363  PROGRESS_TIME_MESSAGE(before);
364  //
365  before = SysUtils::getCurrentMillis();
366  PROGRESS_BEGIN_MESSAGE("Processing turnarounds");
367  if (!oc.getBool("no-turnarounds")) {
368  myEdgeCont.appendTurnarounds(oc.getBool("no-turnarounds.tls"));
369  } else {
370  myEdgeCont.appendTurnarounds(explicitTurnarounds, oc.getBool("no-turnarounds.tls"));
371  }
372  PROGRESS_TIME_MESSAGE(before);
373  //
374  before = SysUtils::getCurrentMillis();
375  PROGRESS_BEGIN_MESSAGE("Rechecking of lane endings");
377  PROGRESS_TIME_MESSAGE(before);
378 
379  if (haveCrossings && !oc.getBool("no-internal-links")) {
380  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
381  i->second->buildCrossingsAndWalkingAreas();
382  }
383  }
384 
385  // GUESS TLS POSITIONS
386  before = SysUtils::getCurrentMillis();
387  PROGRESS_BEGIN_MESSAGE("Assigning nodes to traffic lights");
388  if (oc.isSet("tls.set")) {
389  std::vector<std::string> tlControlledNodes = oc.getStringVector("tls.set");
391  for (std::vector<std::string>::const_iterator i = tlControlledNodes.begin(); i != tlControlledNodes.end(); ++i) {
392  NBNode* node = myNodeCont.retrieve(*i);
393  if (node == 0) {
394  WRITE_WARNING("Building a tl-logic for junction '" + *i + "' is not possible." + "\n The junction '" + *i + "' is not known.");
395  } else {
397  }
398  }
399  }
401  PROGRESS_TIME_MESSAGE(before);
402  //
403  if (oc.getBool("tls.join")) {
404  before = SysUtils::getCurrentMillis();
405  PROGRESS_BEGIN_MESSAGE("Joining traffic light nodes");
406  myNodeCont.joinTLS(myTLLCont, oc.getFloat("tls.join-dist"));
407  PROGRESS_TIME_MESSAGE(before);
408  }
409 
410 
411  // COMPUTING RIGHT-OF-WAY AND TRAFFIC LIGHT PROGRAMS
412  //
413  before = SysUtils::getCurrentMillis();
414  PROGRESS_BEGIN_MESSAGE("Computing traffic light control information");
416  PROGRESS_TIME_MESSAGE(before);
417  //
418  before = SysUtils::getCurrentMillis();
419  PROGRESS_BEGIN_MESSAGE("Computing node logics");
421  PROGRESS_TIME_MESSAGE(before);
422  //
423  before = SysUtils::getCurrentMillis();
424  PROGRESS_BEGIN_MESSAGE("Computing traffic light logics");
425  std::pair<int, int> numbers = myTLLCont.computeLogics(oc);
426  PROGRESS_TIME_MESSAGE(before);
427  std::string progCount = "";
428  if (numbers.first != numbers.second) {
429  progCount = "(" + toString(numbers.second) + " programs) ";
430  }
431  WRITE_MESSAGE(" " + toString(numbers.first) + " traffic light(s) " + progCount + "computed.");
432  //
433  if (oc.isSet("street-sign-output")) {
434  before = SysUtils::getCurrentMillis();
435  PROGRESS_BEGIN_MESSAGE("Generating street signs");
437  PROGRESS_TIME_MESSAGE(before);
438  }
439 
440  // FINISHING INNER EDGES
441  if (!oc.getBool("no-internal-links")) {
442  before = SysUtils::getCurrentMillis();
443  PROGRESS_BEGIN_MESSAGE("Building inner edges");
444  for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) {
445  (*i).second->sortOutgoingConnectionsByIndex();
446  }
447  // walking areas shall only be built if crossings are wished as well
448  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
449  (*i).second->buildInnerEdges();
450  }
451  PROGRESS_TIME_MESSAGE(before);
452  }
453  if (lefthand) {
454  mirrorX();
455  };
456 
457  // report
458  WRITE_MESSAGE("-----------------------------------------------------");
459  WRITE_MESSAGE("Summary:");
461  WRITE_MESSAGE(" Network boundaries:");
462  WRITE_MESSAGE(" Original boundary : " + toString(geoConvHelper.getOrigBoundary()));
463  WRITE_MESSAGE(" Applied offset : " + toString(geoConvHelper.getOffsetBase()));
464  WRITE_MESSAGE(" Converted boundary : " + toString(geoConvHelper.getConvBoundary()));
465  WRITE_MESSAGE("-----------------------------------------------------");
467  // report on very large networks
468  if (MAX2(geoConvHelper.getConvBoundary().xmax(), geoConvHelper.getConvBoundary().ymax()) > 1000000 ||
469  MIN2(geoConvHelper.getConvBoundary().xmin(), geoConvHelper.getConvBoundary().ymin()) < -1000000) {
470  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");
471  }
472 }
473 
474 
475 void
476 NBNetBuilder::moveToOrigin(GeoConvHelper& geoConvHelper, bool lefthand) {
477  long before = SysUtils::getCurrentMillis();
478  PROGRESS_BEGIN_MESSAGE("Moving network to origin");
479  Boundary boundary = geoConvHelper.getConvBoundary();
480  const SUMOReal x = -boundary.xmin();
481  const SUMOReal y = -(lefthand ? boundary.ymax() : boundary.ymin());
482  //if (lefthand) {
483  // y = boundary.ymax();
484  //}
485  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
486  (*i).second->reshiftPosition(x, y);
487  }
488  for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) {
489  (*i).second->reshiftPosition(x, y);
490  }
491  for (std::map<std::string, NBDistrict*>::const_iterator i = myDistrictCont.begin(); i != myDistrictCont.end(); ++i) {
492  (*i).second->reshiftPosition(x, y);
493  }
494  geoConvHelper.moveConvertedBy(x, y);
495  PROGRESS_TIME_MESSAGE(before);
496 }
497 
498 
499 void
501  // mirror the network along the X-axis
502  for (std::map<std::string, NBNode*>::const_iterator i = myNodeCont.begin(); i != myNodeCont.end(); ++i) {
503  (*i).second->mirrorX();
504  }
505  for (std::map<std::string, NBEdge*>::const_iterator i = myEdgeCont.begin(); i != myEdgeCont.end(); ++i) {
506  (*i).second->mirrorX();
507  }
508  for (std::map<std::string, NBDistrict*>::const_iterator i = myDistrictCont.begin(); i != myDistrictCont.end(); ++i) {
509  (*i).second->mirrorX();
510  }
511 }
512 
513 
514 bool
515 NBNetBuilder::transformCoordinates(Position& from, bool includeInBoundary, GeoConvHelper* from_srs) {
516  Position orig(from);
517  bool ok = GeoConvHelper::getProcessing().x2cartesian(from, includeInBoundary);
518  if (ok) {
519  const NBHeightMapper& hm = NBHeightMapper::get();
520  if (hm.ready()) {
521  if (from_srs != 0 && from_srs->usingGeoProjection()) {
522  from_srs->cartesian2geo(orig);
523  }
524  SUMOReal z = hm.getZ(orig);
525  from = Position(from.x(), from.y(), z);
526  }
527  }
528  return ok;
529 }
530 
531 
532 bool
533 NBNetBuilder::transformCoordinates(PositionVector& from, bool includeInBoundary, GeoConvHelper* from_srs) {
534  const SUMOReal maxLength = OptionsCont::getOptions().getFloat("geometry.max-segment-length");
535  if (maxLength > 0 && from.size() > 1) {
536  // transformation to cartesian coordinates must happen before we can check segment length
537  PositionVector copy = from;
538  for (int i = 0; i < (int) from.size(); i++) {
539  transformCoordinates(copy[i], false);
540  }
541  // check lengths and insert new points where needed (in the original
542  // coordinate system)
543  int inserted = 0;
544  for (int i = 0; i < (int)copy.size() - 1; i++) {
545  Position start = from[i + inserted];
546  Position end = from[i + inserted + 1];
547  SUMOReal length = copy[i].distanceTo(copy[i + 1]);
548  const Position step = (end - start) * (maxLength / length);
549  int steps = 0;
550  while (length > maxLength) {
551  length -= maxLength;
552  steps++;
553  from.insert(from.begin() + i + inserted + 1, start + (step * steps));
554  inserted++;
555  }
556  }
557  // now perform the transformation again so that height mapping can be
558  // performed for the new points
559  }
560  bool ok = true;
561  for (int i = 0; i < (int) from.size(); i++) {
562  ok = ok && transformCoordinates(from[i], includeInBoundary, from_srs);
563  }
564  return ok;
565 }
566 
567 /****************************************************************************/
NBNetBuilder()
Constructor.
NBTypeCont myTypeCont
The used container for street types.
Definition: NBNetBuilder.h:229
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 ...
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins edges connecting the same nodes.
Definition: NBNodeCont.cpp:181
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) ...
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 cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
void setConvBoundary(const Boundary &boundary)
sets the converted boundary
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
bool ready() const
returns whether the NBHeightMapper has data
int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, bool removeGeometryNodes)
Removes "unwished" nodes.
Definition: NBNodeCont.cpp:320
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
Definition: NBEdgeCont.cpp:988
void mirrorX()
mirror the network along the X-axis
SUMOReal getZ(const Position &geo) const
returns height for the given geo coordinate (WGS84)
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.
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:98
bool x2cartesian(Position &from, bool includeInBoundary=true)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void guessOpposites()
Sets opposite lane information for geometrically close edges.
Definition: NBEdgeCont.cpp:753
SUMOReal xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:112
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
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
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
void avoidOverlap()
fix overlap
Definition: NBNodeCont.cpp:390
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
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
SUMOReal xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:118
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
#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)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static void reportWarnings()
reports warnings if any occured
Definition: NBRequest.cpp:775
#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 end() const
Returns the pointer to the end of the stored edges.
Definition: NBEdgeCont.h:198
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:60
void computeLanes2Lanes()
divides the incoming lanes on outgoing lanes
std::map< std::string, NBDistrict * >::const_iterator begin() const
Returns the pointer to the begin of the stored districts.
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.
std::map< std::string, NBDistrict * >::const_iterator end() const
Returns the pointer to the end of the stored districts.
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
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
T MIN2(T a, T b)
Definition: StdDefs.h:69
#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 Position getOffsetBase() const
Returns the network base.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
Definition: NBNodeCont.h:134
#define DEG2RAD(x)
Definition: GeomHelper.h:45
const Boundary & getConvBoundary() const
Returns the converted boundary.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
void setDefaults(int defaultNumLanes, SUMOReal defaultLaneWidth, SUMOReal defaultSpeed, int defaultPriority)
Sets the default values.
Definition: NBTypeCont.cpp:51
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
Definition: NBEdgeCont.h:190
void setAsTLControlled(NBNode *node, NBTrafficLightLogicCont &tlc, TrafficLightType type, std::string id="")
Sets the given node as being controlled by a tls.
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
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
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 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
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
A storage for options typed value containers)
Definition: OptionsCont.h:99
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
T get(const std::string &str) const
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
SUMOReal ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:130
const Boundary & getOrigBoundary() const
Returns the original boundary.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:110
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
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
bool myHaveLoadedNetworkWithoutInternalEdges
whether a .net.xml without internal edges was loaded
Definition: NBNetBuilder.h:241
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
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::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
Definition: NBNodeCont.h:126
std::pair< int, int > computeLogics(OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
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.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
TrafficLightType
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.