SUMO - Simulation of Urban MObility
NWWriter_SUMO.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 // Exporter writing networks using the SUMO format
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 #include <cmath>
27 #include <algorithm>
31 #include <utils/common/ToString.h>
36 #include <netbuild/NBEdge.h>
37 #include <netbuild/NBEdgeCont.h>
38 #include <netbuild/NBNode.h>
39 #include <netbuild/NBNodeCont.h>
40 #include <netbuild/NBNetBuilder.h>
42 #include <netbuild/NBDistrict.h>
43 #include <netbuild/NBHelpers.h>
44 #include "NWFrame.h"
45 #include "NWWriter_SUMO.h"
46 
47 
48 //#define DEBUG_OPPOSITE_INTERNAL
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 // ---------------------------------------------------------------------------
54 // static methods
55 // ---------------------------------------------------------------------------
56 void
58  // check whether a sumo net-file shall be generated
59  if (!oc.isSet("output-file")) {
60  return;
61  }
62  OutputDevice& device = OutputDevice::getDevice(oc.getString("output-file"));
63  std::map<SumoXMLAttr, std::string> attrs;
65  if (oc.getBool("lefthand")) {
66  attrs[SUMO_ATTR_LEFTHAND] = "true";
67  }
68  const int cornerDetail = oc.getInt("junctions.corner-detail");
69  if (cornerDetail > 0) {
70  attrs[SUMO_ATTR_CORNERDETAIL] = toString(cornerDetail);
71  }
72  if (!oc.isDefault("junctions.internal-link-detail")) {
73  attrs[SUMO_ATTR_LINKDETAIL] = toString(oc.getInt("junctions.internal-link-detail"));
74  }
75  if (oc.getBool("rectangular-lane-cut")) {
76  attrs[SUMO_ATTR_RECTANGULAR_LANE_CUT] = "true";
77  }
78  if (oc.getBool("crossings.guess") || oc.getBool("walkingareas")) {
79  attrs[SUMO_ATTR_WALKINGAREAS] = "true";
80  }
81  if (oc.getFloat("junctions.limit-turn-speed") > 0) {
82  attrs[SUMO_ATTR_LIMIT_TURN_SPEED] = toString(oc.getFloat("junctions.limit-turn-speed"));
83  }
84  if (!oc.isDefault("check-lane-foes.all")) {
85  attrs[SUMO_ATTR_CHECKLANEFOES_ALL] = toString(oc.getBool("check-lane-foes.all"));
86  }
87  if (!oc.isDefault("check-lane-foes.roundabout")) {
88  attrs[SUMO_ATTR_CHECKLANEFOES_ROUNDABOUT] = toString(oc.getBool("check-lane-foes.roundabout"));
89  }
90  device.writeXMLHeader("net", "net_file.xsd", attrs); // street names may contain non-ascii chars
91  device.lf();
92  // get involved container
93  const NBNodeCont& nc = nb.getNodeCont();
94  const NBEdgeCont& ec = nb.getEdgeCont();
95  const NBDistrictCont& dc = nb.getDistrictCont();
96 
97  // write network offsets and projection
99 
100  // write edge types and restrictions
101  nb.getTypeCont().writeTypes(device);
102 
103  // write inner lanes
104  if (!oc.getBool("no-internal-links")) {
105  bool hadAny = false;
106  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
107  hadAny |= writeInternalEdges(device, ec, *(*i).second);
108  }
109  if (hadAny) {
110  device.lf();
111  }
112  }
113 
114  // write edges with lanes and connected edges
115  bool noNames = !oc.getBool("output.street-names");
116  for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
117  writeEdge(device, *(*i).second, noNames);
118  }
119  device.lf();
120 
121  // write tls logics
122  writeTrafficLights(device, nb.getTLLogicCont());
123 
124  // write the nodes (junctions)
125  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
126  writeJunction(device, *(*i).second);
127  }
128  device.lf();
129  const bool includeInternal = !oc.getBool("no-internal-links");
130  if (includeInternal) {
131  // ... internal nodes if not unwanted
132  bool hadAny = false;
133  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
134  hadAny |= writeInternalNodes(device, *(*i).second);
135  }
136  if (hadAny) {
137  device.lf();
138  }
139  }
140 
141  // write the successors of lanes
142  int numConnections = 0;
143  for (std::map<std::string, NBEdge*>::const_iterator it_edge = ec.begin(); it_edge != ec.end(); it_edge++) {
144  NBEdge* from = it_edge->second;
145  const std::vector<NBEdge::Connection> connections = from->getConnections();
146  numConnections += (int)connections.size();
147  for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
148  writeConnection(device, *from, *it_c, includeInternal);
149  }
150  }
151  if (numConnections > 0) {
152  device.lf();
153  }
154  if (includeInternal) {
155  // ... internal successors if not unwanted
156  bool hadAny = false;
157  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
158  hadAny |= writeInternalConnections(device, *(*i).second);
159  }
160  if (hadAny) {
161  device.lf();
162  }
163  }
164  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
165  NBNode* node = (*i).second;
166  // write connections from pedestrian crossings
167  std::vector<NBNode::Crossing*> crossings = node->getCrossings();
168  for (auto c : crossings) {
169  NWWriter_SUMO::writeInternalConnection(device, c->id, c->nextWalkingArea, 0, 0, "", LINKDIR_STRAIGHT, c->tlID, c->tlLinkIndex2);
170  }
171  // write connections from pedestrian walking areas
172  for (const NBNode::WalkingArea& wa : node->getWalkingAreas()) {
173  for (const std::string& cID : wa.nextCrossings) {
174  const NBNode::Crossing& nextCrossing = *node->getCrossing(cID);
175  // connection to next crossing (may be tls-controlled)
177  device.writeAttr(SUMO_ATTR_FROM, wa.id);
178  device.writeAttr(SUMO_ATTR_TO, cID);
179  device.writeAttr(SUMO_ATTR_FROM_LANE, 0);
180  device.writeAttr(SUMO_ATTR_TO_LANE, 0);
181  if (nextCrossing.tlID != "") {
182  device.writeAttr(SUMO_ATTR_TLID, nextCrossing.tlID);
183  assert(nextCrossing.tlLinkIndex >= 0);
184  device.writeAttr(SUMO_ATTR_TLLINKINDEX, nextCrossing.tlLinkIndex);
185  }
188  device.closeTag();
189  }
190  // optional connections from/to sidewalk
191  std::string edgeID;
192  int laneIndex;
193  for (const std::string& sw : wa.nextSidewalks) {
194  NBHelpers::interpretLaneID(sw, edgeID, laneIndex);
195  NWWriter_SUMO::writeInternalConnection(device, wa.id, edgeID, 0, laneIndex, "");
196  }
197  for (const std::string& sw : wa.prevSidewalks) {
198  NBHelpers::interpretLaneID(sw, edgeID, laneIndex);
199  NWWriter_SUMO::writeInternalConnection(device, edgeID, wa.id, laneIndex, 0, "");
200  }
201  }
202  }
203 
204  // write loaded prohibitions
205  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
206  writeProhibitions(device, i->second->getProhibitions());
207  }
208 
209  // write roundabout information
210  writeRoundabouts(device, ec.getRoundabouts(), ec);
211 
212  // write the districts
213  for (std::map<std::string, NBDistrict*>::const_iterator i = dc.begin(); i != dc.end(); i++) {
214  writeDistrict(device, *(*i).second);
215  }
216  if (dc.size() != 0) {
217  device.lf();
218  }
219  device.close();
220 }
221 
222 
223 std::string
224 NWWriter_SUMO::getOppositeInternalID(const NBEdgeCont& ec, const NBEdge* from, const NBEdge::Connection& con, double& oppositeLength) {
225  const NBEdge::Lane& succ = con.toEdge->getLanes()[con.toLane];
226  const NBEdge::Lane& pred = from->getLanes()[con.fromLane];
227  const bool lefthand = OptionsCont::getOptions().getBool("lefthand");
228  if (succ.oppositeID != "" && succ.oppositeID != "-" && pred.oppositeID != "" && pred.oppositeID != "-") {
229 #ifdef DEBUG_OPPOSITE_INTERNAL
230  std::cout << "getOppositeInternalID con=" << con.getDescription(from) << " (" << con.getInternalLaneID() << ")\n";
231 #endif
232  // find the connection that connects succ.oppositeID to pred.oppositeID
233  const NBEdge* succOpp = ec.retrieve(succ.oppositeID.substr(0, succ.oppositeID.rfind("_")));
234  const NBEdge* predOpp = ec.retrieve(pred.oppositeID.substr(0, pred.oppositeID.rfind("_")));
235  assert(succOpp != 0);
236  assert(predOpp != 0);
237  const std::vector<NBEdge::Connection>& connections = succOpp->getConnections();
238  for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
239  const NBEdge::Connection& conOpp = *it_c;
240  if (succOpp != from // turnaround
241  && predOpp == conOpp.toEdge
242  && succOpp->getLaneID(conOpp.fromLane) == succ.oppositeID
243  && predOpp->getLaneID(conOpp.toLane) == pred.oppositeID
244  && from->getToNode()->getDirection(from, con.toEdge, lefthand) == LINKDIR_STRAIGHT
245  && from->getToNode()->getDirection(succOpp, predOpp, lefthand) == LINKDIR_STRAIGHT
246  ) {
247 #ifdef DEBUG_OPPOSITE_INTERNAL
248  std::cout << " found " << conOpp.getInternalLaneID() << "\n";
249 #endif
250  oppositeLength = conOpp.length;
251  return conOpp.getInternalLaneID();
252  } else {
253  /*
254  #ifdef DEBUG_OPPOSITE_INTERNAL
255  std::cout << " rejected " << conOpp.getInternalLaneID()
256  << "\n succ.oppositeID=" << succ.oppositeID
257  << "\n succOppLane=" << succOpp->getLaneID(conOpp.fromLane)
258  << "\n pred.oppositeID=" << pred.oppositeID
259  << "\n predOppLane=" << predOpp->getLaneID(conOpp.toLane)
260  << "\n predOpp=" << predOpp->getID()
261  << "\n conOppTo=" << conOpp.toEdge->getID()
262  << "\n len1=" << con.shape.length()
263  << "\n len2=" << conOpp.shape.length()
264  << "\n";
265  #endif
266  */
267  }
268  }
269  return "";
270  } else {
271  return "";
272  }
273 }
274 
275 
276 bool
278  bool ret = false;
279  const EdgeVector& incoming = n.getIncomingEdges();
280  // first pass: determine opposite internal edges and average their length
281  std::map<std::string, std::string> oppositeLaneID;
282  std::map<std::string, double> oppositeLengths;
283  for (NBEdge* e : incoming) {
284  for (const NBEdge::Connection& c : e->getConnections()) {
285  double oppositeLength = 0;
286  const std::string op = getOppositeInternalID(ec, e, c, oppositeLength);
287  oppositeLaneID[c.getInternalLaneID()] = op;
288  if (op != "") {
289  oppositeLengths[c.id] = oppositeLength;
290  }
291  }
292  }
293  if (oppositeLengths.size() > 0) {
294  for (NBEdge* e : incoming) {
295  for (NBEdge::Connection& c : e->getConnections()) {
296  if (oppositeLengths.count(c.id) > 0) {
297  c.length = (c.length + oppositeLengths[c.id]) / 2;
298  }
299  }
300  }
301  }
302 
303  for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
304  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
305  if (elv.size() > 0) {
306  bool haveVia = false;
307  std::string edgeID = "";
308  // second pass: write non-via edges
309  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
310  if ((*k).toEdge == nullptr) {
311  assert(false); // should never happen. tell me when it does
312  continue;
313  }
314  if (edgeID != (*k).id) {
315  if (edgeID != "") {
316  // close the previous edge
317  into.closeTag();
318  }
319  edgeID = (*k).id;
320  into.openTag(SUMO_TAG_EDGE);
321  into.writeAttr(SUMO_ATTR_ID, edgeID);
323  // open a new edge
324  }
325  // to avoid changing to an internal lane which has a successor
326  // with the wrong permissions we need to inherit them from the successor
327  const NBEdge::Lane& successor = (*k).toEdge->getLanes()[(*k).toLane];
328  const double width = n.isConstantWidthTransition() && (*i)->getNumLanes() > (*k).toEdge->getNumLanes() ? (*i)->getLaneWidth((*k).fromLane) : successor.width;
329  writeLane(into, (*k).getInternalLaneID(), (*k).vmax,
330  successor.permissions, successor.preferred,
331  NBEdge::UNSPECIFIED_OFFSET, std::map<int, double>(), width, (*k).shape, &(*k),
332  (*k).length, (*k).internalLaneIndex, oppositeLaneID[(*k).getInternalLaneID()]);
333  haveVia = haveVia || (*k).haveVia;
334  }
335  ret = true;
336  into.closeTag(); // close the last edge
337  // third pass: write via edges
338  if (haveVia) {
339  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
340  if (!(*k).haveVia) {
341  continue;
342  }
343  if ((*k).toEdge == nullptr) {
344  assert(false); // should never happen. tell me when it does
345  continue;
346  }
347  const NBEdge::Lane& successor = (*k).toEdge->getLanes()[(*k).toLane];
348  into.openTag(SUMO_TAG_EDGE);
349  into.writeAttr(SUMO_ATTR_ID, (*k).viaID);
351  writeLane(into, (*k).viaID + "_0", (*k).vmax, successor.permissions, successor.preferred,
352  NBEdge::UNSPECIFIED_OFFSET, std::map<int, double>(), successor.width, (*k).viaShape, &(*k),
353  MAX2((*k).viaShape.length(), POSITION_EPS), // microsim needs positive length
354  0, "");
355  into.closeTag();
356  }
357  }
358  }
359  }
360  // write pedestrian crossings
361  for (auto c : n.getCrossings()) {
362  into.openTag(SUMO_TAG_EDGE);
363  into.writeAttr(SUMO_ATTR_ID, c->id);
365  into.writeAttr(SUMO_ATTR_CROSSING_EDGES, c->edges);
366  writeLane(into, c->id + "_0", 1, SVC_PEDESTRIAN, 0,
367  NBEdge::UNSPECIFIED_OFFSET, std::map<int, double>(), c->width, c->shape, nullptr, MAX2(c->shape.length(), POSITION_EPS), 0, "", false, c->customShape.size() != 0);
368  into.closeTag();
369  }
370  // write pedestrian walking areas
371  const std::vector<NBNode::WalkingArea>& WalkingAreas = n.getWalkingAreas();
372  for (std::vector<NBNode::WalkingArea>::const_iterator it = WalkingAreas.begin(); it != WalkingAreas.end(); it++) {
373  const NBNode::WalkingArea& wa = *it;
374  into.openTag(SUMO_TAG_EDGE);
375  into.writeAttr(SUMO_ATTR_ID, wa.id);
377  writeLane(into, wa.id + "_0", 1, SVC_PEDESTRIAN, 0,
378  NBEdge::UNSPECIFIED_OFFSET, std::map<int, double>(), wa.width, wa.shape, nullptr, wa.length, 0, "", false, wa.hasCustomShape);
379  into.closeTag();
380  }
381  return ret;
382 }
383 
384 
385 void
386 NWWriter_SUMO::writeEdge(OutputDevice& into, const NBEdge& e, bool noNames) {
387  // write the edge's begin
390  into.writeAttr(SUMO_ATTR_TO, e.getToNode()->getID());
391  if (!noNames && e.getStreetName() != "") {
393  }
395  if (e.getTypeID() != "") {
397  }
398  if (e.isMacroscopicConnector()) {
400  }
401  // write the spread type if not default ("right")
404  }
405  if (e.hasLoadedLength()) {
407  }
408  if (!e.hasDefaultGeometry()) {
410  }
411  if (e.getStopOffsets().size() != 0) {
412  writeStopOffsets(into, e.getStopOffsets());
413  }
414  if (e.isBidiRail()) {
416  }
417 
418  // write the lanes
419  const std::vector<NBEdge::Lane>& lanes = e.getLanes();
420 
421  const double length = e.getFinalLength();
422  for (int i = 0; i < (int) lanes.size(); i++) {
423  const NBEdge::Lane& l = lanes[i];
424  std::map<int, double> stopOffsets;
425  if (l.stopOffsets != e.getStopOffsets()) {
426  stopOffsets = l.stopOffsets;
427  }
428  writeLane(into, e.getLaneID(i), l.speed,
429  l.permissions, l.preferred, l.endOffset, stopOffsets, l.width, l.shape, &l,
430  length, i, l.oppositeID, l.accelRamp, l.customShape.size() > 0);
431  }
432  // close the edge
433  e.writeParams(into);
434  into.closeTag();
435 }
436 
437 
438 void
439 NWWriter_SUMO::writeLane(OutputDevice& into, const std::string& lID,
440  double speed, SVCPermissions permissions, SVCPermissions preferred,
441  double endOffset, std::map<SVCPermissions, double> stopOffsets, double width, PositionVector shape,
442  const Parameterised* params, double length, int index,
443  const std::string& oppositeID, bool accelRamp, bool customShape) {
444  // output the lane's attributes
446  // the first lane of an edge will be the depart lane
447  into.writeAttr(SUMO_ATTR_INDEX, index);
448  // write the list of allowed/disallowed vehicle classes
449  if (permissions != SVC_UNSPECIFIED) {
450  writePermissions(into, permissions);
451  }
452  writePreferences(into, preferred);
453  // some further information
454  if (speed == 0) {
455  WRITE_WARNING("Lane '" + lID + "' has a maximum allowed speed of 0.");
456  } else if (speed < 0) {
457  throw ProcessError("Negative allowed speed (" + toString(speed) + ") on lane '" + lID + "', use --speed.minimum to prevent this.");
458  }
459  if (endOffset > 0) {
460  length = length - endOffset;
461  }
462  into.writeAttr(SUMO_ATTR_SPEED, speed);
463  into.writeAttr(SUMO_ATTR_LENGTH, length);
464  if (endOffset != NBEdge::UNSPECIFIED_OFFSET) {
465  into.writeAttr(SUMO_ATTR_ENDOFFSET, endOffset);
466  }
467  if (width != NBEdge::UNSPECIFIED_WIDTH) {
468  into.writeAttr(SUMO_ATTR_WIDTH, width);
469  }
470  if (accelRamp) {
471  into.writeAttr<bool>(SUMO_ATTR_ACCELERATION, accelRamp);
472  }
473  if (customShape) {
474  into.writeAttr(SUMO_ATTR_CUSTOMSHAPE, true);
475  }
476  into.writeAttr(SUMO_ATTR_SHAPE, endOffset > 0 ?
477  shape.getSubpart(0, shape.length() - endOffset) : shape);
478 
479  if (stopOffsets.size() != 0) {
480  writeStopOffsets(into, stopOffsets);
481  }
482 
483  if (oppositeID != "" && oppositeID != "-") {
484  into.openTag(SUMO_TAG_NEIGH);
485  into.writeAttr(SUMO_ATTR_LANE, oppositeID);
486  into.closeTag();
487  }
488 
489  if (params != nullptr) {
490  params->writeParams(into);
491  }
492 
493  into.closeTag();
494 }
495 
496 
497 void
499  // write the attributes
501  into.writeAttr(SUMO_ATTR_TYPE, n.getType());
503  // write the incoming lanes
504  std::string incLanes;
505  const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
506  for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
507  int noLanes = (*i)->getNumLanes();
508  for (int j = 0; j < noLanes; j++) {
509  incLanes += (*i)->getLaneID(j);
510  if (i != incoming.end() - 1 || j < noLanes - 1) {
511  incLanes += ' ';
512  }
513  }
514  }
515  std::vector<NBNode::Crossing*> crossings = n.getCrossings();
516  std::set<std::string> prevWAs;
517  // avoid duplicates
518  for (auto c : crossings) {
519  if (prevWAs.count(c->prevWalkingArea) == 0) {
520  incLanes += ' ' + c->prevWalkingArea + "_0";
521  prevWAs.insert(c->prevWalkingArea);
522  }
523  }
524  into.writeAttr(SUMO_ATTR_INCLANES, incLanes);
525  // write the internal lanes
526  std::string intLanes;
527  if (!OptionsCont::getOptions().getBool("no-internal-links")) {
528  int l = 0;
529  for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
530  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
531  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
532  if ((*k).toEdge == nullptr) {
533  continue;
534  }
535  if (l != 0) {
536  intLanes += ' ';
537  }
538  if (!(*k).haveVia) {
539  intLanes += (*k).getInternalLaneID();
540  } else {
541  intLanes += (*k).viaID + "_0";
542  }
543  l++;
544  }
545  }
546  }
547  if (n.getType() != NODETYPE_DEAD_END && n.getType() != NODETYPE_NOJUNCTION) {
548  for (auto c : crossings) {
549  intLanes += ' ' + c->id + "_0";
550  }
551  }
552  into.writeAttr(SUMO_ATTR_INTLANES, intLanes);
553  // close writing
555  // write optional radius
558  }
559  // specify whether a custom shape was used
560  if (n.hasCustomShape()) {
561  into.writeAttr(SUMO_ATTR_CUSTOMSHAPE, true);
562  }
563  if (n.getRightOfWay() != RIGHT_OF_WAY_DEFAULT) {
564  into.writeAttr<std::string>(SUMO_ATTR_RIGHT_OF_WAY, toString(n.getRightOfWay()));
565  }
566  if (n.getType() != NODETYPE_DEAD_END) {
567  // write right-of-way logics
568  n.writeLogic(into);
569  }
570  n.writeParams(into);
571  into.closeTag();
572 }
573 
574 
575 bool
577  bool ret = false;
578  const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
579  // build the list of internal lane ids
580  std::vector<std::string> internalLaneIDs;
581  std::map<std::string, std::string> viaIDs;
582  for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
583  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
584  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
585  if ((*k).toEdge != nullptr) {
586  internalLaneIDs.push_back((*k).getInternalLaneID());
587  viaIDs[(*k).getInternalLaneID()] = ((*k).viaID);
588  }
589  }
590  }
591  for (auto c : n.getCrossings()) {
592  internalLaneIDs.push_back(c->id + "_0");
593  }
594  // write the internal nodes
595  for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
596  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
597  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
598  if ((*k).toEdge == nullptr || !(*k).haveVia) {
599  continue;
600  }
601  Position pos = (*k).shape[-1];
602  into.openTag(SUMO_TAG_JUNCTION).writeAttr(SUMO_ATTR_ID, (*k).viaID + "_0");
604  NWFrame::writePositionLong(pos, into);
605  std::string incLanes = (*k).getInternalLaneID();
606  std::vector<std::string> foeIDs;
607  for (std::string incLane : (*k).foeIncomingLanes) {
608  incLanes += " " + incLane;
609  if (incLane[0] == ':' && viaIDs[incLane] != "") {
610  // intersecting left turns
611  foeIDs.push_back(viaIDs[incLane] + "_0");
612  }
613  }
614  into.writeAttr(SUMO_ATTR_INCLANES, incLanes);
615  const std::vector<int>& foes = (*k).foeInternalLinks;
616  for (std::vector<int>::const_iterator it = foes.begin(); it != foes.end(); ++it) {
617  foeIDs.push_back(internalLaneIDs[*it]);
618  }
619  into.writeAttr(SUMO_ATTR_INTLANES, joinToString(foeIDs, " "));
620  into.closeTag();
621  ret = true;
622  }
623  }
624  return ret;
625 }
626 
627 
628 void
630  bool includeInternal, ConnectionStyle style) {
631  assert(c.toEdge != 0);
633  into.writeAttr(SUMO_ATTR_FROM, from.getID());
634  into.writeAttr(SUMO_ATTR_TO, c.toEdge->getID());
637  if (c.mayDefinitelyPass && style != TLL) {
639  }
640  if ((from.getToNode()->getKeepClear() == false || c.keepClear == false) && style != TLL) {
641  into.writeAttr<bool>(SUMO_ATTR_KEEP_CLEAR, false);
642  }
643  if (c.contPos != NBEdge::UNSPECIFIED_CONTPOS && style != TLL) {
645  }
648  }
649  if (c.speed != NBEdge::UNSPECIFIED_SPEED && style != TLL) {
651  }
652  if (c.customShape.size() != 0 && style != TLL) {
654  }
655  if (c.uncontrolled != false && style != TLL) {
657  }
658  if (style != PLAIN) {
659  if (includeInternal) {
661  }
662  // set information about the controlling tl if any
663  if (c.tlID != "") {
664  into.writeAttr(SUMO_ATTR_TLID, c.tlID);
666  }
667  if (style == SUMONET) {
668  // write the direction information
669  LinkDirection dir = from.getToNode()->getDirection(&from, c.toEdge, OptionsCont::getOptions().getBool("lefthand"));
670  assert(dir != LINKDIR_NODIR);
671  into.writeAttr(SUMO_ATTR_DIR, toString(dir));
672  // write the state information
673  const LinkState linkState = from.getToNode()->getLinkState(
674  &from, c.toEdge, c.fromLane, c.toLane, c.mayDefinitelyPass, c.tlID);
675  into.writeAttr(SUMO_ATTR_STATE, linkState);
676  }
677  }
678  into.closeTag();
679 }
680 
681 
682 bool
684  bool ret = false;
685  const bool lefthand = OptionsCont::getOptions().getBool("lefthand");
686  const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
687  for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
688  NBEdge* from = *i;
689  const std::vector<NBEdge::Connection>& connections = from->getConnections();
690  for (std::vector<NBEdge::Connection>::const_iterator j = connections.begin(); j != connections.end(); ++j) {
691  const NBEdge::Connection& c = *j;
692  LinkDirection dir = n.getDirection(from, c.toEdge, lefthand);
693  assert(c.toEdge != 0);
694  if (c.haveVia) {
695  // internal split
696  writeInternalConnection(into, c.id, c.toEdge->getID(), c.internalLaneIndex, c.toLane, c.viaID + "_0", dir);
697  writeInternalConnection(into, c.viaID, c.toEdge->getID(), 0, c.toLane, "", dir);
698  } else {
699  // no internal split
700  writeInternalConnection(into, c.id, c.toEdge->getID(), c.internalLaneIndex, c.toLane, "", dir);
701  }
702  ret = true;
703  }
704  }
705  return ret;
706 }
707 
708 
709 void
711  const std::string& from, const std::string& to,
712  int fromLane, int toLane, const std::string& via,
713  LinkDirection dir, const std::string& tlID, int linkIndex) {
715  into.writeAttr(SUMO_ATTR_FROM, from);
716  into.writeAttr(SUMO_ATTR_TO, to);
717  into.writeAttr(SUMO_ATTR_FROM_LANE, fromLane);
718  into.writeAttr(SUMO_ATTR_TO_LANE, toLane);
719  if (via != "") {
720  into.writeAttr(SUMO_ATTR_VIA, via);
721  }
722  if (tlID != "" && linkIndex != NBConnection::InvalidTlIndex) {
723  // used for the reverse direction of pedestrian crossings
724  into.writeAttr(SUMO_ATTR_TLID, tlID);
725  into.writeAttr(SUMO_ATTR_TLLINKINDEX, linkIndex);
726  }
727  into.writeAttr(SUMO_ATTR_DIR, dir);
728  into.writeAttr(SUMO_ATTR_STATE, (via != "" ? "m" : "M"));
729  into.closeTag();
730 }
731 
732 
733 void
734 NWWriter_SUMO::writeRoundabouts(OutputDevice& into, const std::set<EdgeSet>& roundabouts,
735  const NBEdgeCont& ec) {
736  // make output deterministic
737  std::vector<std::vector<std::string> > edgeIDs;
738  for (std::set<EdgeSet>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
739  std::vector<std::string> tEdgeIDs;
740  for (EdgeSet::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
741  // the edges may have been erased from NBEdgeCont but their pointers are still valid
742  // we verify their existance in writeRoundabout()
743  tEdgeIDs.push_back((*j)->getID());
744  }
745  std::sort(tEdgeIDs.begin(), tEdgeIDs.end());
746  edgeIDs.push_back(tEdgeIDs);
747  }
748  std::sort(edgeIDs.begin(), edgeIDs.end());
749  // write
750  for (std::vector<std::vector<std::string> >::const_iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
751  writeRoundabout(into, *i, ec);
752  }
753  if (roundabouts.size() != 0) {
754  into.lf();
755  }
756 }
757 
758 
759 void
760 NWWriter_SUMO::writeRoundabout(OutputDevice& into, const std::vector<std::string>& edgeIDs,
761  const NBEdgeCont& ec) {
762  std::vector<std::string> validEdgeIDs;
763  std::vector<std::string> invalidEdgeIDs;
764  std::vector<std::string> nodeIDs;
765  for (std::vector<std::string>::const_iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
766  const NBEdge* edge = ec.retrieve(*i);
767  if (edge != nullptr) {
768  nodeIDs.push_back(edge->getToNode()->getID());
769  validEdgeIDs.push_back(edge->getID());
770  } else {
771  invalidEdgeIDs.push_back(*i);
772  }
773  }
774  std::sort(nodeIDs.begin(), nodeIDs.end());
775  if (validEdgeIDs.size() > 0) {
777  into.writeAttr(SUMO_ATTR_NODES, joinToString(nodeIDs, " "));
778  into.writeAttr(SUMO_ATTR_EDGES, joinToString(validEdgeIDs, " "));
779  into.closeTag();
780  if (invalidEdgeIDs.size() > 0) {
781  WRITE_WARNING("Writing incomplete roundabout. Edges: '"
782  + joinToString(invalidEdgeIDs, " ") + "' no longer exist'");
783  }
784  }
785 }
786 
787 
788 void
790  std::vector<double> sourceW = d.getSourceWeights();
792  std::vector<double> sinkW = d.getSinkWeights();
794  // write the head and the id of the district
796  if (d.getShape().size() > 0) {
798  }
799  // write all sources
800  const std::vector<NBEdge*>& sources = d.getSourceEdges();
801  for (int i = 0; i < (int)sources.size(); i++) {
802  // write the head and the id of the source
803  into.openTag(SUMO_TAG_TAZSOURCE).writeAttr(SUMO_ATTR_ID, sources[i]->getID()).writeAttr(SUMO_ATTR_WEIGHT, sourceW[i]);
804  into.closeTag();
805  }
806  // write all sinks
807  const std::vector<NBEdge*>& sinks = d.getSinkEdges();
808  for (int i = 0; i < (int)sinks.size(); i++) {
809  // write the head and the id of the sink
810  into.openTag(SUMO_TAG_TAZSINK).writeAttr(SUMO_ATTR_ID, sinks[i]->getID()).writeAttr(SUMO_ATTR_WEIGHT, sinkW[i]);
811  into.closeTag();
812  }
813  // write the tail
814  into.closeTag();
815 }
816 
817 
818 std::string
820  double time = STEPS2TIME(steps);
821  if (time == std::floor(time)) {
822  return toString(int(time));
823  } else {
824  return toString(time);
825  }
826 }
827 
828 
829 void
831  for (NBConnectionProhibits::const_iterator j = prohibitions.begin(); j != prohibitions.end(); j++) {
832  NBConnection prohibited = (*j).first;
833  const NBConnectionVector& prohibiting = (*j).second;
834  for (NBConnectionVector::const_iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
835  NBConnection prohibitor = *k;
839  into.closeTag();
840  }
841  }
842 }
843 
844 
845 std::string
847  return c.getFrom()->getID() + "->" + c.getTo()->getID();
848 }
849 
850 
851 void
853  std::vector<NBTrafficLightLogic*> logics = tllCont.getComputed();
854  for (std::vector<NBTrafficLightLogic*>::iterator it = logics.begin(); it != logics.end(); it++) {
856  into.writeAttr(SUMO_ATTR_ID, (*it)->getID());
857  into.writeAttr(SUMO_ATTR_TYPE, (*it)->getType());
858  into.writeAttr(SUMO_ATTR_PROGRAMID, (*it)->getProgramID());
859  into.writeAttr(SUMO_ATTR_OFFSET, writeSUMOTime((*it)->getOffset()));
860  // write the phases
861  const bool varPhaseLength = (*it)->getType() != TLTYPE_STATIC;
862  const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases = (*it)->getPhases();
863  for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator j = phases.begin(); j != phases.end(); ++j) {
864  into.openTag(SUMO_TAG_PHASE);
865  into.writeAttr(SUMO_ATTR_DURATION, writeSUMOTime(j->duration));
866  if (j->duration < TIME2STEPS(10)) {
867  into.writePadding(" ");
868  }
869  into.writeAttr(SUMO_ATTR_STATE, j->state);
870  if (varPhaseLength) {
873  }
876  }
877  }
878  into.closeTag();
879  }
880  // write params
881  (*it)->writeParams(into);
882  into.closeTag();
883  }
884  if (logics.size() > 0) {
885  into.lf();
886  }
887 }
888 
889 
890 void
891 NWWriter_SUMO::writeStopOffsets(OutputDevice& into, const std::map<SVCPermissions, double>& stopOffsets) {
892  if (stopOffsets.size() == 0) {
893  return;
894  }
895  assert(stopOffsets.size() == 1);
896  std::pair<int, double> offset = *stopOffsets.begin();
897  std::string ss_vclasses = getVehicleClassNames(offset.first);
898  if (ss_vclasses.length() == 0) {
899  // This stopOffset would have no effect...
900  return;
901  }
903  std::string ss_exceptions = getVehicleClassNames(~offset.first);
904  if (ss_vclasses.length() <= ss_exceptions.length()) {
905  into.writeAttr(SUMO_ATTR_VCLASSES, ss_vclasses);
906  } else {
907  if (ss_exceptions.length() == 0) {
908  into.writeAttr(SUMO_ATTR_VCLASSES, "all");
909  } else {
910  into.writeAttr(SUMO_ATTR_EXCEPTIONS, ss_exceptions);
911  }
912  }
913  into.writeAttr(SUMO_ATTR_VALUE, offset.second);
914  into.closeTag();
915 }
916 
917 /****************************************************************************/
918 
static void writeRoundabout(OutputDevice &into, const std::vector< std::string > &r, const NBEdgeCont &ec)
Writes a roundabout.
bool getKeepClear() const
Returns the keepClear flag.
Definition: NBNode.h:277
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge&#39;s lanes&#39; lateral offset is computed.
Definition: NBEdge.h:704
std::string id
id of Connection
Definition: NBEdge.h:215
The information about how to spread the lanes from the given position.
std::string getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a &#39; &#39;.
void writePermissions(OutputDevice &into, SVCPermissions permissions)
writes allowed disallowed attributes if needed;
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
void close()
Closes the device and removes it from the dictionary.
static void writeLocation(OutputDevice &into)
writes the location element
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:160
const std::vector< NBEdge * > & getSourceEdges() const
Returns the sources.
Definition: NBDistrict.h:191
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
get link state
Definition: NBNode.cpp:1855
int toLane
The lane the connections yields in.
Definition: NBEdge.h:188
long long int SUMOTime
Definition: SUMOTime.h:36
a list of node ids, used for controlling joining
NBTypeCont & getTypeCont()
Returns a reference to the type container.
Definition: NBNetBuilder.h:160
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
Whether vehicles must keep the junction clear.
PositionVector shape
The lane&#39;s shape.
Definition: NBEdge.h:121
whether a given shape is user-defined
a source within a district (connection road)
is a pedestrian
const std::map< int, double > & getStopOffsets() const
Returns the stopOffset to the end of the edge.
Definition: NBEdge.h:562
static void writeDistrict(OutputDevice &into, const NBDistrict &d)
Writes a district.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
Definition: NBNodeCont.h:116
std::string viaID
if Connection have a via, ID of it
Definition: NBEdge.h:227
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:185
begin/end of the description of a junction
begin/end of the description of a single lane
static const double UNSPECIFIED_VISIBILITY_DISTANCE
unspecified foe visibility for connections
Definition: NBEdge.h:270
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
Definition: NBNodeCont.h:121
A container for traffic light definitions and built programs.
a traffic assignment zone
void writePreferences(OutputDevice &into, SVCPermissions preferred)
writes allowed disallowed attributes if needed;
connectio between two lanes
std::vector< Crossing * > getCrossings() const
return this junctions pedestrian crossings
Definition: NBNode.cpp:2291
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:427
double length
This lane&#39;s width.
Definition: NBNode.h:178
const std::string & getTypeID() const
get ID of type
Definition: NBEdge.h:1004
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
bool hasCustomShape() const
return whether the shape was set by the user
Definition: NBNode.h:511
std::map< std::string, NBDistrict * >::const_iterator end() const
Returns the pointer to the end of the stored districts.
The representation of a single edge during network building.
Definition: NBEdge.h:65
foe visibility distance of a link
static void writeProhibitions(OutputDevice &into, const NBConnectionProhibits &prohibitions)
writes the given prohibitions
static const double UNSPECIFIED_RADIUS
unspecified lane width
Definition: NBNode.h:205
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
link,node: the traffic light id responsible for this link
bool hasCustomShape
whether this walkingArea has a custom shape
Definition: NBNode.h:188
T MAX2(T a, T b)
Definition: StdDefs.h:76
double length
computed length (average of all internal lane shape lengths that share an internal edge) ...
Definition: NBEdge.h:251
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Definition: NBEdge.h:507
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:3013
static const SUMOTime UNSPECIFIED_DURATION
Crossing * getCrossing(const std::string &id) const
return the crossing with the given id
Definition: NBNode.cpp:2948
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:589
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
Definition: NBEdge.h:197
double endOffset
This lane&#39;s offset to the intersection begin.
Definition: NBEdge.h:133
NBEdge * getFrom() const
returns the from-edge (start of the connection)
double visibility
custom foe visiblity for connection
Definition: NBEdge.h:206
std::string id
the (edge)-id of this walkingArea
Definition: NBNode.h:174
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
Definition: NBEdgeCont.h:193
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
maximum duration of a phase
const std::string & getID() const
Returns the id.
Definition: Named.h:78
#define TIME2STEPS(x)
Definition: SUMOTime.h:60
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.
static void writeTrafficLights(OutputDevice &into, const NBTrafficLightLogicCont &tllCont)
writes the traffic light logics to the given device
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
prohibition of circulation between two edges
PositionVector customShape
custom shape for connection
Definition: NBEdge.h:212
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:241
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
static void writeStopOffsets(OutputDevice &into, const std::map< SVCPermissions, double > &stopOffsets)
Write a stopOffset element into output device.
bool accelRamp
Whether this lane is an acceleration lane.
Definition: NBEdge.h:146
bool priority
whether the pedestrians have priority
Definition: NBNode.h:145
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
The link is a straight direction.
static const double UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:264
The state of a link.
A class representing a single district.
Definition: NBDistrict.h:65
bool keepClear
whether the junction must be kept clear when using this connection
Definition: NBEdge.h:200
static std::string prohibitionConnection(const NBConnection &c)
the attribute value for a prohibition
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.
SVCPermissions permissions
List of vehicle types that are allowed on this lane.
Definition: NBEdge.h:127
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into a SUMO-file.
How to compute right of way.
static const int InvalidTlIndex
Definition: NBConnection.h:120
The turning radius at an intersection in m.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
Definition: NBEdgeCont.h:185
double speed
custom speed for connection
Definition: NBEdge.h:209
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
std::string tlID
The id of the traffic light that controls this connection.
Definition: NBEdge.h:191
SVCPermissions preferred
List of vehicle types that are preferred on this lane.
Definition: NBEdge.h:130
This is an uncontrolled, minor link, has to brake.
const PositionVector & getShape() const
Returns the shape.
Definition: NBDistrict.h:215
std::string getLaneID(int lane) const
get Lane ID (Secure)
Definition: NBEdge.cpp:3022
bool writeLogic(OutputDevice &into) const
writes the XML-representation of the logic as a bitset-logic XML representation
Definition: NBNode.cpp:917
static bool writeInternalConnections(OutputDevice &into, const NBNode &n)
Writes inner connections within the node.
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:182
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:150
A list of positions.
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)
static void writeInternalConnection(OutputDevice &into, const std::string &from, const std::string &to, int fromLane, int toLane, const std::string &via, LinkDirection dir=LINKDIR_STRAIGHT, const std::string &tlID="", int linkIndex=NBConnection::InvalidTlIndex)
Writes a single internal connection.
bool isConstantWidthTransition() const
detects whether a given junction splits or merges lanes while keeping constant road width ...
Definition: NBNode.cpp:734
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
Definition: NBEdge.cpp:535
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
roundabout defined in junction
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:61
#define POSITION_EPS
Definition: config.h:172
const std::string & getStreetName() const
Returns the street name of this edge.
Definition: NBEdge.h:543
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
static void writePositionLong(const Position &pos, OutputDevice &dev)
Writes the given position to device in long format (one attribute per dimension)
Definition: NWFrame.cpp:188
edge: the shape in xml-definition
PositionVector getSubpart(double beginOffset, double endOffset) const
get subpart of a position vector
begin/end of the description of a neighboring lane
An upper class for objects with additional parameters.
Definition: Parameterised.h:44
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
static std::string getOppositeInternalID(const NBEdgeCont &ec, const NBEdge *from, const NBEdge::Connection &con, double &oppositeLength)
retrieve the id of the opposite direction internal lane if it exists
double speed
The speed allowed on this lane.
Definition: NBEdge.h:124
double width
This lane&#39;s width.
Definition: NBEdge.h:140
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
double getFinalLength() const
get length that will be assigned to the lanes in the final network
Definition: NBEdge.cpp:3575
int tlLinkIndex
The index of this connection within the controlling traffic light.
Definition: NBEdge.h:194
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
begin/end of the description of an edge
static void normaliseSum(std::vector< T > &v, T msum=1.0)
Definition: VectorHelper.h:51
int size() const
Returns the number of districts inside the container.
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream&#39;s direction.
Definition: NBNode.cpp:1764
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1979
PositionVector simplified() const
return the same shape with intermediate colinear points removed
NBEdge * getTo() const
returns the to-edge (end of the connection)
int internalLaneIndex
The lane index of this internal lane within the internal edge.
Definition: NBEdge.h:239
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:622
RightOfWay getRightOfWay() const
Returns hint on how to compute right of way.
Definition: NBNode.h:282
const std::vector< double > & getSinkWeights() const
Returns the weights of the sinks.
Definition: NBDistrict.h:199
double length() const
Returns the length.
std::map< NBConnection, NBConnectionVector > NBConnectionProhibits
Definition of a container for connection block dependencies Includes a list of all connections which ...
std::vector< NBTrafficLightLogic * > getComputed() const
Returns a list of all computed logics.
double getRadius() const
Returns the turning radius of this node.
Definition: NBNode.h:272
std::string oppositeID
An opposite lane ID, if given.
Definition: NBEdge.h:143
a sink within a district (connection road)
the edges crossed by a pedestrian crossing
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
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:155
std::map< int, double > stopOffsets
stopOffsets.second - The stop offset for vehicles stopping at the lane&#39;s end. Applies if vClass is in...
Definition: NBEdge.h:137
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
static void interpretLaneID(const std::string &lane_id, std::string &edge_id, int &index)
parses edge-id and index from lane-id
Definition: NBHelpers.cpp:121
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
static bool writeInternalNodes(OutputDevice &into, const NBNode &n)
Writes internal junctions (<junction with id[0]==&#39;:&#39; ...) of the given node.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:245
const std::vector< NBEdge * > & getSinkEdges() const
Returns the sinks.
Definition: NBDistrict.h:207
A definition of a pedestrian walking area.
Definition: NBNode.h:164
double contPos
custom position for internal junction on this connection
Definition: NBEdge.h:203
A storage for options typed value containers)
Definition: OptionsCont.h:92
bool uncontrolled
check if Connection is uncontrolled
Definition: NBEdge.h:242
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:267
This is an uncontrolled, major link, may pass.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
Definition: NBNetBuilder.h:165
static void writeLane(OutputDevice &into, const std::string &lID, double speed, SVCPermissions permissions, SVCPermissions preferred, double endOffset, std::map< SVCPermissions, double > stopOffsets, double width, PositionVector shape, const Parameterised *params, double length, int index, const std::string &oppositeID, bool accelRamp=false, bool customShape=false)
Writes a lane (<lane ...) of an edge.
The abstract direction of a link.
int tlLinkIndex
the traffic light index of this crossing (if controlled)
Definition: NBNode.h:149
const Position & getPosition() const
Definition: NBNode.h:242
Represents a single node (junction) during network building.
Definition: NBNode.h:68
A definition of a pedestrian crossing.
Definition: NBNode.h:125
const std::vector< WalkingArea > & getWalkingAreas() const
return this junctions pedestrian walking areas
Definition: NBNode.h:658
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
link: the index of the link within the traffic light
std::string tlID
The id of the traffic light that controls this connection.
Definition: NBNode.h:155
bool isMacroscopicConnector() const
Returns whether this edge was marked as a macroscopic connector.
Definition: NBEdge.h:962
const std::vector< double > & getSourceWeights() const
Returns the weights of the sources.
Definition: NBDistrict.h:183
a traffic light logic
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:434
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
std::string getInternalLaneID() const
get ID of internal lane
Definition: NBEdge.cpp:80
static bool writeInternalEdges(OutputDevice &into, const NBEdgeCont &ec, const NBNode &n)
Writes internal edges (<edge ... with id[0]==&#39;:&#39;) of the given node.
static void writeEdge(OutputDevice &into, const NBEdge &e, bool noNames)
Writes an edge (<edge ...)
bool haveVia
check if Connection have a Via
Definition: NBEdge.h:224
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:497
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
Definition: NBNetBuilder.h:170
PositionVector customShape
A custom shape for this lane set by the user.
Definition: NBEdge.h:153
OutputDevice & writePadding(const std::string &val)
writes padding (ignored for binary output)
Definition: OutputDevice.h:308
static const std::string MAJOR_VERSION
The version number for written files.
Definition: NWFrame.h:62
static void writeRoundabouts(OutputDevice &into, const std::set< EdgeSet > &roundabouts, const NBEdgeCont &ec)
Writes roundabouts.
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:441
a single phase description
static std::string writeSUMOTime(SUMOTime time)
writes a SUMOTime as int if possible, otherwise as a float
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:237
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void lf()
writes a line feed if applicable
Definition: OutputDevice.h:234
static void writeJunction(OutputDevice &into, const NBNode &n)
Writes a junction (<junction ...)
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
static void writeConnection(OutputDevice &into, const NBEdge &from, const NBEdge::Connection &c, bool includeInternal, ConnectionStyle style=SUMONET)
Writes connections outgoing from the given edge (also used in NWWriter_XML)
PositionVector shape
The polygonal shape.
Definition: NBNode.h:180
void writeTypes(OutputDevice &into) const
writes all types a s XML
Definition: NBTypeCont.cpp:120
The link has no direction (is a dead end link)
double width
This lane&#39;s width.
Definition: NBNode.h:176
Information on vClass specific stop offsets at lane end.