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-2016 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_SPLIT:
100  addSplit(attrs);
101  break;
102  case SUMO_TAG_DELETE:
103  deleteEdge(attrs);
104  break;
105  case SUMO_TAG_ROUNDABOUT:
106  addRoundabout(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
132  if (myCurrentEdge != 0) {
133  // update existing edge. only update lane-specific settings when explicitly requested
134  myIsUpdate = true;
138  } else {
139  // this is a completely new edge. get the type specific defaults
143  }
144  myCurrentType = "";
148  myCurrentStreetName = "";
149  myReinitKeepEdgeShape = false;
152  // check whether a type's values shall be used
153  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
154  myCurrentType = attrs.get<std::string>(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok);
155  if (!ok) {
156  return;
157  }
158  if (!myTypeCont.knows(myCurrentType) && !myOptions.getBool("ignore-errors.edge-type")) {
159  WRITE_ERROR("Type '" + myCurrentType + "' used by edge '" + myCurrentID + "' was not defined (ignore with option --ignore-errors.edge-type).");
160  return;
161  }
169  }
170  // use values from the edge to overwrite if existing, then
171  if (myIsUpdate) {
173  WRITE_MESSAGE("Duplicate edge id occurred ('" + myCurrentID + "'); assuming overwriting is wished.");
175  }
178  WRITE_MESSAGE("Edge '" + myCurrentID + "' changed it's type; assuming type override is wished.");
180  }
181  }
182  if (attrs.getOpt<bool>(SUMO_ATTR_REMOVE, myCurrentID.c_str(), ok, false)) {
184  myCurrentEdge = 0;
185  return;
186  }
191  myReinitKeepEdgeShape = true;
192  }
196  }
198  }
199  // speed, priority and the number of lanes have now default values;
200  // try to read the real values from the file
201  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
202  myCurrentSpeed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok);
203  }
204  if (myOptions.getBool("speed-in-kmh") && myCurrentSpeed != NBEdge::UNSPECIFIED_SPEED) {
206  }
207  // try to get the number of lanes
208  if (attrs.hasAttribute(SUMO_ATTR_NUMLANES)) {
209  myCurrentLaneNo = attrs.get<int>(SUMO_ATTR_NUMLANES, myCurrentID.c_str(), ok);
210  }
211  // try to get the priority
212  if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
213  myCurrentPriority = attrs.get<int>(SUMO_ATTR_PRIORITY, myCurrentID.c_str(), ok);
214  }
215  // try to get the width
216  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
217  myCurrentWidth = attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok);
218  }
219  // try to get the offset of the stop line from the intersection
220  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
222  }
223  // try to get the street name
224  if (attrs.hasAttribute(SUMO_ATTR_NAME)) {
225  myCurrentStreetName = attrs.get<std::string>(SUMO_ATTR_NAME, myCurrentID.c_str(), ok);
226  if (myCurrentStreetName != "" && myOptions.isDefault("output.street-names")) {
227  myOptions.set("output.street-names", "true");
228  }
229  }
230 
231  // try to get the allowed/disallowed classes
233  std::string allowS = attrs.hasAttribute(SUMO_ATTR_ALLOW) ? attrs.getStringSecure(SUMO_ATTR_ALLOW, "") : "";
234  std::string disallowS = attrs.hasAttribute(SUMO_ATTR_DISALLOW) ? attrs.getStringSecure(SUMO_ATTR_DISALLOW, "") : "";
235  // XXX matter of interpretation: should updated permissions replace or extend previously set permissions?
236  myPermissions = parseVehicleClasses(allowS, disallowS);
237  }
238  // try to set the nodes
239  if (!setNodes(attrs)) {
240  // return if this failed
241  return;
242  }
243  // try to get the shape
244  myShape = tryGetShape(attrs);
245  // try to get the spread type
247  // try to get the length
249  // try to get the sidewalkWidth
251  // try to get the bikeLaneWidth
253  // insert the parsed edge into the edges map
254  if (!ok) {
255  return;
256  }
257  // check whether a previously defined edge shall be overwritten
258  if (myCurrentEdge != 0) {
264  } else {
265  // the edge must be allocated in dependence to whether a shape is given
266  if (myShape.size() == 0) {
270  } else {
275  }
276  }
280  }
281 }
282 
283 
284 void
286  if (myCurrentEdge == 0) {
287  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
288  WRITE_ERROR("Additional lane information could not be set - the edge with id '" + myCurrentID + "' is not known.");
289  }
290  return;
291  }
292  bool ok = true;
293  int lane;
294  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
295  lane = attrs.get<int>(SUMO_ATTR_ID, myCurrentID.c_str(), ok);
298  WRITE_WARNING("'" + toString(SUMO_ATTR_ID) + "' is deprecated, please use '" + toString(SUMO_ATTR_INDEX) + "' instead.");
299  }
300  } else {
301  lane = attrs.get<int>(SUMO_ATTR_INDEX, myCurrentID.c_str(), ok);
302  }
303  std::string allowed, disallowed, preferred;
304  allowed = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, 0, ok, "");
305  disallowed = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, 0, ok, "");
306  preferred = attrs.getOpt<std::string>(SUMO_ATTR_PREFER, 0, ok, "");
307  if (!ok) {
308  return;
309  }
310  // check whether this lane exists
311  if (lane >= (int) myCurrentEdge->getNumLanes()) {
312  WRITE_ERROR("Lane index is larger than number of lanes (edge '" + myCurrentID + "').");
313  return;
314  }
315  // set information about allowed / disallowed vehicle classes
316  myCurrentEdge->setPermissions(parseVehicleClasses(allowed, disallowed), lane);
318  // try to get the width
319  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
320  myCurrentEdge->setLaneWidth(lane, attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok));
321  }
322  // try to get the end-offset (lane shortened due to pedestrian crossing etc..)
323  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
325  }
326  // try to get lane specific speed (should not occur for german networks)
327  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
328  myCurrentEdge->setSpeed(lane, attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok));
329  }
330 }
331 
332 
334  if (myCurrentEdge == 0) {
335  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
336  WRITE_WARNING("Ignoring 'split' because it cannot be assigned to an edge");
337  }
338  return;
339  }
340  bool ok = true;
341  Split e;
342  e.pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok);
343  if (ok) {
344  if (fabs(e.pos) > myCurrentEdge->getGeometry().length()) {
345  WRITE_ERROR("Edge '" + myCurrentID + "' has a split at invalid position " + toString(e.pos) + ".");
346  return;
347  }
348  std::vector<Split>::iterator i = find_if(mySplits.begin(), mySplits.end(), split_by_pos_finder(e.pos));
349  if (i != mySplits.end()) {
350  WRITE_ERROR("Edge '" + myCurrentID + "' has already a split at position " + toString(e.pos) + ".");
351  return;
352  }
353  const std::string nameid = toString((int)e.pos);
354  if (e.pos < 0) {
356  }
357  std::vector<std::string> lanes;
358  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LANES, 0, ok, ""), lanes);
359  for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) {
360  try {
361  int lane = TplConvert::_2int((*i).c_str());
362  e.lanes.push_back(lane);
363  } catch (NumberFormatException&) {
364  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
365  } catch (EmptyData&) {
366  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
367  }
368  }
369  if (e.lanes.empty()) {
370  for (size_t l = 0; l < myCurrentEdge->getNumLanes(); ++l) {
371  e.lanes.push_back((int) l);
372  }
373  }
374  e.speed = attrs.getOpt(SUMO_ATTR_SPEED, 0, ok, myCurrentEdge->getSpeed());
375  if (attrs.hasAttribute(SUMO_ATTR_SPEED) && myOptions.getBool("speed-in-kmh")) {
376  e.speed /= (SUMOReal) 3.6;
377  }
378  if (!ok) {
379  return;
380  }
381  e.node = new NBNode(myCurrentID + "." + nameid,
385  mySplits.push_back(e);
386  }
387 }
388 
389 
390 bool
392  // the names and the coordinates of the beginning and the end node
393  // may be found, try
394  bool ok = true;
395  std::string begNodeID = myIsUpdate ? myCurrentEdge->getFromNode()->getID() : "";
396  std::string endNodeID = myIsUpdate ? myCurrentEdge->getToNode()->getID() : "";
397  std::string oldBegID = begNodeID;
398  std::string oldEndID = endNodeID;
399  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
400  begNodeID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
401  } else if (!myIsUpdate) {
402  WRITE_ERROR("The from-node is not given for edge '" + myCurrentID + "'.");
403  ok = false;
404  }
405  if (attrs.hasAttribute(SUMO_ATTR_TO)) {
406  endNodeID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
407  } else if (!myIsUpdate) {
408  WRITE_ERROR("The to-node is not given for edge '" + myCurrentID + "'.");
409  ok = false;
410  }
411  if (!ok) {
412  return false;
413  }
414  myFromNode = myNodeCont.retrieve(begNodeID);
415  myToNode = myNodeCont.retrieve(endNodeID);
416  if (myFromNode == 0) {
417  WRITE_ERROR("Edge's '" + myCurrentID + "' from-node '" + begNodeID + "' is not known.");
418  }
419  if (myToNode == 0) {
420  WRITE_ERROR("Edge's '" + myCurrentID + "' to-node '" + endNodeID + "' is not known.");
421  }
422  if (myFromNode != 0 && myToNode != 0) {
423  if (myIsUpdate && (myFromNode->getID() != oldBegID || myToNode->getID() != oldEndID)) {
425  }
426  }
427  return myFromNode != 0 && myToNode != 0;
428 }
429 
430 
433  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
434  return myShape;
435  }
436  // try to build shape
437  bool ok = true;
438  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
439  myReinitKeepEdgeShape = false;
440  return PositionVector();
441  }
444  WRITE_ERROR("Unable to project coordinates for edge '" + myCurrentID + "'.");
445  }
447  return shape;
448 }
449 
450 
453  bool ok = true;
455  std::string lsfS = toString(result);
456  lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, myCurrentID.c_str(), ok, lsfS);
457  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
459  } else {
460  WRITE_WARNING("Ignoring unknown spreadType '" + lsfS + "' for edge '" + myCurrentID + "'.");
461  }
462  return result;
463 }
464 
465 
466 void
468  bool ok = true;
469  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
470  if (!ok) {
471  return;
472  }
474  if (edge == 0) {
475  WRITE_WARNING("Ignoring tag '" + toString(SUMO_TAG_DELETE) + "' for unknown edge '" +
476  myCurrentID + "'");
477  return;
478  }
479  myEdgeCont.extract(myDistrictCont, edge, true);
480 }
481 
482 
483 void
485  if (element == SUMO_TAG_EDGE && myCurrentEdge != 0) {
486  // add bike lane, wait until lanes are loaded to avoid building if it already exists
489  }
490  // add sidewalk, wait until lanes are loaded to avoid building if it already exists
493  }
494  if (!myIsUpdate) {
495  try {
497  WRITE_ERROR("Duplicate edge occured. ID='" + myCurrentID + "'");
498  delete myCurrentEdge;
499  }
500  } catch (InvalidArgument& e) {
501  WRITE_ERROR(e.what());
502  throw;
503  } catch (...) {
504  WRITE_ERROR("An important information is missing in edge '" + myCurrentID + "'.");
505  }
506  }
507  if (mySplits.size() != 0) {
508  std::vector<Split>::iterator i;
509  NBEdge* e = myCurrentEdge;
510  sort(mySplits.begin(), mySplits.end(), split_sorter());
511  unsigned int noLanesMax = e->getNumLanes();
512  // compute the node positions and sort the lanes
513  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
514  sort((*i).lanes.begin(), (*i).lanes.end());
515  noLanesMax = MAX2(noLanesMax, (unsigned int)(*i).lanes.size());
516  }
517  // split the edge
518  std::vector<int> currLanes;
519  for (unsigned int l = 0; l < e->getNumLanes(); ++l) {
520  currLanes.push_back(l);
521  }
522  if (e->getNumLanes() != mySplits.back().lanes.size()) {
523  // invalidate traffic light definitions loaded from a SUMO network
524  // XXX it would be preferable to reconstruct the phase definitions heuristically
526  // if the number of lanes changes the connections should be
527  // recomputed
528  e->invalidateConnections(true);
529  }
530 
531  std::string edgeid = e->getID();
532  SUMOReal seen = 0;
533  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
534  const Split& exp = *i;
535  assert(exp.lanes.size() != 0);
536  if (exp.pos > 0 && e->getGeometry().length() + seen > exp.pos && exp.pos > seen) {
537  if (myNodeCont.insert(exp.node)) {
539  // split the edge
540  std::string pid = e->getID();
541  myEdgeCont.splitAt(myDistrictCont, e, exp.pos - seen, exp.node,
542  pid, exp.node->getID(), e->getNumLanes(), (unsigned int) exp.lanes.size(), exp.speed);
543  seen = exp.pos;
544  std::vector<int> newLanes = exp.lanes;
545  NBEdge* pe = myEdgeCont.retrieve(pid);
546  NBEdge* ne = myEdgeCont.retrieve(exp.node->getID());
547  // reconnect lanes
548  pe->invalidateConnections(true);
549  // new on right
550  unsigned int rightMostP = currLanes[0];
551  unsigned int rightMostN = newLanes[0];
552  for (int l = 0; l < (int) rightMostP - (int) rightMostN; ++l) {
553  pe->addLane2LaneConnection(0, ne, l, NBEdge::L2L_VALIDATED, true);
554  }
555  // new on left
556  unsigned int leftMostP = currLanes.back();
557  unsigned int leftMostN = newLanes.back();
558  for (int l = 0; l < (int) leftMostN - (int) leftMostP; ++l) {
559  pe->addLane2LaneConnection(pe->getNumLanes() - 1, ne, leftMostN - l - rightMostN, NBEdge::L2L_VALIDATED, true);
560  }
561  // all other connected
562  for (unsigned int l = 0; l < noLanesMax; ++l) {
563  if (find(currLanes.begin(), currLanes.end(), l) == currLanes.end()) {
564  continue;
565  }
566  if (find(newLanes.begin(), newLanes.end(), l) == newLanes.end()) {
567  continue;
568  }
569  pe->addLane2LaneConnection(l - rightMostP, ne, l - rightMostN, NBEdge::L2L_VALIDATED, true);
570  }
571  // move to next
572  e = ne;
573  currLanes = newLanes;
574  } else {
575  WRITE_WARNING("Error on parsing a split (edge '" + myCurrentID + "').");
576  }
577  } else if (exp.pos == 0) {
578  if (e->getNumLanes() < exp.lanes.size()) {
579  e->incLaneNo((int) exp.lanes.size() - e->getNumLanes());
580  } else {
581  e->decLaneNo(e->getNumLanes() - (int) exp.lanes.size());
582  }
583  currLanes = exp.lanes;
584  // invalidate traffic light definition loaded from a SUMO network
585  // XXX it would be preferable to reconstruct the phase definitions heuristically
587  } else {
588  WRITE_WARNING("Split at '" + toString(exp.pos) + "' lies beyond the edge's length (edge '" + myCurrentID + "').");
589  }
590  }
591  // patch lane offsets
592  e = myEdgeCont.retrieve(edgeid);
593  if (mySplits.front().pos != 0) {
594  // add a dummy split at the beginning to ensure correct offset
595  Split start;
596  start.pos = 0;
597  for (int lane = 0; lane < (int)e->getNumLanes(); ++lane) {
598  start.lanes.push_back(lane);
599  }
600  mySplits.insert(mySplits.begin(), start);
601  }
602  i = mySplits.begin();
603  for (; i != mySplits.end(); ++i) {
604  unsigned int maxLeft = (*i).lanes.back();
605  SUMOReal offset = 0;
606  if (maxLeft < noLanesMax) {
608  offset = SUMO_const_laneWidthAndOffset * (noLanesMax - 1 - maxLeft);
609  } else {
610  offset = SUMO_const_halfLaneAndOffset * (noLanesMax - 1 - maxLeft);
611  }
612  }
613  unsigned int maxRight = (*i).lanes.front();
614  if (maxRight > 0 && e->getLaneSpreadFunction() == LANESPREAD_CENTER) {
615  offset -= SUMO_const_halfLaneAndOffset * maxRight;
616  }
617  if (offset != 0) {
618  PositionVector g = e->getGeometry();
619  g.move2side(offset);
620  e->setGeometry(g);
621  }
622  if (e->getToNode()->getOutgoingEdges().size() != 0) {
623  e = e->getToNode()->getOutgoingEdges()[0];
624  }
625  }
626  }
627  }
628 }
629 
630 
631 void
633  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
634  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
635  EdgeSet roundabout;
636  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
637  NBEdge* edge = myEdgeCont.retrieve(*it);
638  if (edge == 0) {
639  if (!myEdgeCont.wasIgnored(*it)) {
640  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
641  }
642  } else {
643  roundabout.insert(edge);
644  }
645  }
646  myEdgeCont.addRoundabout(roundabout);
647  } else {
648  WRITE_ERROR("Empty edges in roundabout.");
649  }
650 }
651 
652 
653 
654 /****************************************************************************/
655 
void invalidateConnections(bool reallowSetting=false)
Definition: NBEdge.cpp:949
The information about how to spread the lanes from the given position.
const std::string & getTypeID() const
Definition: NBEdge.h:907
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...
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
Definition: NBEdge.cpp:423
std::string myCurrentID
The current edge&#39;s id.
const SUMOReal SUMO_const_halfLaneAndOffset
Definition: StdDefs.h:54
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
void markAsSplit(const NBNode *node)
mark a node as being created form a split
Definition: NBNodeCont.h:326
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:2294
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:2349
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:53
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:2478
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:70
void incLaneNo(unsigned int by)
Definition: NBEdge.cpp:2210
NBNode * myFromNode
The nodes the edge starts and ends at.
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, SUMOReal contPos=UNSPECIFIED_CONTPOS)
Adds a connection between the specified this edge&#39;s lane and an approached one.
Definition: NBEdge.cpp:684
A container for districts.
static const SUMOReal UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:205
NIXMLEdgesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
T MAX2(T a, T b)
Definition: StdDefs.h:75
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:2365
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:411
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:436
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:217
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The connection was computed and validated.
Definition: NBEdge.h:115
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
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:223
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges.
Definition: NBNode.h:248
SUMOReal getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:413
const std::string & getID() const
Returns the id.
Definition: Named.h:65
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
const Position & getPosition() const
Returns the position of this node.
Definition: NBNode.h:228
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:181
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:229
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:353
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:161
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:387
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:175
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:345
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:187
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Definition: NBEdge.h:423
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) ...
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:75
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:54
void setLoadedLength(SUMOReal val)
Definition: NBEdge.cpp:2408
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: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:2484
void decLaneNo(unsigned int by)
Definition: NBEdge.cpp:2236
static int _2int(const E *const data)
Definition: TplConvert.h:114
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:369
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:246
SUMOReal myCurrentSpeed
The current edge&#39;s maximum speed.
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
Definition: NBEdge.h:210
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
Definition: NBEdge.cpp:2379
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:523
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:380
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:80
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:603
Represents a single node (junction) during network building.
Definition: NBNode.h:74
T get(const std::string &str) const
void move2side(SUMOReal amount)
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:2333
#define SUMOReal
Definition: config.h:213
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:464
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:109
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:211
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:431
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:949
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
void invalidateTLS(NBTrafficLightLogicCont &tlCont)
causes the traffic light to be computed anew
Definition: NBNode.cpp:352
const std::string & getStreetName() const
Returns the street name of this edge.
Definition: NBEdge.h:465
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
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:266
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:361