SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2014 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 "NIXMLEdgesHandler.h"
56 
57 #ifdef CHECK_MEMORY_LEAKS
58 #include <foreign/nvwa/debug_new.h>
59 #endif // CHECK_MEMORY_LEAKS
60 
61 
62 // ===========================================================================
63 // used constants
64 // ===========================================================================
66 
67 // ===========================================================================
68 // method definitions
69 // ===========================================================================
71  NBEdgeCont& ec,
72  NBTypeCont& tc,
73  NBDistrictCont& dc,
75  OptionsCont& options)
76  : SUMOSAXHandler("xml-edges - file"),
77  myOptions(options),
78  myNodeCont(nc),
79  myEdgeCont(ec),
80  myTypeCont(tc),
81  myDistrictCont(dc),
82  myTLLogicCont(tlc),
83  myCurrentEdge(0), myHaveReportedAboutOverwriting(false),
84  myHaveWarnedAboutDeprecatedLaneId(false),
85  myKeepEdgeShape(!options.getBool("plain.extend-edge-shape"))
86 {}
87 
88 
90 
91 
92 void
94  const SUMOSAXAttributes& attrs) {
95  switch (element) {
96  case SUMO_TAG_EDGE:
97  addEdge(attrs);
98  break;
99  case SUMO_TAG_LANE:
100  addLane(attrs);
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
138  myCurrentType = "";
142  myCurrentStreetName = "";
143  myReinitKeepEdgeShape = false;
144  // check whether a type's values shall be used
145  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
146  myCurrentType = attrs.get<std::string>(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok);
147  if (!ok) {
148  return;
149  }
150  if (!myTypeCont.knows(myCurrentType) && !myOptions.getBool("ignore-errors.edge-type")) {
151  WRITE_ERROR("Type '" + myCurrentType + "' used by edge '" + myCurrentID + "' was not defined (ignore with option --ignore-errors.edge-type).");
152  return;
153  }
159  }
160  // use values from the edge to overwrite if existing, then
161  if (myCurrentEdge != 0) {
162  myIsUpdate = true;
164  WRITE_MESSAGE("Duplicate edge id occured ('" + myCurrentID + "'); assuming overwriting is wished.");
166  }
167  if (attrs.getOpt<bool>(SUMO_ATTR_REMOVE, myCurrentID.c_str(), ok, false)) {
169  myCurrentEdge = 0;
170  return;
171  }
179  myReinitKeepEdgeShape = true;
180  }
186  }
188  }
189  // speed, priority and the number of lanes have now default values;
190  // try to read the real values from the file
191  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
192  myCurrentSpeed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok);
193  }
194  if (myOptions.getBool("speed-in-kmh")) {
196  }
197  // try to get the number of lanes
198  if (attrs.hasAttribute(SUMO_ATTR_NUMLANES)) {
199  myCurrentLaneNo = attrs.get<int>(SUMO_ATTR_NUMLANES, myCurrentID.c_str(), ok);
200  }
201  // try to get the priority
202  if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
203  myCurrentPriority = attrs.get<int>(SUMO_ATTR_PRIORITY, myCurrentID.c_str(), ok);
204  }
205  // try to get the width
206  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
207  myCurrentWidth = attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok);
208  }
209  // try to get the width
210  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
212  }
213  // try to get the street name
214  if (attrs.hasAttribute(SUMO_ATTR_NAME)) {
215  myCurrentStreetName = attrs.get<std::string>(SUMO_ATTR_NAME, myCurrentID.c_str(), ok);
216  if (myCurrentStreetName != "" && myOptions.isDefault("output.street-names")) {
217  myOptions.set("output.street-names", "true");
218  }
219  }
220 
221  // try to get the allowed/disallowed classes
223  std::string allowS = attrs.hasAttribute(SUMO_ATTR_ALLOW) ? attrs.getStringSecure(SUMO_ATTR_ALLOW, "") : "";
224  std::string disallowS = attrs.hasAttribute(SUMO_ATTR_DISALLOW) ? attrs.getStringSecure(SUMO_ATTR_DISALLOW, "") : "";
225  // XXX matter of interpretation: should updated permissions replace or extend previously set permissions?
226  myPermissions = parseVehicleClasses(allowS, disallowS);
227  }
228  // try to set the nodes
229  if (!setNodes(attrs)) {
230  // return if this failed
231  return;
232  }
233  // try to get the shape
234  myShape = tryGetShape(attrs);
235  // try to get the spread type
237  // try to get the length
239  // insert the parsed edge into the edges map
240  if (!ok) {
241  return;
242  }
243  // check whether a previously defined edge shall be overwritten
244  if (myCurrentEdge != 0) {
250  } else {
251  // the edge must be allocated in dependence to whether a shape is given
252  if (myShape.size() == 0) {
256  } else {
261  }
262  }
266  // lane specifications may override this
268  }
269 }
270 
271 
272 void
274  if (myCurrentEdge == 0) {
275  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
276  WRITE_ERROR("Additional lane information could not be set - the edge with id '" + myCurrentID + "' is not known.");
277  }
278  return;
279  }
280  bool ok = true;
281  int lane;
282  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
283  lane = attrs.get<int>(SUMO_ATTR_ID, myCurrentID.c_str(), ok);
286  WRITE_WARNING("'" + toString(SUMO_ATTR_ID) + "' is deprecated, please use '" + toString(SUMO_ATTR_INDEX) + "' instead.");
287  }
288  } else {
289  lane = attrs.get<int>(SUMO_ATTR_INDEX, myCurrentID.c_str(), ok);
290  }
291  std::string allowed, disallowed, preferred;
292  allowed = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, 0, ok, "");
293  disallowed = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, 0, ok, "");
294  preferred = attrs.getOpt<std::string>(SUMO_ATTR_PREFER, 0, ok, "");
295  if (!ok) {
296  return;
297  }
298  // check whether this lane exists
299  if (lane >= (int) myCurrentEdge->getNumLanes()) {
300  WRITE_ERROR("Lane index is larger than number of lanes (edge '" + myCurrentID + "').");
301  return;
302  }
303  // set information about allowed / disallowed vehicle classes
304  myCurrentEdge->setPermissions(parseVehicleClasses(allowed, disallowed), lane);
306  // try to get the width
307  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
308  myCurrentEdge->setLaneWidth(lane, attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok));
309  }
310  // try to get the end-offset (lane shortened due to pedestrian crossing etc..)
311  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
313  }
314  // try to get lane specific speed (should not occur for german networks)
315  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
316  myCurrentEdge->setSpeed(lane, attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok));
317  }
318 }
319 
320 
322  if (myCurrentEdge == 0) {
323  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
324  WRITE_WARNING("Ignoring 'split' because it cannot be assigned to an edge");
325  }
326  return;
327  }
328  bool ok = true;
329  Split e;
330  e.pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok);
331  if (ok) {
332  if (fabs(e.pos) > myCurrentEdge->getGeometry().length()) {
333  WRITE_ERROR("Edge '" + myCurrentID + "' has a split at invalid position " + toString(e.pos) + ".");
334  return;
335  }
336  std::vector<Split>::iterator i = find_if(mySplits.begin(), mySplits.end(), split_by_pos_finder(e.pos));
337  if (i != mySplits.end()) {
338  WRITE_ERROR("Edge '" + myCurrentID + "' has already a split at position " + toString(e.pos) + ".");
339  return;
340  }
341  e.nameid = (int)e.pos;
342  if (e.pos < 0) {
344  }
345  std::vector<std::string> lanes;
346  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LANES, 0, ok, ""), lanes);
347  for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) {
348  try {
349  int lane = TplConvert::_2int((*i).c_str());
350  e.lanes.push_back(lane);
351  } catch (NumberFormatException&) {
352  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
353  } catch (EmptyData&) {
354  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
355  }
356  }
357  if (e.lanes.empty()) {
358  for (size_t l = 0; l < myCurrentEdge->getNumLanes(); ++l) {
359  e.lanes.push_back((int) l);
360  }
361  }
362  e.speed = attrs.getOpt(SUMO_ATTR_SPEED, 0, ok, myCurrentEdge->getSpeed());
363  if (attrs.hasAttribute(SUMO_ATTR_SPEED) && myOptions.getBool("speed-in-kmh")) {
364  e.speed /= (SUMOReal) 3.6;
365  }
366  if (!ok) {
367  return;
368  }
369  mySplits.push_back(e);
370  }
371 }
372 
373 
374 bool
376  // the names and the coordinates of the beginning and the end node
377  // may be found, try
378  bool ok = true;
379  std::string begNodeID = myIsUpdate ? myCurrentEdge->getFromNode()->getID() : "";
380  std::string endNodeID = myIsUpdate ? myCurrentEdge->getToNode()->getID() : "";
381  std::string oldBegID = begNodeID;
382  std::string oldEndID = endNodeID;
383  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
384  begNodeID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
385  } else if (!myIsUpdate) {
386  WRITE_ERROR("The from-node is not given for edge '" + myCurrentID + "'.");
387  ok = false;
388  }
389  if (attrs.hasAttribute(SUMO_ATTR_TO)) {
390  endNodeID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
391  } else if (!myIsUpdate) {
392  WRITE_ERROR("The to-node is not given for edge '" + myCurrentID + "'.");
393  ok = false;
394  }
395  if (!ok) {
396  return false;
397  }
398  myFromNode = myNodeCont.retrieve(begNodeID);
399  myToNode = myNodeCont.retrieve(endNodeID);
400  if (myFromNode == 0) {
401  WRITE_ERROR("Edge's '" + myCurrentID + "' from-node '" + begNodeID + "' is not known.");
402  }
403  if (myToNode == 0) {
404  WRITE_ERROR("Edge's '" + myCurrentID + "' to-node '" + endNodeID + "' is not known.");
405  }
406  if (myFromNode != 0 && myToNode != 0) {
407  if (myIsUpdate && (myFromNode->getID() != oldBegID || myToNode->getID() != oldEndID)) {
409  }
410  }
411  return myFromNode != 0 && myToNode != 0;
412 }
413 
414 
417  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
418  return myShape;
419  }
420  // try to build shape
421  bool ok = true;
422  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
423  myReinitKeepEdgeShape = false;
424  return PositionVector();
425  }
428  WRITE_ERROR("Unable to project coordinates for edge '" + myCurrentID + "'.");
429  }
431  return shape;
432 }
433 
434 
437  bool ok = true;
439  std::string lsfS = toString(result);
440  lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, myCurrentID.c_str(), ok, lsfS);
441  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
443  } else {
444  WRITE_WARNING("Ignoring unknown spreadType '" + lsfS + "' for edge '" + myCurrentID + "'.");
445  }
446  return result;
447 }
448 
449 
450 void
452  bool ok = true;
453  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
454  if (!ok) {
455  return;
456  }
458  if (edge == 0) {
459  WRITE_WARNING("Ignoring tag '" + toString(SUMO_TAG_DELETE) + "' for unknown edge '" +
460  myCurrentID + "'");
461  return;
462  }
463  myEdgeCont.extract(myDistrictCont, edge, true);
464 }
465 
466 
467 void
469  if (element == SUMO_TAG_EDGE && myCurrentEdge != 0) {
470  if (!myIsUpdate) {
471  try {
473  WRITE_ERROR("Duplicate edge occured. ID='" + myCurrentID + "'");
474  delete myCurrentEdge;
475  }
476  } catch (InvalidArgument& e) {
477  WRITE_ERROR(e.what());
478  throw;
479  } catch (...) {
480  WRITE_ERROR("An important information is missing in edge '" + myCurrentID + "'.");
481  }
482  }
483  if (mySplits.size() != 0) {
484  std::vector<Split>::iterator i;
485  NBEdge* e = myCurrentEdge;
486  sort(mySplits.begin(), mySplits.end(), split_sorter());
487  unsigned int noLanesMax = e->getNumLanes();
488  // compute the node positions and sort the lanes
489  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
490  (*i).gpos = e->getGeometry().positionAtOffset((*i).pos);
491  sort((*i).lanes.begin(), (*i).lanes.end());
492  noLanesMax = MAX2(noLanesMax, (unsigned int)(*i).lanes.size());
493  }
494  // invalidate traffic light definitions loaded from a SUMO network
495  // XXX it would be preferable to reconstruct the phase definitions heuristically
497  e->invalidateConnections(true);
498 
499  // split the edge
500  std::vector<int> currLanes;
501  for (unsigned int l = 0; l < e->getNumLanes(); ++l) {
502  currLanes.push_back(l);
503  }
504  std::string edgeid = e->getID();
505  SUMOReal seen = 0;
506  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
507  const Split& exp = *i;
508  assert(exp.lanes.size() != 0);
509  if (exp.pos > 0 && e->getGeometry().length() + seen > exp.pos && exp.pos > seen) {
510  std::string nid = edgeid + "." + toString(exp.nameid);
511  NBNode* rn = new NBNode(nid, exp.gpos);
512  if (myNodeCont.insert(rn)) {
513  // split the edge
514  std::string nid = myCurrentID + "." + toString(exp.nameid);
515  std::string pid = e->getID();
516  myEdgeCont.splitAt(myDistrictCont, e, exp.pos - seen, rn,
517  pid, nid, e->getNumLanes(), (unsigned int) exp.lanes.size(), exp.speed);
518  seen = exp.pos;
519  std::vector<int> newLanes = exp.lanes;
520  NBEdge* pe = myEdgeCont.retrieve(pid);
521  NBEdge* ne = myEdgeCont.retrieve(nid);
522  // reconnect lanes
523  pe->invalidateConnections(true);
524  // new on right
525  unsigned int rightMostP = currLanes[0];
526  unsigned int rightMostN = newLanes[0];
527  for (int l = 0; l < (int) rightMostP - (int) rightMostN; ++l) {
528  pe->addLane2LaneConnection(0, ne, l, NBEdge::L2L_VALIDATED, true);
529  }
530  // new on left
531  unsigned int leftMostP = currLanes.back();
532  unsigned int leftMostN = newLanes.back();
533  for (int l = 0; l < (int) leftMostN - (int) leftMostP; ++l) {
534  pe->addLane2LaneConnection(pe->getNumLanes() - 1, ne, leftMostN - l - rightMostN, NBEdge::L2L_VALIDATED, true);
535  }
536  // all other connected
537  for (unsigned int l = 0; l < noLanesMax; ++l) {
538  if (find(currLanes.begin(), currLanes.end(), l) == currLanes.end()) {
539  continue;
540  }
541  if (find(newLanes.begin(), newLanes.end(), l) == newLanes.end()) {
542  continue;
543  }
544  pe->addLane2LaneConnection(l - rightMostP, ne, l - rightMostN, NBEdge::L2L_VALIDATED, true);
545  }
546  // move to next
547  e = ne;
548  currLanes = newLanes;
549  } else {
550  WRITE_WARNING("Error on parsing a split (edge '" + myCurrentID + "').");
551  }
552  } else if (exp.pos == 0) {
553  if (e->getNumLanes() < exp.lanes.size()) {
554  e->incLaneNo((int) exp.lanes.size() - e->getNumLanes());
555  } else {
556  e->decLaneNo(e->getNumLanes() - (int) exp.lanes.size());
557  }
558  currLanes = exp.lanes;
559  // invalidate traffic light definition loaded from a SUMO network
560  // XXX it would be preferable to reconstruct the phase definitions heuristically
562  } else {
563  WRITE_WARNING("Split at '" + toString(exp.pos) + "' lies beyond the edge's length (edge '" + myCurrentID + "').");
564  }
565  }
566  // patch lane offsets
567  e = myEdgeCont.retrieve(edgeid);
568  i = mySplits.begin();
569  if ((*i).pos != 0) {
570  e = e->getToNode()->getOutgoingEdges()[0];
571  }
572  for (; i != mySplits.end(); ++i) {
573  unsigned int maxLeft = (*i).lanes.back();
574  SUMOReal offset = 0;
575  if (maxLeft < noLanesMax) {
577  offset = SUMO_const_laneWidthAndOffset * (noLanesMax - 1 - maxLeft);
578  } else {
579  offset = SUMO_const_halfLaneAndOffset * (noLanesMax - 1 - maxLeft);
580  }
581  }
582  unsigned int maxRight = (*i).lanes.front();
583  if (maxRight > 0 && e->getLaneSpreadFunction() == LANESPREAD_CENTER) {
584  offset -= SUMO_const_halfLaneAndOffset * maxRight;
585  }
586  if (offset != 0) {
587  PositionVector g = e->getGeometry();
588  g.move2side(offset);
589  e->setGeometry(g);
590  }
591  if (e->getToNode()->getOutgoingEdges().size() != 0) {
592  e = e->getToNode()->getOutgoingEdges()[0];
593  }
594  }
595  }
596  }
597 }
598 
599 
600 void
602  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
603  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
604  EdgeSet roundabout;
605  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
606  NBEdge* edge = myEdgeCont.retrieve(*it);
607  if (edge == 0) {
608  if (!myEdgeCont.wasIgnored(*it)) {
609  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
610  }
611  } else {
612  roundabout.insert(edge);
613  }
614  }
615  myEdgeCont.addRoundabout(roundabout);
616  } else {
617  WRITE_ERROR("Empty edges in roundabout.");
618  }
619 }
620 
621 
622 
623 /****************************************************************************/
624 
void invalidateConnections(bool reallowSetting=false)
Definition: NBEdge.cpp:863
The information about how to spread the lanes from the given position.
const std::string & getTypeID() const
Definition: NBEdge.h:885
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:201
LaneSpreadFunction myLanesSpread
Information about how to spread the lanes.
Finds a split at the given position.
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
int nameid
A numerical id.
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
Definition: NBEdge.cpp:379
std::string myCurrentID
The current edge&#39;s id.
const SUMOReal SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:51
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
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:2066
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2112
void addRoundabout(const SUMOSAXAttributes &attrs)
Parses a roundabout and stores it in myEdgeCont.
const SUMOReal SUMO_const_laneWidthAndOffset
Definition: StdDefs.h:50
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:2237
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
void incLaneNo(unsigned int by)
Definition: NBEdge.cpp:1979
NBNode * myFromNode
The nodes the edge starts and ends at.
const SUMOReal SUMOXML_INVALID_POSITION
A container for districts.
NIXMLEdgesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false)
Adds a connection between the specified this edge&#39;s lane and an approached one.
Definition: NBEdge.cpp:628
T MAX2(T a, T b)
Definition: StdDefs.h:74
bool myHaveReportedAboutOverwriting
Information whether at least one edge&#39;s attributes were overwritten.
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
Definition: NBEdge.h:446
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:2128
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:391
NBDistrictCont & myDistrictCont
The districts container (needed if an edge must be split)
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:203
SAX-handler base for SUMO-files.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge&#39;s geometry
Definition: NBEdge.cpp:392
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:134
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The connection was computed and validated.
Definition: NBEdge.h:116
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
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 &quot;myCurrentEdge&quot;.
~NIXMLEdgesHandler()
Destructor.
SUMOReal getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:140
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges.
Definition: NBNode.h:252
SUMOReal getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:412
const std::string & getID() const
Returns the id.
Definition: Named.h:60
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:104
std::vector< Split > mySplits
The list of this edge&#39;s splits.
std::set< NBEdge * > EdgeSet
Definition: NBCont.h:51
the edges of a route
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:352
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:158
bool myHaveWarnedAboutDeprecatedLaneId
Encapsulated SAX-Attributes.
SUMOReal speed
The speed after this change.
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:367
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:98
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...
unsigned int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:344
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:110
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Definition: NBEdge.h:420
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.
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)
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) ...
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:80
LaneSpreadFunction tryGetLaneSpread(const SUMOSAXAttributes &attrs)
Tries to parse the spread type.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
void setLoadedLength(SUMOReal val)
Definition: NBEdge.cpp:2171
SUMOReal getEndOffset() const
Returns the offset to the destination node.
Definition: NBEdge.h:471
virtual std::vector< std::string > getStringVector(int attr) const =0
Tries to read given attribute assuming it is a string vector.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:2156
SUMOReal length() const
Returns the length.
static int _2int(const E *const data)
Definition: TplConvert.h:114
void decLaneNo(unsigned int by, int dir=0)
Definition: NBEdge.cpp:1994
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:368
SVCPermissions myPermissions
Information about lane permissions.
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:245
SUMOReal myCurrentSpeed
The current edge&#39;s maximum speed.
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
Definition: NBEdge.h:207
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
Definition: NBEdge.cpp:2142
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:521
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
void myEndElement(int element)
Called when a closing tag occurs.
A storage for options typed value containers)
Definition: OptionsCont.h:108
NBEdge * myCurrentEdge
The currently processed edge.
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:360
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:79
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:597
Represents a single node (junction) during network building.
Definition: NBNode.h:75
Position gpos
A 2D-position (for the node to insert at this place)
T get(const std::string &str) const
void move2side(SUMOReal amount)
void setEndOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2096
#define SUMOReal
Definition: config.h:218
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:463
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:108
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:128
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:428
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:64
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
Definition: NBEdgeCont.cpp:897
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
void invalidateTLS(NBTrafficLightLogicCont &tlCont)
causes the traffic light to be computed anew
Definition: NBNode.cpp:328
const std::string & getStreetName() const
Returns the street name of this edge.
Definition: NBEdge.h:458
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and modifies myCurrentEdge according to the given attribures.
int myCurrentPriority
The current edge&#39;s priority.
void reinit(NBNode *from, NBNode *to, const std::string &type, SUMOReal speed, unsigned 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:258
A storage for available types of edges.
Definition: NBTypeCont.h:56
PositionVector tryGetShape(const SUMOSAXAttributes &attrs)
Tries to parse the shape definition.
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:360