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-sim.org/
14 // Copyright (C) 2001-2013 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  default:
109  break;
110  }
111 }
112 
113 
114 void
116  myIsUpdate = false;
117  bool ok = true;
118  // initialise the edge
119  myCurrentEdge = 0;
120  mySplits.clear();
121  // get the id, report an error if not given or empty...
122  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
123  if (!ok) {
124  return;
125  }
127  // check deprecated (unused) attributes
128  // use default values, first
135  myCurrentType = "";
139  myCurrentStreetName = "";
140  myReinitKeepEdgeShape = false;
141  // check whether a type's values shall be used
142  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
143  myCurrentType = attrs.get<std::string>(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok);
144  if (!ok) {
145  return;
146  }
147  if (!myTypeCont.knows(myCurrentType) && !myOptions.getBool("ignore-errors.edge-type")) {
148  WRITE_ERROR("Type '" + myCurrentType + "' used by edge '" + myCurrentID + "' was not defined (ignore with option --ignore-errors.edge-type).");
149  return;
150  }
156  }
157  // use values from the edge to overwrite if existing, then
158  if (myCurrentEdge != 0) {
159  myIsUpdate = true;
161  WRITE_MESSAGE("Duplicate edge id occured ('" + myCurrentID + "'); assuming overwriting is wished.");
163  }
164  if (attrs.getOpt<bool>(SUMO_ATTR_REMOVE, myCurrentID.c_str(), ok, false)) {
166  myCurrentEdge = 0;
167  return;
168  }
176  myReinitKeepEdgeShape = true;
177  }
183  }
185  }
186  // speed, priority and the number of lanes have now default values;
187  // try to read the real values from the file
188  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
189  myCurrentSpeed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok);
190  }
191  if (myOptions.getBool("speed-in-kmh")) {
193  }
194  // try to get the number of lanes
195  if (attrs.hasAttribute(SUMO_ATTR_NUMLANES)) {
196  myCurrentLaneNo = attrs.get<int>(SUMO_ATTR_NUMLANES, myCurrentID.c_str(), ok);
197  }
198  // try to get the priority
199  if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
200  myCurrentPriority = attrs.get<int>(SUMO_ATTR_PRIORITY, myCurrentID.c_str(), ok);
201  }
202  // try to get the width
203  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
204  myCurrentWidth = attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok);
205  }
206  // try to get the width
207  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
209  }
210  // try to get the street name
211  if (attrs.hasAttribute(SUMO_ATTR_NAME)) {
212  myCurrentStreetName = attrs.get<std::string>(SUMO_ATTR_NAME, myCurrentID.c_str(), ok);
213  if (myCurrentStreetName != "" && myOptions.isDefault("output.street-names")) {
214  myOptions.set("output.street-names", "true");
215  }
216  }
217 
218  // try to get the allowed/disallowed classes
220  std::string allowS = attrs.hasAttribute(SUMO_ATTR_ALLOW) ? attrs.getStringSecure(SUMO_ATTR_ALLOW, "") : "";
221  std::string disallowS = attrs.hasAttribute(SUMO_ATTR_DISALLOW) ? attrs.getStringSecure(SUMO_ATTR_DISALLOW, "") : "";
222  // XXX matter of interpretation: should updated permissions replace or extend previously set permissions?
223  myPermissions = parseVehicleClasses(allowS, disallowS);
224  }
225  // try to set the nodes
226  if (!setNodes(attrs)) {
227  // return if this failed
228  return;
229  }
230  // try to get the shape
231  myShape = tryGetShape(attrs);
232  // try to get the spread type
234  // try to get the length
236  // insert the parsed edge into the edges map
237  if (!ok) {
238  return;
239  }
240  // check whether a previously defined edge shall be overwritten
241  if (myCurrentEdge != 0) {
247  } else {
248  // the edge must be allocated in dependence to whether a shape is given
249  if (myShape.size() == 0) {
253  } else {
258  }
259  }
262 }
263 
264 
265 void
267  if (myCurrentEdge == 0) {
268  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
269  WRITE_ERROR("Additional lane information could not be set - the edge with id '" + myCurrentID + "' is not known.");
270  }
271  return;
272  }
273  bool ok = true;
274  int lane;
275  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
276  lane = attrs.get<int>(SUMO_ATTR_ID, myCurrentID.c_str(), ok);
279  WRITE_WARNING("'" + toString(SUMO_ATTR_ID) + "' is deprecated, please use '" + toString(SUMO_ATTR_INDEX) + "' instead.");
280  }
281  } else {
282  lane = attrs.get<int>(SUMO_ATTR_INDEX, myCurrentID.c_str(), ok);
283  }
284  std::string allowed, disallowed, preferred;
285  allowed = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, 0, ok, "");
286  disallowed = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, 0, ok, "");
287  preferred = attrs.getOpt<std::string>(SUMO_ATTR_PREFER, 0, ok, "");
288  if (!ok) {
289  return;
290  }
291  // check whether this lane exists
292  if (lane >= (int) myCurrentEdge->getNumLanes()) {
293  WRITE_ERROR("Lane index is larger than number of lanes (edge '" + myCurrentID + "').");
294  return;
295  }
296  // set information about allowed / disallowed vehicle classes
297  myCurrentEdge->setPermissions(parseVehicleClasses(allowed, disallowed), lane);
299  // try to get the width
300  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
301  myCurrentEdge->setLaneWidth(lane, attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok));
302  }
303  // try to get the end-offset (lane shortened due to pedestrian crossing etc..)
304  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
305  myCurrentEdge->setOffset(lane, attrs.get<SUMOReal>(SUMO_ATTR_ENDOFFSET, myCurrentID.c_str(), ok));
306  }
307  // try to get lane specific speed (should not occur for german networks)
308  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
309  myCurrentEdge->setSpeed(lane, attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok));
310  }
311 }
312 
313 
315  if (myCurrentEdge == 0) {
316  WRITE_WARNING("Ignoring 'split' because it cannot be assigned to an edge");
317  return;
318  }
319  bool ok = true;
320  Split e;
321  e.pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok);
322  if (ok) {
323  if (fabs(e.pos) > myCurrentEdge->getGeometry().length()) {
324  WRITE_ERROR("Edge '" + myCurrentID + "' has a split at invalid position " + toString(e.pos) + ".");
325  return;
326  }
327  std::vector<Split>::iterator i = find_if(mySplits.begin(), mySplits.end(), split_by_pos_finder(e.pos));
328  if (i != mySplits.end()) {
329  WRITE_ERROR("Edge '" + myCurrentID + "' has already a split at position " + toString(e.pos) + ".");
330  return;
331  }
332  e.nameid = (int)e.pos;
333  if (myCurrentEdge == 0) {
334  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
335  WRITE_ERROR("Additional lane information could not be set - the edge with id '" + myCurrentID + "' is not known.");
336  }
337  return;
338  }
339  if (e.pos < 0) {
341  }
342  std::vector<std::string> lanes;
343  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LANES, 0, ok, ""), lanes);
344  for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) {
345  try {
346  int lane = TplConvert::_2int((*i).c_str());
347  e.lanes.push_back(lane);
348  } catch (NumberFormatException&) {
349  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
350  } catch (EmptyData&) {
351  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
352  }
353  }
354  if (e.lanes.empty()) {
355  for (size_t l = 0; l < myCurrentEdge->getNumLanes(); ++l) {
356  e.lanes.push_back((int) l);
357  }
358  }
359  mySplits.push_back(e);
360  }
361 }
362 
363 
364 bool
366  // the names and the coordinates of the beginning and the end node
367  // may be found, try
368  bool ok = true;
369  std::string begNodeID = myIsUpdate ? myCurrentEdge->getFromNode()->getID() : "";
370  std::string endNodeID = myIsUpdate ? myCurrentEdge->getToNode()->getID() : "";
371  std::string oldBegID = begNodeID;
372  std::string oldEndID = endNodeID;
373  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
374  begNodeID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
375  } else if (!myIsUpdate) {
376  WRITE_ERROR("The from-node is not given for edge '" + myCurrentID + "'.");
377  ok = false;
378  }
379  if (attrs.hasAttribute(SUMO_ATTR_TO)) {
380  endNodeID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
381  } else if (!myIsUpdate) {
382  WRITE_ERROR("The to-node is not given for edge '" + myCurrentID + "'.");
383  ok = false;
384  }
385  if (!ok) {
386  return false;
387  }
388  myFromNode = myNodeCont.retrieve(begNodeID);
389  myToNode = myNodeCont.retrieve(endNodeID);
390  if (myFromNode == 0) {
391  WRITE_ERROR("Edge's '" + myCurrentID + "' from-node '" + begNodeID + "' is not known.");
392  }
393  if (myToNode == 0) {
394  WRITE_ERROR("Edge's '" + myCurrentID + "' to-node '" + endNodeID + "' is not known.");
395  }
396  if (myFromNode != 0 && myToNode != 0) {
397  if (myIsUpdate && (myFromNode->getID() != oldBegID || myToNode->getID() != oldEndID)) {
399  }
400  }
401  return myFromNode != 0 && myToNode != 0;
402 }
403 
404 
407  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
408  return myShape;
409  }
410  // try to build shape
411  bool ok = true;
412  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
413  myReinitKeepEdgeShape = false;
414  return PositionVector();
415  }
418  WRITE_ERROR("Unable to project coordinates for edge '" + myCurrentID + "'.");
419  }
421  return shape;
422 }
423 
424 
427  bool ok = true;
429  std::string lsfS = toString(result);
430  lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, myCurrentID.c_str(), ok, lsfS);
431  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
433  } else {
434  WRITE_WARNING("Ignoring unknown spreadType '" + lsfS + "' for edge '" + myCurrentID + "'.");
435  }
436  return result;
437 }
438 
439 
440 void
442  bool ok = true;
443  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
444  if (!ok) {
445  return;
446  }
448  if (edge == 0) {
449  WRITE_WARNING("Ignoring tag '" + toString(SUMO_TAG_DELETE) + "' for unknown edge '" +
450  myCurrentID + "'");
451  return;
452  }
453  myEdgeCont.extract(myDistrictCont, edge, true);
454 }
455 
456 
457 void
459  if (element == SUMO_TAG_EDGE && myCurrentEdge != 0) {
460  if (!myIsUpdate) {
461  try {
463  WRITE_ERROR("Duplicate edge occured. ID='" + myCurrentID + "'");
464  delete myCurrentEdge;
465  }
466  } catch (InvalidArgument& e) {
467  WRITE_ERROR(e.what());
468  throw;
469  } catch (...) {
470  WRITE_ERROR("An important information is missing in edge '" + myCurrentID + "'.");
471  }
472  }
473  if (mySplits.size() != 0) {
474  std::vector<Split>::iterator i;
475  NBEdge* e = myCurrentEdge;
476  sort(mySplits.begin(), mySplits.end(), split_sorter());
477  unsigned int noLanesMax = e->getNumLanes();
478  // compute the node positions and sort the lanes
479  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
480  (*i).gpos = e->getGeometry().positionAtOffset((*i).pos);
481  sort((*i).lanes.begin(), (*i).lanes.end());
482  noLanesMax = MAX2(noLanesMax, (unsigned int)(*i).lanes.size());
483  }
484  // invalidate traffic light definitions loaded from a SUMO network
485  // XXX it would be preferable to reconstruct the phase definitions heuristically
487  e->invalidateConnections(true);
488 
489  // split the edge
490  std::vector<int> currLanes;
491  for (unsigned int l = 0; l < e->getNumLanes(); ++l) {
492  currLanes.push_back(l);
493  }
494  std::string edgeid = e->getID();
495  SUMOReal seen = 0;
496  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
497  const Split& exp = *i;
498  assert(exp.lanes.size() != 0);
499  if (exp.pos > 0 && e->getGeometry().length() + seen > exp.pos && exp.pos > seen) {
500  std::string nid = edgeid + "." + toString(exp.nameid);
501  NBNode* rn = new NBNode(nid, exp.gpos);
502  if (myNodeCont.insert(rn)) {
503  // split the edge
504  std::string nid = myCurrentID + "." + toString(exp.nameid);
505  std::string pid = e->getID();
506  myEdgeCont.splitAt(myDistrictCont, e, exp.pos - seen, rn,
507  pid, nid, e->getNumLanes(), (unsigned int) exp.lanes.size());
508  seen = exp.pos;
509  std::vector<int> newLanes = exp.lanes;
510  NBEdge* pe = myEdgeCont.retrieve(pid);
511  NBEdge* ne = myEdgeCont.retrieve(nid);
512  // reconnect lanes
513  pe->invalidateConnections(true);
514  // new on right
515  unsigned int rightMostP = currLanes[0];
516  unsigned int rightMostN = newLanes[0];
517  for (int l = 0; l < (int) rightMostP - (int) rightMostN; ++l) {
518  pe->addLane2LaneConnection(0, ne, l, NBEdge::L2L_VALIDATED, true);
519  }
520  // new on left
521  unsigned int leftMostP = currLanes.back();
522  unsigned int leftMostN = newLanes.back();
523  for (int l = 0; l < (int) leftMostN - (int) leftMostP; ++l) {
524  pe->addLane2LaneConnection(pe->getNumLanes() - 1, ne, leftMostN - l - rightMostN, NBEdge::L2L_VALIDATED, true);
525  }
526  // all other connected
527  for (unsigned int l = 0; l < noLanesMax; ++l) {
528  if (find(currLanes.begin(), currLanes.end(), l) == currLanes.end()) {
529  continue;
530  }
531  if (find(newLanes.begin(), newLanes.end(), l) == newLanes.end()) {
532  continue;
533  }
534  pe->addLane2LaneConnection(l - rightMostP, ne, l - rightMostN, NBEdge::L2L_VALIDATED, true);
535  }
536  // move to next
537  e = ne;
538  currLanes = newLanes;
539  } else {
540  WRITE_WARNING("Error on parsing a split (edge '" + myCurrentID + "').");
541  }
542  } else if (exp.pos == 0) {
543  if (e->getNumLanes() < exp.lanes.size()) {
544  e->incLaneNo((int) exp.lanes.size() - e->getNumLanes());
545  } else {
546  e->decLaneNo(e->getNumLanes() - (int) exp.lanes.size());
547  }
548  currLanes = exp.lanes;
549  // invalidate traffic light definition loaded from a SUMO network
550  // XXX it would be preferable to reconstruct the phase definitions heuristically
552  } else {
553  WRITE_WARNING("Split at '" + toString(exp.pos) + "' lies beyond the edge's length (edge '" + myCurrentID + "').");
554  }
555  }
556  // patch lane offsets
557  e = myEdgeCont.retrieve(edgeid);
558  i = mySplits.begin();
559  if ((*i).pos != 0) {
560  e = e->getToNode()->getOutgoingEdges()[0];
561  }
562  for (; i != mySplits.end(); ++i) {
563  unsigned int maxLeft = (*i).lanes.back();
564  SUMOReal offset = 0;
565  if (maxLeft < noLanesMax) {
567  offset = SUMO_const_laneWidthAndOffset * (noLanesMax - 1 - maxLeft);
568  } else {
569  offset = SUMO_const_halfLaneAndOffset * (noLanesMax - 1 - maxLeft);
570  }
571  }
572  unsigned int maxRight = (*i).lanes.front();
573  if (maxRight > 0 && e->getLaneSpreadFunction() == LANESPREAD_CENTER) {
574  offset -= SUMO_const_halfLaneAndOffset * maxRight;
575  }
576  if (offset != 0) {
577  PositionVector g = e->getGeometry();
578  g.move2side(offset);
579  e->setGeometry(g);
580  }
581  if (e->getToNode()->getOutgoingEdges().size() != 0) {
582  e = e->getToNode()->getOutgoingEdges()[0];
583  }
584  }
585  }
586  }
587 }
588 
589 /****************************************************************************/
590 
void invalidateConnections(bool reallowSetting=false)
Definition: NBEdge.cpp:843
The information about how to spread the lanes from the given position.
const std::string & getTypeID() const
Definition: NBEdge.h:854
LaneSpreadFunction myLanesSpread
Information about how to spread the lanes.
Finds a split at the given position.
bool insert(const std::string &id, const Position &position, NBDistrict *district)
Inserts a node into the map.
Definition: NBNodeCont.cpp:78
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
bool isInStringVector(const std::string &optionName, const std::string &itemName)
Returns the named option is a list of string values containing the specified item.
Position positionAtOffset(SUMOReal pos) const
Returns the position at the given length.
int nameid
A numerical id.
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
Definition: NBEdge.cpp:360
std::string myCurrentID
The current edge&#39;s id.
const SUMOReal SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:46
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:1982
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2028
void setOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2012
const SUMOReal SUMO_const_laneWidthAndOffset
Definition: StdDefs.h:45
bool setNodes(const SUMOSAXAttributes &attrs)
Sets from/to node information of the currently parsed edge.
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:1895
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:608
T MAX2(T a, T b)
Definition: StdDefs.h:63
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:435
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:2044
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:367
NBDistrictCont & myDistrictCont
The districts container (needed if an edge must be split)
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:198
SAX-handler base for SUMO-files.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge&#39;s geometry
Definition: NBEdge.cpp:373
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/s].
Definition: NBTypeCont.cpp:134
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:196
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.
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges.
Definition: NBNode.h:185
SUMOReal getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:401
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.
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:341
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:165
bool myHaveWarnedAboutDeprecatedLaneId
Encapsulated SAX-Attributes.
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:343
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 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:333
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:409
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
std::vector< int > lanes
The lanes until 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. ...
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:51
void setLoadedLength(SUMOReal val)
Definition: NBEdge.cpp:2087
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:201
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:2072
T get(const std::string &str)
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:1910
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:357
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:240
SUMOReal myCurrentSpeed
The current edge&#39;s maximum speed.
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
Definition: NBEdge.h:200
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
Definition: NBEdge.cpp:2058
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:494
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:336
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:570
Represents a single node (junction) during network building.
Definition: NBNode.h:74
Position gpos
A 2D-position (for the node to insert at this place)
void move2side(SUMOReal amount)
#define SUMOReal
Definition: config.h:221
SUMOReal myCurrentOffset
The current edge&#39;s offset till the destination node.
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.
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:129
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:417
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.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:197
void invalidateTLS(NBTrafficLightLogicCont &tlCont)
causes the traffic light to be computed anew
Definition: NBNode.cpp:296
const std::string & getStreetName() const
Returns the street name of this edge.
Definition: NBEdge.h:447
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and modifies myCurrentEdge according to the given attribures.
SUMOReal getOffset() const
Returns the offset to the destination node.
Definition: NBEdge.h:460
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:241
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:349