SUMO - Simulation of Urban MObility
NIXMLEdgesHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // Importer for network edges stored in XML
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <iostream>
37 #include <map>
38 #include <cmath>
39 #include <xercesc/sax/HandlerBase.hpp>
40 #include <xercesc/sax/AttributeList.hpp>
41 #include <xercesc/sax/SAXParseException.hpp>
42 #include <xercesc/sax/SAXException.hpp>
44 #include <netbuild/NBNodeCont.h>
45 #include <netbuild/NBTypeCont.h>
46 #include <netbuild/NBNetBuilder.h>
52 #include <utils/common/ToString.h>
55 #include "NIXMLNodesHandler.h"
56 #include "NIXMLEdgesHandler.h"
57 
58 #ifdef CHECK_MEMORY_LEAKS
59 #include <foreign/nvwa/debug_new.h>
60 #endif // CHECK_MEMORY_LEAKS
61 
62 
63 // ===========================================================================
64 // method definitions
65 // ===========================================================================
67  NBEdgeCont& ec,
68  NBTypeCont& tc,
69  NBDistrictCont& dc,
71  OptionsCont& options)
72  : SUMOSAXHandler("xml-edges - file"),
73  myOptions(options),
74  myNodeCont(nc),
75  myEdgeCont(ec),
76  myTypeCont(tc),
77  myDistrictCont(dc),
78  myTLLogicCont(tlc),
79  myCurrentEdge(0), myHaveReportedAboutOverwriting(false),
80  myHaveReportedAboutTypeOverride(false),
81  myHaveWarnedAboutDeprecatedLaneId(false),
82  myKeepEdgeShape(!options.getBool("plain.extend-edge-shape")) {
83 }
84 
85 
87 
88 
89 void
91  const SUMOSAXAttributes& attrs) {
92  switch (element) {
93  case SUMO_TAG_EDGE:
94  addEdge(attrs);
95  break;
96  case SUMO_TAG_LANE:
97  addLane(attrs);
98  break;
99  case SUMO_TAG_NEIGH:
101  break;
102  case SUMO_TAG_SPLIT:
103  addSplit(attrs);
104  break;
105  case SUMO_TAG_DELETE:
106  deleteEdge(attrs);
107  break;
108  case SUMO_TAG_ROUNDABOUT:
109  addRoundabout(attrs);
110  break;
111  default:
112  break;
113  }
114 }
115 
116 
117 void
119  myIsUpdate = false;
120  bool ok = true;
121  // initialise the edge
122  myCurrentEdge = 0;
123  mySplits.clear();
124  // get the id, report an error if not given or empty...
125  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
126  if (!ok) {
127  return;
128  }
130  // check deprecated (unused) attributes
131  // use default values, first
135  if (myCurrentEdge != 0) {
136  // update existing edge. only update lane-specific settings when explicitly requested
137  myIsUpdate = true;
141  } else {
142  // this is a completely new edge. get the type specific defaults
146  }
147  myCurrentType = "";
151  myCurrentStreetName = "";
152  myReinitKeepEdgeShape = false;
155  // check whether a type's values shall be used
156  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
157  myCurrentType = attrs.get<std::string>(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok);
158  if (!ok) {
159  return;
160  }
161  if (!myTypeCont.knows(myCurrentType) && !myOptions.getBool("ignore-errors.edge-type")) {
162  WRITE_ERROR("Type '" + myCurrentType + "' used by edge '" + myCurrentID + "' was not defined (ignore with option --ignore-errors.edge-type).");
163  return;
164  }
172  }
173  // use values from the edge to overwrite if existing, then
174  if (myIsUpdate) {
176  WRITE_MESSAGE("Duplicate edge id occurred ('" + myCurrentID + "'); assuming overwriting is wished.");
178  }
181  WRITE_MESSAGE("Edge '" + myCurrentID + "' changed it's type; assuming type override is wished.");
183  }
184  }
185  if (attrs.getOpt<bool>(SUMO_ATTR_REMOVE, myCurrentID.c_str(), ok, false)) {
187  myCurrentEdge = 0;
188  return;
189  }
194  myReinitKeepEdgeShape = true;
195  }
199  }
201  }
202  // speed, priority and the number of lanes have now default values;
203  // try to read the real values from the file
204  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
205  myCurrentSpeed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok);
206  }
207  if (myOptions.getBool("speed-in-kmh") && myCurrentSpeed != NBEdge::UNSPECIFIED_SPEED) {
209  }
210  // try to get the number of lanes
211  if (attrs.hasAttribute(SUMO_ATTR_NUMLANES)) {
212  myCurrentLaneNo = attrs.get<int>(SUMO_ATTR_NUMLANES, myCurrentID.c_str(), ok);
213  }
214  // try to get the priority
215  if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
216  myCurrentPriority = attrs.get<int>(SUMO_ATTR_PRIORITY, myCurrentID.c_str(), ok);
217  }
218  // try to get the width
219  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
220  myCurrentWidth = attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok);
221  }
222  // try to get the offset of the stop line from the intersection
223  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
225  }
226  // try to get the street name
227  if (attrs.hasAttribute(SUMO_ATTR_NAME)) {
228  myCurrentStreetName = attrs.get<std::string>(SUMO_ATTR_NAME, myCurrentID.c_str(), ok);
229  if (myCurrentStreetName != "" && myOptions.isDefault("output.street-names")) {
230  myOptions.set("output.street-names", "true");
231  }
232  }
233 
234  // try to get the allowed/disallowed classes
236  std::string allowS = attrs.hasAttribute(SUMO_ATTR_ALLOW) ? attrs.getStringSecure(SUMO_ATTR_ALLOW, "") : "";
237  std::string disallowS = attrs.hasAttribute(SUMO_ATTR_DISALLOW) ? attrs.getStringSecure(SUMO_ATTR_DISALLOW, "") : "";
238  // XXX matter of interpretation: should updated permissions replace or extend previously set permissions?
239  myPermissions = parseVehicleClasses(allowS, disallowS);
240  }
241  // try to set the nodes
242  if (!setNodes(attrs)) {
243  // return if this failed
244  return;
245  }
246  // try to get the shape
247  myShape = tryGetShape(attrs);
248  // try to get the spread type
250  // try to get the length
252  // try to get the sidewalkWidth
254  // try to get the bikeLaneWidth
256  // insert the parsed edge into the edges map
257  if (!ok) {
258  return;
259  }
260  // check whether a previously defined edge shall be overwritten
261  if (myCurrentEdge != 0) {
267  } else {
268  // the edge must be allocated in dependence to whether a shape is given
269  if (myShape.size() == 0) {
273  } else {
278  }
279  }
283  }
284 }
285 
286 
287 void
289  if (myCurrentEdge == 0) {
290  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
291  WRITE_ERROR("Additional lane information could not be set - the edge with id '" + myCurrentID + "' is not known.");
292  }
293  return;
294  }
295  bool ok = true;
296  int lane;
297  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
298  lane = attrs.get<int>(SUMO_ATTR_ID, myCurrentID.c_str(), ok);
301  WRITE_WARNING("'" + toString(SUMO_ATTR_ID) + "' is deprecated, please use '" + toString(SUMO_ATTR_INDEX) + "' instead.");
302  }
303  } else {
304  lane = attrs.get<int>(SUMO_ATTR_INDEX, myCurrentID.c_str(), ok);
305  }
306  if (!ok) {
307  return;
308  }
309  // check whether this lane exists
310  if (lane >= (int) myCurrentEdge->getNumLanes()) {
311  WRITE_ERROR("Lane index is larger than number of lanes (edge '" + myCurrentID + "').");
312  return;
313  }
314  // set information about allowed / disallowed vehicle classes (if specified)
316  const std::string allowed = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, 0, ok, "");
317  const std::string disallowed = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, 0, ok, "");
318  myCurrentEdge->setPermissions(parseVehicleClasses(allowed, disallowed), lane);
319  }
320  if (attrs.hasAttribute(SUMO_ATTR_PREFER)) {
321  const std::string preferred = attrs.get<std::string>(SUMO_ATTR_PREFER, 0, ok);
323  }
324  // try to get the width
325  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
326  myCurrentEdge->setLaneWidth(lane, attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok));
327  }
328  // try to get the end-offset (lane shortened due to pedestrian crossing etc..)
329  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
331  }
332  // try to get lane specific speed (should not occur for german networks)
333  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
334  myCurrentEdge->setSpeed(lane, attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok));
335  }
336 }
337 
338 
340  if (myCurrentEdge == 0) {
341  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
342  WRITE_WARNING("Ignoring 'split' because it cannot be assigned to an edge");
343  }
344  return;
345  }
346  bool ok = true;
347  Split e;
348  e.pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok);
349  if (ok) {
350  if (fabs(e.pos) > myCurrentEdge->getGeometry().length()) {
351  WRITE_ERROR("Edge '" + myCurrentID + "' has a split at invalid position " + toString(e.pos) + ".");
352  return;
353  }
354  std::vector<Split>::iterator i = find_if(mySplits.begin(), mySplits.end(), split_by_pos_finder(e.pos));
355  if (i != mySplits.end()) {
356  WRITE_ERROR("Edge '" + myCurrentID + "' has already a split at position " + toString(e.pos) + ".");
357  return;
358  }
359  const std::string nameid = toString((int)e.pos);
360  if (e.pos < 0) {
362  }
363  std::vector<std::string> lanes;
364  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LANES, 0, ok, ""), lanes);
365  for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) {
366  try {
367  int lane = TplConvert::_2int((*i).c_str());
368  e.lanes.push_back(lane);
369  } catch (NumberFormatException&) {
370  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
371  } catch (EmptyData&) {
372  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
373  }
374  }
375  if (e.lanes.empty()) {
376  for (int l = 0; l < myCurrentEdge->getNumLanes(); ++l) {
377  e.lanes.push_back(l);
378  }
379  }
380  e.speed = attrs.getOpt(SUMO_ATTR_SPEED, 0, ok, myCurrentEdge->getSpeed());
381  if (attrs.hasAttribute(SUMO_ATTR_SPEED) && myOptions.getBool("speed-in-kmh")) {
382  e.speed /= (SUMOReal) 3.6;
383  }
384  e.idBefore = attrs.getOpt(SUMO_ATTR_ID_BEFORE, 0, ok, std::string(""));
385  e.idAfter = attrs.getOpt(SUMO_ATTR_ID_AFTER, 0, ok, std::string(""));
386  if (!ok) {
387  return;
388  }
389  e.node = new NBNode(myCurrentID + "." + nameid,
393  mySplits.push_back(e);
394  }
395 }
396 
397 
398 bool
400  // the names and the coordinates of the beginning and the end node
401  // may be found, try
402  bool ok = true;
403  std::string begNodeID = myIsUpdate ? myCurrentEdge->getFromNode()->getID() : "";
404  std::string endNodeID = myIsUpdate ? myCurrentEdge->getToNode()->getID() : "";
405  std::string oldBegID = begNodeID;
406  std::string oldEndID = endNodeID;
407  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
408  begNodeID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
409  } else if (!myIsUpdate) {
410  WRITE_ERROR("The from-node is not given for edge '" + myCurrentID + "'.");
411  ok = false;
412  }
413  if (attrs.hasAttribute(SUMO_ATTR_TO)) {
414  endNodeID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
415  } else if (!myIsUpdate) {
416  WRITE_ERROR("The to-node is not given for edge '" + myCurrentID + "'.");
417  ok = false;
418  }
419  if (!ok) {
420  return false;
421  }
422  myFromNode = myNodeCont.retrieve(begNodeID);
423  myToNode = myNodeCont.retrieve(endNodeID);
424  if (myFromNode == 0) {
425  WRITE_ERROR("Edge's '" + myCurrentID + "' from-node '" + begNodeID + "' is not known.");
426  }
427  if (myToNode == 0) {
428  WRITE_ERROR("Edge's '" + myCurrentID + "' to-node '" + endNodeID + "' is not known.");
429  }
430  if (myFromNode != 0 && myToNode != 0) {
431  if (myIsUpdate && (myFromNode->getID() != oldBegID || myToNode->getID() != oldEndID)) {
433  }
434  }
435  return myFromNode != 0 && myToNode != 0;
436 }
437 
438 
441  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
442  return myShape;
443  }
444  // try to build shape
445  bool ok = true;
446  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
447  myReinitKeepEdgeShape = false;
448  return PositionVector();
449  }
452  WRITE_ERROR("Unable to project coordinates for edge '" + myCurrentID + "'.");
453  }
455  return shape;
456 }
457 
458 
461  bool ok = true;
463  std::string lsfS = toString(result);
464  lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, myCurrentID.c_str(), ok, lsfS);
465  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
467  } else {
468  WRITE_WARNING("Ignoring unknown spreadType '" + lsfS + "' for edge '" + myCurrentID + "'.");
469  }
470  return result;
471 }
472 
473 
474 void
476  bool ok = true;
477  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
478  if (!ok) {
479  return;
480  }
482  if (edge == 0) {
483  WRITE_WARNING("Ignoring tag '" + toString(SUMO_TAG_DELETE) + "' for unknown edge '" +
484  myCurrentID + "'");
485  return;
486  }
487  myEdgeCont.extract(myDistrictCont, edge, true);
488 }
489 
490 
491 void
493  if (element == SUMO_TAG_EDGE && myCurrentEdge != 0) {
494  // add bike lane, wait until lanes are loaded to avoid building if it already exists
497  }
498  // add sidewalk, wait until lanes are loaded to avoid building if it already exists
501  }
502  if (!myIsUpdate) {
503  try {
505  WRITE_ERROR("Duplicate edge occured. ID='" + myCurrentID + "'");
506  delete myCurrentEdge;
507  }
508  } catch (InvalidArgument& e) {
509  WRITE_ERROR(e.what());
510  throw;
511  } catch (...) {
512  WRITE_ERROR("An important information is missing in edge '" + myCurrentID + "'.");
513  }
514  }
515  if (mySplits.size() != 0) {
516  std::vector<Split>::iterator i;
517  NBEdge* e = myCurrentEdge;
518  sort(mySplits.begin(), mySplits.end(), split_sorter());
519  int noLanesMax = e->getNumLanes();
520  // compute the node positions and sort the lanes
521  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
522  sort((*i).lanes.begin(), (*i).lanes.end());
523  noLanesMax = MAX2(noLanesMax, (int)(*i).lanes.size());
524  }
525  // split the edge
526  std::vector<int> currLanes;
527  for (int l = 0; l < e->getNumLanes(); ++l) {
528  currLanes.push_back(l);
529  }
530  if (e->getNumLanes() != (int)mySplits.back().lanes.size()) {
531  // invalidate traffic light definitions loaded from a SUMO network
532  // XXX it would be preferable to reconstruct the phase definitions heuristically
534  // if the number of lanes changes the connections should be
535  // recomputed
536  e->invalidateConnections(true);
537  }
538 
539  std::string firstID = "";
540  SUMOReal seen = 0;
541  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
542  const Split& exp = *i;
543  assert(exp.lanes.size() != 0);
544  if (exp.pos > 0 && e->getGeometry().length() + seen > exp.pos && exp.pos > seen) {
545  if (myNodeCont.insert(exp.node)) {
547  // split the edge
548  std::string idBefore = exp.idBefore == "" ? e->getID() : exp.idBefore;
549  std::string idAfter = exp.idAfter == "" ? exp.node->getID() : exp.idAfter;
550  if (firstID == "") {
551  firstID = idBefore;
552  }
553  myEdgeCont.splitAt(myDistrictCont, e, exp.pos - seen, exp.node,
554  idBefore, idAfter, e->getNumLanes(), (int) exp.lanes.size(), exp.speed);
555  seen = exp.pos;
556  std::vector<int> newLanes = exp.lanes;
557  NBEdge* pe = myEdgeCont.retrieve(idBefore);
558  NBEdge* ne = myEdgeCont.retrieve(idAfter);
559  // reconnect lanes
560  pe->invalidateConnections(true);
561  // new on right
562  int rightMostP = currLanes[0];
563  int rightMostN = newLanes[0];
564  for (int l = 0; l < (int) rightMostP - (int) rightMostN; ++l) {
565  pe->addLane2LaneConnection(0, ne, l, NBEdge::L2L_VALIDATED, true);
566  }
567  // new on left
568  int leftMostP = currLanes.back();
569  int leftMostN = newLanes.back();
570  for (int l = 0; l < (int) leftMostN - (int) leftMostP; ++l) {
571  pe->addLane2LaneConnection(pe->getNumLanes() - 1, ne, leftMostN - l - rightMostN, NBEdge::L2L_VALIDATED, true);
572  }
573  // all other connected
574  for (int l = 0; l < noLanesMax; ++l) {
575  if (find(currLanes.begin(), currLanes.end(), l) == currLanes.end()) {
576  continue;
577  }
578  if (find(newLanes.begin(), newLanes.end(), l) == newLanes.end()) {
579  continue;
580  }
581  pe->addLane2LaneConnection(l - rightMostP, ne, l - rightMostN, NBEdge::L2L_VALIDATED, true);
582  }
583  // move to next
584  e = ne;
585  currLanes = newLanes;
586  } else {
587  WRITE_WARNING("Error on parsing a split (edge '" + myCurrentID + "').");
588  }
589  } else if (exp.pos == 0) {
590  const int laneCountDiff = e->getNumLanes() - (int)exp.lanes.size();
591  if (laneCountDiff < 0) {
592  e->incLaneNo(-laneCountDiff);
593  } else {
594  e->decLaneNo(laneCountDiff);
595  }
596  currLanes = exp.lanes;
597  // invalidate traffic light definition loaded from a SUMO network
598  // XXX it would be preferable to reconstruct the phase definitions heuristically
600  } else {
601  WRITE_WARNING("Split at '" + toString(exp.pos) + "' lies beyond the edge's length (edge '" + myCurrentID + "').");
602  }
603  }
604  // patch lane offsets
605  e = myEdgeCont.retrieve(firstID);
606  if (mySplits.front().pos != 0) {
607  // add a dummy split at the beginning to ensure correct offset
608  Split start;
609  start.pos = 0;
610  for (int lane = 0; lane < (int)e->getNumLanes(); ++lane) {
611  start.lanes.push_back(lane);
612  }
613  mySplits.insert(mySplits.begin(), start);
614  }
615  i = mySplits.begin();
616  for (; i != mySplits.end(); ++i) {
617  int maxLeft = (*i).lanes.back();
618  SUMOReal offset = 0;
619  if (maxLeft < noLanesMax) {
621  offset = SUMO_const_laneWidthAndOffset * (noLanesMax - 1 - maxLeft);
622  } else {
623  offset = SUMO_const_halfLaneAndOffset * (noLanesMax - 1 - maxLeft);
624  }
625  }
626  int maxRight = (*i).lanes.front();
627  if (maxRight > 0 && e->getLaneSpreadFunction() == LANESPREAD_CENTER) {
628  offset -= SUMO_const_halfLaneAndOffset * maxRight;
629  }
630  if (offset != 0) {
631  PositionVector g = e->getGeometry();
632  g.move2side(offset);
633  e->setGeometry(g);
634  }
635  if (e->getToNode()->getOutgoingEdges().size() != 0) {
636  e = e->getToNode()->getOutgoingEdges()[0];
637  }
638  }
639  }
640  }
641 }
642 
643 
644 void
646  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
647  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
648  EdgeSet roundabout;
649  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
650  NBEdge* edge = myEdgeCont.retrieve(*it);
651  if (edge == 0) {
652  if (!myEdgeCont.wasIgnored(*it)) {
653  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
654  }
655  } else {
656  roundabout.insert(edge);
657  }
658  }
659  myEdgeCont.addRoundabout(roundabout);
660  } else {
661  WRITE_ERROR("Empty edges in roundabout.");
662  }
663 }
664 
665 
666 
667 /****************************************************************************/
668 
void invalidateConnections(bool reallowSetting=false)
invalidate current connections of edge
Definition: NBEdge.cpp:1148
The information about how to spread the lanes from the given position.
const std::string & getTypeID() const
get ID of type
Definition: NBEdge.h:946
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:244
LaneSpreadFunction myLanesSpread
Information about how to spread the lanes.
split something
Finds a split at the given position.
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
Definition: NBEdge.cpp:486
begin/end of the description of a single lane
std::string myCurrentID
The current edge&#39;s id.
const SUMOReal SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:53
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
void markAsSplit(const NBNode *node)
mark a node as being created form a split
Definition: NBNodeCont.h:277
PositionVector myShape
The shape of the edge.
A container for traffic light definitions and built programs.
void setLaneWidth(int lane, SUMOReal width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2664
SUMOReal myBikeLaneWidth
The width of the bike lane that shall be added to the current edge.
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2719
void addRoundabout(const SUMOSAXAttributes &attrs)
Parses a roundabout and stores it in myEdgeCont.
SUMOReal mySidewalkWidth
The width of the sidewalk that shall be added to the current edge.
const SUMOReal SUMO_const_laneWidthAndOffset
Definition: StdDefs.h:52
bool setNodes(const SUMOSAXAttributes &attrs)
Sets from/to node information of the currently parsed edge.
void addSidewalk(SUMOReal width)
add a pedestrian sidewalk of the given width and shift existing connctions
Definition: NBEdge.cpp:2861
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
Definition: NBEdge.h:71
NBNode * myFromNode
The nodes the edge starts and ends at.
A container for districts.
static const SUMOReal UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:250
NIXMLEdgesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
T MAX2(T a, T b)
Definition: StdDefs.h:70
bool myHaveReportedAboutOverwriting
Information whether at least one edge&#39;s attributes were overwritten.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
Definition: NBEdge.cpp:2735
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:420
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
NBDistrictCont & myDistrictCont
The districts container (needed if an edge must be split)
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1123
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:247
SAX-handler base for SUMO-files.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge&#39;s geometry
Definition: NBEdge.cpp:499
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:221
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The connection was computed and validated.
Definition: NBEdge.h:117
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
void reinit(NBNode *from, NBNode *to, const std::string &type, SUMOReal speed, int nolanes, int priority, PositionVector geom, SUMOReal width, SUMOReal offset, const std::string &streetName, LaneSpreadFunction spread=LANESPREAD_RIGHT, bool tryIgnoreNodePositions=false)
Resets initial values.
Definition: NBEdge.cpp:325
const bool myKeepEdgeShape
Whether the edge shape shall be kept generally.
bool myReinitKeepEdgeShape
Whether the edge shape shall be kept at reinitilization.
void addEdge(const SUMOSAXAttributes &attrs)
Parses an edge and stores the values in "myCurrentEdge".
~NIXMLEdgesHandler()
Destructor.
SUMOReal getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:227
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges (The edges which start at this node)
Definition: NBNode.h:245
SUMOReal getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:479
const std::string & getID() const
Returns the id.
Definition: Named.h:66
void incLaneNo(int by)
increment lane
Definition: NBEdge.cpp:2580
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
const Position & getPosition() const
Definition: NBNode.h:232
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:185
std::vector< Split > mySplits
The list of this edge&#39;s splits.
SUMOReal getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:233
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:51
the edges of a route
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:409
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:162
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
bool myHaveWarnedAboutDeprecatedLaneId
void decLaneNo(int by)
decrement lane
Definition: NBEdge.cpp:2606
Encapsulated SAX-Attributes.
SUMOReal speed
The speed after this change.
virtual std::vector< std::string > getStringVector(int attr) const =0
Tries to read given attribute assuming it is a string vector.
void extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
Definition: NBEdgeCont.cpp:396
void deleteEdge(const SUMOSAXAttributes &attrs)
parses delete tag and deletes the specified edge
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:179
A structure which describes changes of lane number or speed along the road.
A list of positions.
void addSplit(const SUMOSAXAttributes &attrs)
Parses a split and stores it in mySplits. Splits are executed Upon reading the end tag of an edge...
std::string myCurrentType
The current edge&#39;s type.
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:191
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, SUMOReal contPos=UNSPECIFIED_CONTPOS, SUMOReal visibility=UNSPECIFIED_VISIBILITY_DISTANCE)
Adds a connection between the specified this edge&#39;s lane and an approached one.
Definition: NBEdge.cpp:826
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Definition: NBEdge.h:489
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:402
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
SUMOReal myCurrentEndOffset
The current edge&#39;s offset till the destination node.
roundabout defined in junction
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
std::vector< int > lanes
The lanes after this change.
NBNodeCont & myNodeCont
The nodes container (for retrieval of referenced nodes)
edge: the shape in xml-definition
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to (when invalidating tls because of splits) ...
static void processNodeType(const SUMOSAXAttributes &attrs, NBNode *node, const std::string &nodeID, const Position &position, bool updateEdgeGeometries, NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
parses node attributes (not related to positioning)
Sorts splits by their position (increasing)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:79
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
LaneSpreadFunction tryGetLaneSpread(const SUMOSAXAttributes &attrs)
Tries to parse the spread type.
begin/end of the description of a neighboring lane
void setLoadedLength(SUMOReal val)
set loaded lenght
Definition: NBEdge.cpp:2778
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
begin/end of the description of an edge
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
SUMOReal length() const
Returns the length.
void addBikeLane(SUMOReal width)
add a bicycle lane of the given width and shift existing connctions
Definition: NBEdge.cpp:2873
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
Definition: TplConvert.h:149
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:423
SVCPermissions myPermissions
Information about lane permissions.
std::string idAfter
The id for the edge after the split.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
bool myIsUpdate
Whether this edge definition is an update of a previously inserted edge.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:255
SUMOReal myCurrentSpeed
The current edge&#39;s maximum speed.
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
Definition: NBEdge.h:259
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
set preferred Vehicle Class
Definition: NBEdge.cpp:2749
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:584
void myEndElement(int element)
Called when a closing tag occurs.
A storage for options typed value containers)
Definition: OptionsCont.h:99
NBEdge * myCurrentEdge
The currently processed edge.
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:389
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:81
OptionsCont & myOptions
A reference to the program&#39;s options.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge&#39;s lateral offset shal...
NBTypeCont & myTypeCont
The types container (for retrieval of type defaults)
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge&#39;s lanes&#39; lateral offset is computed.
Definition: NBEdge.h:653
Represents a single node (junction) during network building.
Definition: NBNode.h:75
T get(const std::string &str) const
void move2side(SUMOReal amount)
move position vector to side using certain ammount
bool myHaveReportedAboutTypeOverride
Information whether at least one edge&#39;s type was changed.
void setEndOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2703
#define SUMOReal
Definition: config.h:208
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:472
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NBEdgeCont & myEdgeCont
The edges container (for insertion of build edges)
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:110
int myCurrentLaneNo
The current edge&#39;s number of lanes.
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:215
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:496
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:63
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
SUMOReal myCurrentWidth
The current edge&#39;s lane width.
SUMOReal myLength
The current edge&#39;s length.
SUMOReal pos
The position of this change.
std::string myCurrentStreetName
The current edge&#39;s street name.
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
delete certain element
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
void invalidateTLS(NBTrafficLightLogicCont &tlCont)
causes the traffic light to be computed anew
Definition: NBNode.cpp:354
std::string idBefore
The id for the edge before the split.
const std::string & getStreetName() const
Returns the street name of this edge.
Definition: NBEdge.h:525
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and modifies myCurrentEdge according to the given attribures.
int myCurrentPriority
The current edge&#39;s priority.
NBNode * node
The new node that is created for this split.
const SVCPermissions SVC_UNSPECIFIED
A storage for available types of edges.
Definition: NBTypeCont.h:62
PositionVector tryGetShape(const SUMOSAXAttributes &attrs)
Tries to parse the shape definition.
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:416