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 
49 // ===========================================================================
50 // method definitions
51 // ===========================================================================
52 // ---------------------------------------------------------------------------
53 // static methods
54 // ---------------------------------------------------------------------------
55 void
57  // check whether a sumo net-file shall be generated
58  if (!oc.isSet("output-file")) {
59  return;
60  }
61  OutputDevice& device = OutputDevice::getDevice(oc.getString("output-file"));
62  std::map<SumoXMLAttr, std::string> attrs;
64  if (oc.getBool("lefthand")) {
65  attrs[SUMO_ATTR_LEFTHAND] = "true";
66  }
67  const int cornerDetail = oc.getInt("junctions.corner-detail");
68  if (cornerDetail > 0) {
69  attrs[SUMO_ATTR_CORNERDETAIL] = toString(cornerDetail);
70  }
71  if (!oc.isDefault("junctions.internal-link-detail")) {
72  attrs[SUMO_ATTR_LINKDETAIL] = toString(oc.getInt("junctions.internal-link-detail"));
73  }
74  if (oc.getBool("rectangular-lane-cut")) {
75  attrs[SUMO_ATTR_RECTANGULAR_LANE_CUT] = "true";
76  }
77  if (oc.getBool("crossings.guess") || oc.getBool("walkingareas")) {
78  attrs[SUMO_ATTR_WALKINGAREAS] = "true";
79  }
80  if (oc.getFloat("junctions.limit-turn-speed") > 0) {
81  attrs[SUMO_ATTR_LIMIT_TURN_SPEED] = toString(oc.getFloat("junctions.limit-turn-speed"));
82  }
83  device.writeXMLHeader("net", "net_file.xsd", attrs); // street names may contain non-ascii chars
84  device.lf();
85  // get involved container
86  const NBNodeCont& nc = nb.getNodeCont();
87  const NBEdgeCont& ec = nb.getEdgeCont();
88  const NBDistrictCont& dc = nb.getDistrictCont();
89 
90  // write network offsets and projection
92 
93  // write edge types and restrictions
94  nb.getTypeCont().writeTypes(device);
95 
96  // write inner lanes
97  if (!oc.getBool("no-internal-links")) {
98  bool hadAny = false;
99  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
100  hadAny |= writeInternalEdges(device, ec, *(*i).second);
101  }
102  if (hadAny) {
103  device.lf();
104  }
105  }
106 
107  // write edges with lanes and connected edges
108  bool noNames = !oc.getBool("output.street-names");
109  for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
110  writeEdge(device, *(*i).second, noNames);
111  }
112  device.lf();
113 
114  // write tls logics
115  writeTrafficLights(device, nb.getTLLogicCont());
116 
117  // write the nodes (junctions)
118  std::set<NBNode*> roundaboutNodes;
119  const bool checkLaneFoesAll = oc.getBool("check-lane-foes.all");
120  const bool checkLaneFoesRoundabout = !checkLaneFoesAll && oc.getBool("check-lane-foes.roundabout");
121  if (checkLaneFoesRoundabout) {
122  const std::set<EdgeSet>& roundabouts = ec.getRoundabouts();
123  for (std::set<EdgeSet>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
124  for (EdgeSet::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
125  roundaboutNodes.insert((*j)->getToNode());
126  }
127  }
128  }
129  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
130  const bool checkLaneFoes = checkLaneFoesAll || (checkLaneFoesRoundabout && roundaboutNodes.count((*i).second) > 0);
131  writeJunction(device, *(*i).second, checkLaneFoes);
132  }
133  device.lf();
134  const bool includeInternal = !oc.getBool("no-internal-links");
135  if (includeInternal) {
136  // ... internal nodes if not unwanted
137  bool hadAny = false;
138  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
139  hadAny |= writeInternalNodes(device, *(*i).second);
140  }
141  if (hadAny) {
142  device.lf();
143  }
144  }
145 
146  // write the successors of lanes
147  int numConnections = 0;
148  for (std::map<std::string, NBEdge*>::const_iterator it_edge = ec.begin(); it_edge != ec.end(); it_edge++) {
149  NBEdge* from = it_edge->second;
150  const std::vector<NBEdge::Connection> connections = from->getConnections();
151  numConnections += (int)connections.size();
152  for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
153  writeConnection(device, *from, *it_c, includeInternal);
154  }
155  }
156  if (numConnections > 0) {
157  device.lf();
158  }
159  if (includeInternal) {
160  // ... internal successors if not unwanted
161  bool hadAny = false;
162  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
163  hadAny |= writeInternalConnections(device, *(*i).second);
164  }
165  if (hadAny) {
166  device.lf();
167  }
168  }
169  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
170  NBNode* node = (*i).second;
171  // write connections from pedestrian crossings
172  std::vector<NBNode::Crossing*> crossings = node->getCrossings();
173  for (auto c : crossings) {
174  NWWriter_SUMO::writeInternalConnection(device, c->id, c->nextWalkingArea, 0, 0, "", LINKDIR_STRAIGHT, c->tlID, c->tlLinkIndex2);
175  }
176  // write connections from pedestrian walking areas
177  for (const NBNode::WalkingArea& wa : node->getWalkingAreas()) {
178  for (const std::string& cID : wa.nextCrossings) {
179  const NBNode::Crossing& nextCrossing = *node->getCrossing(cID);
180  // connection to next crossing (may be tls-controlled)
182  device.writeAttr(SUMO_ATTR_FROM, wa.id);
183  device.writeAttr(SUMO_ATTR_TO, cID);
184  device.writeAttr(SUMO_ATTR_FROM_LANE, 0);
185  device.writeAttr(SUMO_ATTR_TO_LANE, 0);
186  if (nextCrossing.tlID != "") {
187  device.writeAttr(SUMO_ATTR_TLID, nextCrossing.tlID);
188  assert(nextCrossing.tlLinkIndex >= 0);
189  device.writeAttr(SUMO_ATTR_TLLINKINDEX, nextCrossing.tlLinkIndex);
190  }
193  device.closeTag();
194  }
195  // optional connections from/to sidewalk
196  std::string edgeID;
197  int laneIndex;
198  for (const std::string& sw : wa.nextSidewalks) {
199  NBHelpers::interpretLaneID(sw, edgeID, laneIndex);
200  NWWriter_SUMO::writeInternalConnection(device, wa.id, edgeID, 0, laneIndex, "");
201  }
202  for (const std::string& sw : wa.prevSidewalks) {
203  NBHelpers::interpretLaneID(sw, edgeID, laneIndex);
204  NWWriter_SUMO::writeInternalConnection(device, edgeID, wa.id, laneIndex, 0, "");
205  }
206  }
207  }
208 
209  // write loaded prohibitions
210  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
211  writeProhibitions(device, i->second->getProhibitions());
212  }
213 
214  // write roundabout information
215  writeRoundabouts(device, ec.getRoundabouts(), ec);
216 
217  // write the districts
218  for (std::map<std::string, NBDistrict*>::const_iterator i = dc.begin(); i != dc.end(); i++) {
219  writeDistrict(device, *(*i).second);
220  }
221  if (dc.size() != 0) {
222  device.lf();
223  }
224  device.close();
225 }
226 
227 
228 std::string
230  const NBEdge::Lane& succ = con.toEdge->getLanes()[con.toLane];
231  const NBEdge::Lane& pred = from->getLanes()[con.fromLane];
232  if (succ.oppositeID != "" && succ.oppositeID != "-" && pred.oppositeID != "" && pred.oppositeID != "-") {
233  // find the connection that connects succ.oppositeID to pred.oppositeID
234  const NBEdge* succOpp = ec.retrieve(succ.oppositeID.substr(0, succ.oppositeID.rfind("_")));
235  const NBEdge* predOpp = ec.retrieve(pred.oppositeID.substr(0, pred.oppositeID.rfind("_")));
236  assert(succOpp != 0);
237  assert(predOpp != 0);
238  const std::vector<NBEdge::Connection>& connections = succOpp->getConnections();
239  for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
240  const NBEdge::Connection& conOpp = *it_c;
241  if (succOpp != from && // turnaround
242  succOpp->getLaneID(conOpp.fromLane) == succ.oppositeID &&
243  predOpp == conOpp.toEdge &&
244  predOpp->getLaneID(conOpp.toLane) == pred.oppositeID &&
245  // same lengths (@note: averaging is not taken into account)
246  con.shape.length() == conOpp.shape.length()) {
247  return conOpp.getInternalLaneID();
248  }
249  }
250  return "";
251  } else {
252  return "";
253  }
254 }
255 
256 
257 bool
259  bool ret = false;
260  const EdgeVector& incoming = n.getIncomingEdges();
261  for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
262  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
263  if (elv.size() > 0) {
264  bool haveVia = false;
265  std::string edgeID = "";
266  // first pass: compute average lengths of non-via edges
267  std::map<std::string, double> lengthSum;
268  std::map<std::string, int> numLanes;
269  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
270  lengthSum[(*k).id] += MAX2((*k).shape.length(), POSITION_EPS);
271  numLanes[(*k).id] += 1;
272  }
273  // second pass: write non-via edges
274  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
275  if ((*k).toEdge == 0) {
276  assert(false); // should never happen. tell me when it does
277  continue;
278  }
279  if (edgeID != (*k).id) {
280  if (edgeID != "") {
281  // close the previous edge
282  into.closeTag();
283  }
284  edgeID = (*k).id;
285  into.openTag(SUMO_TAG_EDGE);
286  into.writeAttr(SUMO_ATTR_ID, edgeID);
288  // open a new edge
289  }
290  // to avoid changing to an internal lane which has a successor
291  // with the wrong permissions we need to inherit them from the successor
292  const NBEdge::Lane& successor = (*k).toEdge->getLanes()[(*k).toLane];
293  const double length = lengthSum[edgeID] / numLanes[edgeID];
294  // @note the actual length should be used once sumo supports lanes of
295  // varying length within the same edge
296  //const double length = MAX2((*k).shape.length(), POSITION_EPS);
297  const double width = n.isConstantWidthTransition() && (*i)->getNumLanes() > (*k).toEdge->getNumLanes() ? (*i)->getLaneWidth((*k).fromLane) : successor.width;
298  writeLane(into, (*k).getInternalLaneID(), (*k).vmax,
299  successor.permissions, successor.preferred,
300  NBEdge::UNSPECIFIED_OFFSET, std::map<int, double>(), width, (*k).shape, &(*k),
301  length, (*k).internalLaneIndex, getOppositeInternalID(ec, *i, *k));
302  haveVia = haveVia || (*k).haveVia;
303  }
304  ret = true;
305  into.closeTag(); // close the last edge
306  // third pass: write via edges
307  if (haveVia) {
308  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
309  if (!(*k).haveVia) {
310  continue;
311  }
312  if ((*k).toEdge == 0) {
313  assert(false); // should never happen. tell me when it does
314  continue;
315  }
316  const NBEdge::Lane& successor = (*k).toEdge->getLanes()[(*k).toLane];
317  into.openTag(SUMO_TAG_EDGE);
318  into.writeAttr(SUMO_ATTR_ID, (*k).viaID);
320  writeLane(into, (*k).viaID + "_0", (*k).vmax, SVCAll, SVCAll,
321  NBEdge::UNSPECIFIED_OFFSET, std::map<int, double>(), successor.width, (*k).viaShape, &(*k),
322  MAX2((*k).viaShape.length(), POSITION_EPS), // microsim needs positive length
323  0, "");
324  into.closeTag();
325  }
326  }
327  }
328  }
329  // write pedestrian crossings
330  for (auto c : n.getCrossings()) {
331  into.openTag(SUMO_TAG_EDGE);
332  into.writeAttr(SUMO_ATTR_ID, c->id);
334  into.writeAttr(SUMO_ATTR_CROSSING_EDGES, c->edges);
335  writeLane(into, c->id + "_0", 1, SVC_PEDESTRIAN, 0,
336  NBEdge::UNSPECIFIED_OFFSET, std::map<int, double>(), c->width, c->shape, 0, MAX2(c->shape.length(), POSITION_EPS), 0, "", false, c->customShape.size() != 0);
337  into.closeTag();
338  }
339  // write pedestrian walking areas
340  const std::vector<NBNode::WalkingArea>& WalkingAreas = n.getWalkingAreas();
341  for (std::vector<NBNode::WalkingArea>::const_iterator it = WalkingAreas.begin(); it != WalkingAreas.end(); it++) {
342  const NBNode::WalkingArea& wa = *it;
343  into.openTag(SUMO_TAG_EDGE);
344  into.writeAttr(SUMO_ATTR_ID, wa.id);
346  writeLane(into, wa.id + "_0", 1, SVC_PEDESTRIAN, 0,
347  NBEdge::UNSPECIFIED_OFFSET, std::map<int, double>(), wa.width, wa.shape, 0, wa.length, 0, "", false, wa.hasCustomShape);
348  into.closeTag();
349  }
350  return ret;
351 }
352 
353 
354 void
355 NWWriter_SUMO::writeEdge(OutputDevice& into, const NBEdge& e, bool noNames) {
356  // write the edge's begin
359  into.writeAttr(SUMO_ATTR_TO, e.getToNode()->getID());
360  if (!noNames && e.getStreetName() != "") {
362  }
364  if (e.getTypeID() != "") {
366  }
367  if (e.isMacroscopicConnector()) {
369  }
370  // write the spread type if not default ("right")
373  }
374  if (e.hasLoadedLength()) {
376  }
377  if (!e.hasDefaultGeometry()) {
379  }
380  if (e.getStopOffsets().size() != 0) {
381  writeStopOffsets(into, e.getStopOffsets());
382  }
383 
384  // write the lanes
385  const std::vector<NBEdge::Lane>& lanes = e.getLanes();
386 
387  const double length = e.getFinalLength();
388  for (int i = 0; i < (int) lanes.size(); i++) {
389  const NBEdge::Lane& l = lanes[i];
390  std::map<int, double> stopOffsets;
391  if (l.stopOffsets != e.getStopOffsets()) {
392  stopOffsets = l.stopOffsets;
393  }
394  writeLane(into, e.getLaneID(i), l.speed,
395  l.permissions, l.preferred, l.endOffset, stopOffsets, l.width, l.shape, &l,
396  length, i, l.oppositeID, l.accelRamp, l.customShape.size() > 0);
397  }
398  // close the edge
399  e.writeParams(into);
400  into.closeTag();
401 }
402 
403 
404 void
405 NWWriter_SUMO::writeLane(OutputDevice& into, const std::string& lID,
406  double speed, SVCPermissions permissions, SVCPermissions preferred,
407  double endOffset, std::map<SVCPermissions, double> stopOffsets, double width, PositionVector shape,
408  const Parameterised* params, double length, int index,
409  const std::string& oppositeID, bool accelRamp, bool customShape) {
410  // output the lane's attributes
412  // the first lane of an edge will be the depart lane
413  into.writeAttr(SUMO_ATTR_INDEX, index);
414  // write the list of allowed/disallowed vehicle classes
415  if (permissions != SVC_UNSPECIFIED) {
416  writePermissions(into, permissions);
417  }
418  writePreferences(into, preferred);
419  // some further information
420  if (speed == 0) {
421  WRITE_WARNING("Lane '" + lID + "' has a maximum allowed speed of 0.");
422  } else if (speed < 0) {
423  throw ProcessError("Negative allowed speed (" + toString(speed) + ") on lane '" + lID + "', use --speed.minimum to prevent this.");
424  }
425  if (endOffset > 0) {
426  length = length - endOffset;
427  }
428  into.writeAttr(SUMO_ATTR_SPEED, speed);
429  into.writeAttr(SUMO_ATTR_LENGTH, length);
430  if (endOffset != NBEdge::UNSPECIFIED_OFFSET) {
431  into.writeAttr(SUMO_ATTR_ENDOFFSET, endOffset);
432  }
433  if (width != NBEdge::UNSPECIFIED_WIDTH) {
434  into.writeAttr(SUMO_ATTR_WIDTH, width);
435  }
436  if (accelRamp) {
437  into.writeAttr<bool>(SUMO_ATTR_ACCELERATION, accelRamp);
438  }
439  if (customShape) {
440  into.writeAttr(SUMO_ATTR_CUSTOMSHAPE, true);
441  }
442  into.writeAttr(SUMO_ATTR_SHAPE, endOffset > 0 ?
443  shape.getSubpart(0, shape.length() - endOffset) : shape);
444 
445  if (stopOffsets.size() != 0) {
446  writeStopOffsets(into, stopOffsets);
447  }
448 
449  if (oppositeID != "" && oppositeID != "-") {
450  into.openTag(SUMO_TAG_NEIGH);
451  into.writeAttr(SUMO_ATTR_LANE, oppositeID);
452  into.closeTag();
453  }
454 
455  if (params != 0) {
456  params->writeParams(into);
457  }
458 
459  into.closeTag();
460 }
461 
462 
463 void
464 NWWriter_SUMO::writeJunction(OutputDevice& into, const NBNode& n, const bool checkLaneFoes) {
465  // write the attributes
467  into.writeAttr(SUMO_ATTR_TYPE, n.getType());
469  // write the incoming lanes
470  std::string incLanes;
471  const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
472  for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
473  int noLanes = (*i)->getNumLanes();
474  for (int j = 0; j < noLanes; j++) {
475  incLanes += (*i)->getLaneID(j);
476  if (i != incoming.end() - 1 || j < noLanes - 1) {
477  incLanes += ' ';
478  }
479  }
480  }
481  std::vector<NBNode::Crossing*> crossings = n.getCrossings();
482  std::set<std::string> prevWAs;
483  // avoid duplicates
484  for (auto c : crossings) {
485  if (prevWAs.count(c->prevWalkingArea) == 0) {
486  incLanes += ' ' + c->prevWalkingArea + "_0";
487  prevWAs.insert(c->prevWalkingArea);
488  }
489  }
490  into.writeAttr(SUMO_ATTR_INCLANES, incLanes);
491  // write the internal lanes
492  std::string intLanes;
493  if (!OptionsCont::getOptions().getBool("no-internal-links")) {
494  int l = 0;
495  for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
496  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
497  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
498  if ((*k).toEdge == 0) {
499  continue;
500  }
501  if (l != 0) {
502  intLanes += ' ';
503  }
504  if (!(*k).haveVia) {
505  intLanes += (*k).getInternalLaneID();
506  } else {
507  intLanes += (*k).viaID + "_0";
508  }
509  l++;
510  }
511  }
512  }
513  if (n.getType() != NODETYPE_DEAD_END && n.getType() != NODETYPE_NOJUNCTION) {
514  for (auto c : crossings) {
515  intLanes += ' ' + c->id + "_0";
516  }
517  }
518  into.writeAttr(SUMO_ATTR_INTLANES, intLanes);
519  // close writing
521  // write optional radius
524  }
525  // specify whether a custom shape was used
526  if (n.hasCustomShape()) {
527  into.writeAttr(SUMO_ATTR_CUSTOMSHAPE, true);
528  }
529  if (n.getType() != NODETYPE_DEAD_END) {
530  // write right-of-way logics
531  n.writeLogic(into, checkLaneFoes);
532  }
533  n.writeParams(into);
534  into.closeTag();
535 }
536 
537 
538 bool
540  bool ret = false;
541  const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
542  // build the list of internal lane ids
543  std::vector<std::string> internalLaneIDs;
544  std::map<std::string, std::string> viaIDs;
545  for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
546  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
547  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
548  if ((*k).toEdge != 0) {
549  internalLaneIDs.push_back((*k).getInternalLaneID());
550  viaIDs[(*k).getInternalLaneID()] = ((*k).viaID);
551  }
552  }
553  }
554  for (auto c : n.getCrossings()) {
555  internalLaneIDs.push_back(c->id + "_0");
556  }
557  // write the internal nodes
558  for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
559  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
560  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
561  if ((*k).toEdge == 0 || !(*k).haveVia) {
562  continue;
563  }
564  Position pos = (*k).shape[-1];
565  into.openTag(SUMO_TAG_JUNCTION).writeAttr(SUMO_ATTR_ID, (*k).viaID + "_0");
567  NWFrame::writePositionLong(pos, into);
568  std::string incLanes = (*k).getInternalLaneID();
569  std::vector<std::string> foeIDs;
570  for (std::string incLane : (*k).foeIncomingLanes) {
571  incLanes += " " + incLane;
572  if (incLane[0] == ':' && viaIDs[incLane] != "") {
573  // intersecting left turns
574  foeIDs.push_back(viaIDs[incLane] + "_0");
575  }
576  }
577  into.writeAttr(SUMO_ATTR_INCLANES, incLanes);
578  const std::vector<int>& foes = (*k).foeInternalLinks;
579  for (std::vector<int>::const_iterator it = foes.begin(); it != foes.end(); ++it) {
580  foeIDs.push_back(internalLaneIDs[*it]);
581  }
582  into.writeAttr(SUMO_ATTR_INTLANES, joinToString(foeIDs, " "));
583  into.closeTag();
584  ret = true;
585  }
586  }
587  return ret;
588 }
589 
590 
591 void
593  bool includeInternal, ConnectionStyle style) {
594  assert(c.toEdge != 0);
596  into.writeAttr(SUMO_ATTR_FROM, from.getID());
597  into.writeAttr(SUMO_ATTR_TO, c.toEdge->getID());
600  if (c.mayDefinitelyPass && style != TLL) {
602  }
603  if ((from.getToNode()->getKeepClear() == false || c.keepClear == false) && style != TLL) {
604  into.writeAttr<bool>(SUMO_ATTR_KEEP_CLEAR, false);
605  }
606  if (c.contPos != NBEdge::UNSPECIFIED_CONTPOS && style != TLL) {
608  }
611  }
612  if (c.speed != NBEdge::UNSPECIFIED_SPEED && style != TLL) {
614  }
615  if (c.customShape.size() != 0 && style != TLL) {
617  }
618  if (c.uncontrolled != false && style != TLL) {
620  }
621  if (style != PLAIN) {
622  if (includeInternal) {
624  }
625  // set information about the controlling tl if any
626  if (c.tlID != "") {
627  into.writeAttr(SUMO_ATTR_TLID, c.tlID);
629  }
630  if (style == SUMONET) {
631  // write the direction information
632  LinkDirection dir = from.getToNode()->getDirection(&from, c.toEdge, OptionsCont::getOptions().getBool("lefthand"));
633  assert(dir != LINKDIR_NODIR);
634  into.writeAttr(SUMO_ATTR_DIR, toString(dir));
635  // write the state information
636  const LinkState linkState = from.getToNode()->getLinkState(
637  &from, c.toEdge, c.fromLane, c.toLane, c.mayDefinitelyPass, c.tlID);
638  into.writeAttr(SUMO_ATTR_STATE, linkState);
639  }
640  }
641  into.closeTag();
642 }
643 
644 
645 bool
647  bool ret = false;
648  const bool lefthand = OptionsCont::getOptions().getBool("lefthand");
649  const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
650  for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
651  NBEdge* from = *i;
652  const std::vector<NBEdge::Connection>& connections = from->getConnections();
653  for (std::vector<NBEdge::Connection>::const_iterator j = connections.begin(); j != connections.end(); ++j) {
654  const NBEdge::Connection& c = *j;
655  LinkDirection dir = n.getDirection(from, c.toEdge, lefthand);
656  assert(c.toEdge != 0);
657  if (c.haveVia) {
658  // internal split
659  writeInternalConnection(into, c.id, c.toEdge->getID(), c.internalLaneIndex, c.toLane, c.viaID + "_0", dir);
660  writeInternalConnection(into, c.viaID, c.toEdge->getID(), 0, c.toLane, "", dir);
661  } else {
662  // no internal split
663  writeInternalConnection(into, c.id, c.toEdge->getID(), c.internalLaneIndex, c.toLane, "", dir);
664  }
665  ret = true;
666  }
667  }
668  return ret;
669 }
670 
671 
672 void
674  const std::string& from, const std::string& to,
675  int fromLane, int toLane, const std::string& via,
676  LinkDirection dir, const std::string& tlID, int linkIndex) {
678  into.writeAttr(SUMO_ATTR_FROM, from);
679  into.writeAttr(SUMO_ATTR_TO, to);
680  into.writeAttr(SUMO_ATTR_FROM_LANE, fromLane);
681  into.writeAttr(SUMO_ATTR_TO_LANE, toLane);
682  if (via != "") {
683  into.writeAttr(SUMO_ATTR_VIA, via);
684  }
685  if (tlID != "" && linkIndex != NBConnection::InvalidTlIndex) {
686  // used for the reverse direction of pedestrian crossings
687  into.writeAttr(SUMO_ATTR_TLID, tlID);
688  into.writeAttr(SUMO_ATTR_TLLINKINDEX, linkIndex);
689  }
690  into.writeAttr(SUMO_ATTR_DIR, dir);
691  into.writeAttr(SUMO_ATTR_STATE, (via != "" ? "m" : "M"));
692  into.closeTag();
693 }
694 
695 
696 void
697 NWWriter_SUMO::writeRoundabouts(OutputDevice& into, const std::set<EdgeSet>& roundabouts,
698  const NBEdgeCont& ec) {
699  // make output deterministic
700  std::vector<std::vector<std::string> > edgeIDs;
701  for (std::set<EdgeSet>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
702  std::vector<std::string> tEdgeIDs;
703  for (EdgeSet::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
704  // the edges may have been erased from NBEdgeCont but their pointers are still valid
705  // we verify their existance in writeRoundabout()
706  tEdgeIDs.push_back((*j)->getID());
707  }
708  std::sort(tEdgeIDs.begin(), tEdgeIDs.end());
709  edgeIDs.push_back(tEdgeIDs);
710  }
711  std::sort(edgeIDs.begin(), edgeIDs.end());
712  // write
713  for (std::vector<std::vector<std::string> >::const_iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
714  writeRoundabout(into, *i, ec);
715  }
716  if (roundabouts.size() != 0) {
717  into.lf();
718  }
719 }
720 
721 
722 void
723 NWWriter_SUMO::writeRoundabout(OutputDevice& into, const std::vector<std::string>& edgeIDs,
724  const NBEdgeCont& ec) {
725  std::vector<std::string> validEdgeIDs;
726  std::vector<std::string> invalidEdgeIDs;
727  std::vector<std::string> nodeIDs;
728  for (std::vector<std::string>::const_iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
729  const NBEdge* edge = ec.retrieve(*i);
730  if (edge != 0) {
731  nodeIDs.push_back(edge->getToNode()->getID());
732  validEdgeIDs.push_back(edge->getID());
733  } else {
734  invalidEdgeIDs.push_back(*i);
735  }
736  }
737  std::sort(nodeIDs.begin(), nodeIDs.end());
738  if (validEdgeIDs.size() > 0) {
740  into.writeAttr(SUMO_ATTR_NODES, joinToString(nodeIDs, " "));
741  into.writeAttr(SUMO_ATTR_EDGES, joinToString(validEdgeIDs, " "));
742  into.closeTag();
743  if (invalidEdgeIDs.size() > 0) {
744  WRITE_WARNING("Writing incomplete roundabout. Edges: '"
745  + joinToString(invalidEdgeIDs, " ") + "' no longer exist'");
746  }
747  }
748 }
749 
750 
751 void
753  std::vector<double> sourceW = d.getSourceWeights();
755  std::vector<double> sinkW = d.getSinkWeights();
757  // write the head and the id of the district
759  if (d.getShape().size() > 0) {
761  }
762  // write all sources
763  const std::vector<NBEdge*>& sources = d.getSourceEdges();
764  for (int i = 0; i < (int)sources.size(); i++) {
765  // write the head and the id of the source
766  into.openTag(SUMO_TAG_TAZSOURCE).writeAttr(SUMO_ATTR_ID, sources[i]->getID()).writeAttr(SUMO_ATTR_WEIGHT, sourceW[i]);
767  into.closeTag();
768  }
769  // write all sinks
770  const std::vector<NBEdge*>& sinks = d.getSinkEdges();
771  for (int i = 0; i < (int)sinks.size(); i++) {
772  // write the head and the id of the sink
773  into.openTag(SUMO_TAG_TAZSINK).writeAttr(SUMO_ATTR_ID, sinks[i]->getID()).writeAttr(SUMO_ATTR_WEIGHT, sinkW[i]);
774  into.closeTag();
775  }
776  // write the tail
777  into.closeTag();
778 }
779 
780 
781 std::string
783  double time = STEPS2TIME(steps);
784  if (time == std::floor(time)) {
785  return toString(int(time));
786  } else {
787  return toString(time);
788  }
789 }
790 
791 
792 void
794  for (NBConnectionProhibits::const_iterator j = prohibitions.begin(); j != prohibitions.end(); j++) {
795  NBConnection prohibited = (*j).first;
796  const NBConnectionVector& prohibiting = (*j).second;
797  for (NBConnectionVector::const_iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
798  NBConnection prohibitor = *k;
802  into.closeTag();
803  }
804  }
805 }
806 
807 
808 std::string
810  return c.getFrom()->getID() + "->" + c.getTo()->getID();
811 }
812 
813 
814 void
816  std::vector<NBTrafficLightLogic*> logics = tllCont.getComputed();
817  for (std::vector<NBTrafficLightLogic*>::iterator it = logics.begin(); it != logics.end(); it++) {
819  into.writeAttr(SUMO_ATTR_ID, (*it)->getID());
820  into.writeAttr(SUMO_ATTR_TYPE, (*it)->getType());
821  into.writeAttr(SUMO_ATTR_PROGRAMID, (*it)->getProgramID());
822  into.writeAttr(SUMO_ATTR_OFFSET, writeSUMOTime((*it)->getOffset()));
823  // write the phases
824  const bool varPhaseLength = (*it)->getType() != TLTYPE_STATIC;
825  const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases = (*it)->getPhases();
826  for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator j = phases.begin(); j != phases.end(); ++j) {
827  into.openTag(SUMO_TAG_PHASE);
828  into.writeAttr(SUMO_ATTR_DURATION, writeSUMOTime(j->duration));
829  if (j->duration < TIME2STEPS(10)) {
830  into.writePadding(" ");
831  }
832  into.writeAttr(SUMO_ATTR_STATE, j->state);
833  if (varPhaseLength) {
836  }
839  }
840  }
841  into.closeTag();
842  }
843  // write params
844  (*it)->writeParams(into);
845  into.closeTag();
846  }
847  if (logics.size() > 0) {
848  into.lf();
849  }
850 }
851 
852 
853 void
854 NWWriter_SUMO::writeStopOffsets(OutputDevice& into, const std::map<SVCPermissions, double>& stopOffsets) {
855  if (stopOffsets.size() == 0) {
856  return;
857  }
858  assert(stopOffsets.size() == 1);
859  std::pair<int, double> offset = *stopOffsets.begin();
860  std::string ss_vclasses = getVehicleClassNames(offset.first);
861  if (ss_vclasses.length() == 0) {
862  // This stopOffset would have no effect...
863  return;
864  }
866  std::string ss_exceptions = getVehicleClassNames(~offset.first);
867  if (ss_vclasses.length() <= ss_exceptions.length()) {
868  into.writeAttr(SUMO_ATTR_VCLASSES, ss_vclasses);
869  } else {
870  if (ss_exceptions.length() == 0) {
871  into.writeAttr(SUMO_ATTR_VCLASSES, "all");
872  } else {
873  into.writeAttr(SUMO_ATTR_EXCEPTIONS, ss_exceptions);
874  }
875  }
876  into.writeAttr(SUMO_ATTR_VALUE, offset.second);
877  into.closeTag();
878 }
879 
880 /****************************************************************************/
881 
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:276
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge&#39;s lanes&#39; lateral offset is computed.
Definition: NBEdge.h:699
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:1787
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:557
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:265
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:2223
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:422
double length
This lane&#39;s width.
Definition: NBNode.h:178
const std::string & getTypeID() const
get ID of type
Definition: NBEdge.h:999
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:494
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
A container for districts.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:256
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:68
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Definition: NBEdge.h:502
static const SUMOTime UNSPECIFIED_DURATION
Crossing * getCrossing(const std::string &id) const
return the crossing with the given id
Definition: NBNode.cpp:2856
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:584
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:69
#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.
const SVCPermissions SVCAll
all VClasses are allowed
static void writeTrafficLights(OutputDevice &into, const NBTrafficLightLogicCont &tllCont)
writes the traffic light logics to the given device
static std::string getOppositeInternalID(const NBEdgeCont &ec, const NBEdge *from, const NBEdge::Connection &con)
retrieve the id of the opposite direction internal lane if it exists
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:253
prohibition of circulation between two edges
PositionVector customShape
custom shape for connection
Definition: NBEdge.h:212
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:242
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:259
PositionVector shape
shape of Connection
Definition: NBEdge.h:218
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.
bool writeLogic(OutputDevice &into, const bool checkLaneFoes) const
writes the XML-representation of the logic as a bitset-logic XML representation
Definition: NBNode.cpp:869
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:2970
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:262
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:694
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
Definition: NBEdge.cpp:528
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:538
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.
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:3523
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:1696
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1911
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:617
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:271
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:249
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:862
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:266
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:241
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:641
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.
static void writeJunction(OutputDevice &into, const NBNode &n, const bool checkLaneFoes)
Writes a junction (<junction ...)
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:957
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:429
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
std::string getInternalLaneID() const
get ID of internal lane
Definition: NBEdge.cpp:78
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:492
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:436
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:230
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void lf()
writes a line feed if applicable
Definition: OutputDevice.h:234
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.