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-2015 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
135  if (myCurrentEdge != 0) {
136  // update existing edge. only update lane-specific settings when explicitly requested
140  } else {
141  // this is a completely new edge. get the type specific defaults
145  }
146  myCurrentType = "";
150  myCurrentStreetName = "";
151  myReinitKeepEdgeShape = false;
153  // check whether a type's values shall be used
154  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
155  myCurrentType = attrs.get<std::string>(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok);
156  if (!ok) {
157  return;
158  }
159  if (!myTypeCont.knows(myCurrentType) && !myOptions.getBool("ignore-errors.edge-type")) {
160  WRITE_ERROR("Type '" + myCurrentType + "' used by edge '" + myCurrentID + "' was not defined (ignore with option --ignore-errors.edge-type).");
161  return;
162  }
169  }
170  // use values from the edge to overwrite if existing, then
171  if (myCurrentEdge != 0) {
172  myIsUpdate = true;
174  WRITE_MESSAGE("Duplicate edge id occured ('" + myCurrentID + "'); assuming overwriting is wished.");
176  }
177  if (attrs.getOpt<bool>(SUMO_ATTR_REMOVE, myCurrentID.c_str(), ok, false)) {
179  myCurrentEdge = 0;
180  return;
181  }
187  myReinitKeepEdgeShape = true;
188  }
192  }
194  }
195  // speed, priority and the number of lanes have now default values;
196  // try to read the real values from the file
197  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
198  myCurrentSpeed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok);
199  }
200  if (myOptions.getBool("speed-in-kmh") && myCurrentSpeed != NBEdge::UNSPECIFIED_SPEED) {
202  }
203  // try to get the number of lanes
204  if (attrs.hasAttribute(SUMO_ATTR_NUMLANES)) {
205  myCurrentLaneNo = attrs.get<int>(SUMO_ATTR_NUMLANES, myCurrentID.c_str(), ok);
206  }
207  // try to get the priority
208  if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
209  myCurrentPriority = attrs.get<int>(SUMO_ATTR_PRIORITY, myCurrentID.c_str(), ok);
210  }
211  // try to get the width
212  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
213  myCurrentWidth = attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok);
214  }
215  // try to get the offset of the stop line from the intersection
216  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
218  }
219  // try to get the street name
220  if (attrs.hasAttribute(SUMO_ATTR_NAME)) {
221  myCurrentStreetName = attrs.get<std::string>(SUMO_ATTR_NAME, myCurrentID.c_str(), ok);
222  if (myCurrentStreetName != "" && myOptions.isDefault("output.street-names")) {
223  myOptions.set("output.street-names", "true");
224  }
225  }
226 
227  // try to get the allowed/disallowed classes
229  std::string allowS = attrs.hasAttribute(SUMO_ATTR_ALLOW) ? attrs.getStringSecure(SUMO_ATTR_ALLOW, "") : "";
230  std::string disallowS = attrs.hasAttribute(SUMO_ATTR_DISALLOW) ? attrs.getStringSecure(SUMO_ATTR_DISALLOW, "") : "";
231  // XXX matter of interpretation: should updated permissions replace or extend previously set permissions?
232  myPermissions = parseVehicleClasses(allowS, disallowS);
233  }
234  // try to set the nodes
235  if (!setNodes(attrs)) {
236  // return if this failed
237  return;
238  }
239  // try to get the shape
240  myShape = tryGetShape(attrs);
241  // try to get the spread type
243  // try to get the length
245  // tro to get the sidewalkWidth
247  // insert the parsed edge into the edges map
248  if (!ok) {
249  return;
250  }
251  // check whether a previously defined edge shall be overwritten
252  if (myCurrentEdge != 0) {
258  } else {
259  // the edge must be allocated in dependence to whether a shape is given
260  if (myShape.size() == 0) {
264  } else {
269  }
270  }
274  }
275 }
276 
277 
278 void
280  if (myCurrentEdge == 0) {
281  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
282  WRITE_ERROR("Additional lane information could not be set - the edge with id '" + myCurrentID + "' is not known.");
283  }
284  return;
285  }
286  bool ok = true;
287  int lane;
288  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
289  lane = attrs.get<int>(SUMO_ATTR_ID, myCurrentID.c_str(), ok);
292  WRITE_WARNING("'" + toString(SUMO_ATTR_ID) + "' is deprecated, please use '" + toString(SUMO_ATTR_INDEX) + "' instead.");
293  }
294  } else {
295  lane = attrs.get<int>(SUMO_ATTR_INDEX, myCurrentID.c_str(), ok);
296  }
297  std::string allowed, disallowed, preferred;
298  allowed = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, 0, ok, "");
299  disallowed = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, 0, ok, "");
300  preferred = attrs.getOpt<std::string>(SUMO_ATTR_PREFER, 0, ok, "");
301  if (!ok) {
302  return;
303  }
304  // check whether this lane exists
305  if (lane >= (int) myCurrentEdge->getNumLanes()) {
306  WRITE_ERROR("Lane index is larger than number of lanes (edge '" + myCurrentID + "').");
307  return;
308  }
309  // set information about allowed / disallowed vehicle classes
310  myCurrentEdge->setPermissions(parseVehicleClasses(allowed, disallowed), lane);
312  // try to get the width
313  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
314  myCurrentEdge->setLaneWidth(lane, attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok));
315  }
316  // try to get the end-offset (lane shortened due to pedestrian crossing etc..)
317  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
319  }
320  // try to get lane specific speed (should not occur for german networks)
321  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
322  myCurrentEdge->setSpeed(lane, attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok));
323  }
324 }
325 
326 
328  if (myCurrentEdge == 0) {
329  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
330  WRITE_WARNING("Ignoring 'split' because it cannot be assigned to an edge");
331  }
332  return;
333  }
334  bool ok = true;
335  Split e;
336  e.pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok);
337  if (ok) {
338  if (fabs(e.pos) > myCurrentEdge->getGeometry().length()) {
339  WRITE_ERROR("Edge '" + myCurrentID + "' has a split at invalid position " + toString(e.pos) + ".");
340  return;
341  }
342  std::vector<Split>::iterator i = find_if(mySplits.begin(), mySplits.end(), split_by_pos_finder(e.pos));
343  if (i != mySplits.end()) {
344  WRITE_ERROR("Edge '" + myCurrentID + "' has already a split at position " + toString(e.pos) + ".");
345  return;
346  }
347  e.nameid = (int)e.pos;
348  if (e.pos < 0) {
350  }
351  std::vector<std::string> lanes;
352  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LANES, 0, ok, ""), lanes);
353  for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) {
354  try {
355  int lane = TplConvert::_2int((*i).c_str());
356  e.lanes.push_back(lane);
357  } catch (NumberFormatException&) {
358  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
359  } catch (EmptyData&) {
360  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
361  }
362  }
363  if (e.lanes.empty()) {
364  for (size_t l = 0; l < myCurrentEdge->getNumLanes(); ++l) {
365  e.lanes.push_back((int) l);
366  }
367  }
368  e.speed = attrs.getOpt(SUMO_ATTR_SPEED, 0, ok, myCurrentEdge->getSpeed());
369  if (attrs.hasAttribute(SUMO_ATTR_SPEED) && myOptions.getBool("speed-in-kmh")) {
370  e.speed /= (SUMOReal) 3.6;
371  }
372  if (!ok) {
373  return;
374  }
375  mySplits.push_back(e);
376  }
377 }
378 
379 
380 bool
382  // the names and the coordinates of the beginning and the end node
383  // may be found, try
384  bool ok = true;
385  std::string begNodeID = myIsUpdate ? myCurrentEdge->getFromNode()->getID() : "";
386  std::string endNodeID = myIsUpdate ? myCurrentEdge->getToNode()->getID() : "";
387  std::string oldBegID = begNodeID;
388  std::string oldEndID = endNodeID;
389  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
390  begNodeID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
391  } else if (!myIsUpdate) {
392  WRITE_ERROR("The from-node is not given for edge '" + myCurrentID + "'.");
393  ok = false;
394  }
395  if (attrs.hasAttribute(SUMO_ATTR_TO)) {
396  endNodeID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
397  } else if (!myIsUpdate) {
398  WRITE_ERROR("The to-node is not given for edge '" + myCurrentID + "'.");
399  ok = false;
400  }
401  if (!ok) {
402  return false;
403  }
404  myFromNode = myNodeCont.retrieve(begNodeID);
405  myToNode = myNodeCont.retrieve(endNodeID);
406  if (myFromNode == 0) {
407  WRITE_ERROR("Edge's '" + myCurrentID + "' from-node '" + begNodeID + "' is not known.");
408  }
409  if (myToNode == 0) {
410  WRITE_ERROR("Edge's '" + myCurrentID + "' to-node '" + endNodeID + "' is not known.");
411  }
412  if (myFromNode != 0 && myToNode != 0) {
413  if (myIsUpdate && (myFromNode->getID() != oldBegID || myToNode->getID() != oldEndID)) {
415  }
416  }
417  return myFromNode != 0 && myToNode != 0;
418 }
419 
420 
423  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
424  return myShape;
425  }
426  // try to build shape
427  bool ok = true;
428  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
429  myReinitKeepEdgeShape = false;
430  return PositionVector();
431  }
434  WRITE_ERROR("Unable to project coordinates for edge '" + myCurrentID + "'.");
435  }
437  return shape;
438 }
439 
440 
443  bool ok = true;
445  std::string lsfS = toString(result);
446  lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, myCurrentID.c_str(), ok, lsfS);
447  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
449  } else {
450  WRITE_WARNING("Ignoring unknown spreadType '" + lsfS + "' for edge '" + myCurrentID + "'.");
451  }
452  return result;
453 }
454 
455 
456 void
458  bool ok = true;
459  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
460  if (!ok) {
461  return;
462  }
464  if (edge == 0) {
465  WRITE_WARNING("Ignoring tag '" + toString(SUMO_TAG_DELETE) + "' for unknown edge '" +
466  myCurrentID + "'");
467  return;
468  }
469  myEdgeCont.extract(myDistrictCont, edge, true);
470 }
471 
472 
473 void
475  if (element == SUMO_TAG_EDGE && myCurrentEdge != 0) {
476  // add sidewalk, wait until lanes are loaded to avoid building if it already exists
479  }
480  if (!myIsUpdate) {
481  try {
483  WRITE_ERROR("Duplicate edge occured. ID='" + myCurrentID + "'");
484  delete myCurrentEdge;
485  }
486  } catch (InvalidArgument& e) {
487  WRITE_ERROR(e.what());
488  throw;
489  } catch (...) {
490  WRITE_ERROR("An important information is missing in edge '" + myCurrentID + "'.");
491  }
492  }
493  if (mySplits.size() != 0) {
494  std::vector<Split>::iterator i;
495  NBEdge* e = myCurrentEdge;
496  sort(mySplits.begin(), mySplits.end(), split_sorter());
497  unsigned int noLanesMax = e->getNumLanes();
498  // compute the node positions and sort the lanes
499  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
500  (*i).gpos = e->getGeometry().positionAtOffset((*i).pos);
501  sort((*i).lanes.begin(), (*i).lanes.end());
502  noLanesMax = MAX2(noLanesMax, (unsigned int)(*i).lanes.size());
503  }
504  // split the edge
505  std::vector<int> currLanes;
506  for (unsigned int l = 0; l < e->getNumLanes(); ++l) {
507  currLanes.push_back(l);
508  }
509  if (e->getNumLanes() != mySplits.back().lanes.size()) {
510  // invalidate traffic light definitions loaded from a SUMO network
511  // XXX it would be preferable to reconstruct the phase definitions heuristically
513  // if the number of lanes changes the connections should be
514  // recomputed
515  e->invalidateConnections(true);
516  }
517 
518  std::string edgeid = e->getID();
519  SUMOReal seen = 0;
520  for (i = mySplits.begin(); i != mySplits.end(); ++i) {
521  const Split& exp = *i;
522  assert(exp.lanes.size() != 0);
523  if (exp.pos > 0 && e->getGeometry().length() + seen > exp.pos && exp.pos > seen) {
524  std::string nid = edgeid + "." + toString(exp.nameid);
525  NBNode* rn = new NBNode(nid, exp.gpos);
526  if (myNodeCont.insert(rn)) {
527  // split the edge
528  std::string nid = myCurrentID + "." + toString(exp.nameid);
529  std::string pid = e->getID();
530  myEdgeCont.splitAt(myDistrictCont, e, exp.pos - seen, rn,
531  pid, nid, e->getNumLanes(), (unsigned int) exp.lanes.size(), exp.speed);
532  seen = exp.pos;
533  std::vector<int> newLanes = exp.lanes;
534  NBEdge* pe = myEdgeCont.retrieve(pid);
535  NBEdge* ne = myEdgeCont.retrieve(nid);
536  // reconnect lanes
537  pe->invalidateConnections(true);
538  // new on right
539  unsigned int rightMostP = currLanes[0];
540  unsigned int rightMostN = newLanes[0];
541  for (int l = 0; l < (int) rightMostP - (int) rightMostN; ++l) {
542  pe->addLane2LaneConnection(0, ne, l, NBEdge::L2L_VALIDATED, true);
543  }
544  // new on left
545  unsigned int leftMostP = currLanes.back();
546  unsigned int leftMostN = newLanes.back();
547  for (int l = 0; l < (int) leftMostN - (int) leftMostP; ++l) {
548  pe->addLane2LaneConnection(pe->getNumLanes() - 1, ne, leftMostN - l - rightMostN, NBEdge::L2L_VALIDATED, true);
549  }
550  // all other connected
551  for (unsigned int l = 0; l < noLanesMax; ++l) {
552  if (find(currLanes.begin(), currLanes.end(), l) == currLanes.end()) {
553  continue;
554  }
555  if (find(newLanes.begin(), newLanes.end(), l) == newLanes.end()) {
556  continue;
557  }
558  pe->addLane2LaneConnection(l - rightMostP, ne, l - rightMostN, NBEdge::L2L_VALIDATED, true);
559  }
560  // move to next
561  e = ne;
562  currLanes = newLanes;
563  } else {
564  WRITE_WARNING("Error on parsing a split (edge '" + myCurrentID + "').");
565  }
566  } else if (exp.pos == 0) {
567  if (e->getNumLanes() < exp.lanes.size()) {
568  e->incLaneNo((int) exp.lanes.size() - e->getNumLanes());
569  } else {
570  e->decLaneNo(e->getNumLanes() - (int) exp.lanes.size());
571  }
572  currLanes = exp.lanes;
573  // invalidate traffic light definition loaded from a SUMO network
574  // XXX it would be preferable to reconstruct the phase definitions heuristically
576  } else {
577  WRITE_WARNING("Split at '" + toString(exp.pos) + "' lies beyond the edge's length (edge '" + myCurrentID + "').");
578  }
579  }
580  // patch lane offsets
581  e = myEdgeCont.retrieve(edgeid);
582  if (mySplits.front().pos != 0) {
583  // add a dummy split at the beginning to ensure correct offset
584  Split start;
585  start.pos = 0;
586  for (int lane = 0; lane < (int)e->getNumLanes(); ++lane) {
587  start.lanes.push_back(lane);
588  }
589  mySplits.insert(mySplits.begin(), start);
590  }
591  i = mySplits.begin();
592  for (; i != mySplits.end(); ++i) {
593  unsigned int maxLeft = (*i).lanes.back();
594  SUMOReal offset = 0;
595  if (maxLeft < noLanesMax) {
597  offset = SUMO_const_laneWidthAndOffset * (noLanesMax - 1 - maxLeft);
598  } else {
599  offset = SUMO_const_halfLaneAndOffset * (noLanesMax - 1 - maxLeft);
600  }
601  }
602  unsigned int maxRight = (*i).lanes.front();
603  if (maxRight > 0 && e->getLaneSpreadFunction() == LANESPREAD_CENTER) {
604  offset -= SUMO_const_halfLaneAndOffset * maxRight;
605  }
606  if (offset != 0) {
607  PositionVector g = e->getGeometry();
608  g.move2side(offset);
609  e->setGeometry(g);
610  }
611  if (e->getToNode()->getOutgoingEdges().size() != 0) {
612  e = e->getToNode()->getOutgoingEdges()[0];
613  }
614  }
615  }
616  }
617 }
618 
619 
620 void
622  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
623  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
624  EdgeSet roundabout;
625  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
626  NBEdge* edge = myEdgeCont.retrieve(*it);
627  if (edge == 0) {
628  if (!myEdgeCont.wasIgnored(*it)) {
629  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
630  }
631  } else {
632  roundabout.insert(edge);
633  }
634  }
635  myEdgeCont.addRoundabout(roundabout);
636  } else {
637  WRITE_ERROR("Empty edges in roundabout.");
638  }
639 }
640 
641 
642 
643 /****************************************************************************/
644 
void invalidateConnections(bool reallowSetting=false)
Definition: NBEdge.cpp:896
The information about how to spread the lanes from the given position.
const std::string & getTypeID() const
Definition: NBEdge.h:905
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:400
std::string myCurrentID
The current edge'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:2156
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2211
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: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:2339
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:2069
NBNode * myFromNode
The nodes the edge starts and ends at.
const SUMOReal SUMOXML_INVALID_POSITION
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.
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's lane and an approached one.
Definition: NBEdge.cpp:649
T MAX2(T a, T b)
Definition: StdDefs.h:74
bool myHaveReportedAboutOverwriting
Information whether at least one edge'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:2227
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:404
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's geometry
Definition: NBEdge.cpp:413
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 "myCurrentEdge".
~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's outgoing edges.
Definition: NBNode.h:259
SUMOReal getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
Definition: NBEdge.h:415
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'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:355
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:170
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:380
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:347
std::string myCurrentType
The current edge'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:423
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
SUMOReal myCurrentEndOffset
The current edge'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:2270
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
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:2084
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:371
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:258
SUMOReal myCurrentSpeed
The current edge's maximum speed.
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
Definition: NBEdge.h:208
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
Definition: NBEdge.cpp:2241
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:531
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:373
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's options.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
NBTypeCont & myTypeCont
The types container (for retrieval of type defaults)
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
Definition: NBEdge.h:611
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:2195
#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:471
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'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: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's lane width.
SUMOReal myLength
The current edge's length.
SUMOReal pos
The position of this change.
std::string myCurrentStreetName
The current edge's street name.
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
Definition: NBEdgeCont.cpp:920
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
void invalidateTLS(NBTrafficLightLogicCont &tlCont)
causes the traffic light to be computed anew
Definition: NBNode.cpp:334
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's priority.
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:263
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:363