Eclipse SUMO - Simulation of Urban MObility
NIXMLEdgesHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
23 // Importer for network edges stored in XML
24 /****************************************************************************/
25 #include <config.h>
26 
27 #include <string>
28 #include <iostream>
29 #include <map>
30 #include <cmath>
31 #include <xercesc/sax/HandlerBase.hpp>
32 #include <xercesc/sax/AttributeList.hpp>
33 #include <xercesc/sax/SAXParseException.hpp>
34 #include <xercesc/sax/SAXException.hpp>
36 #include <netbuild/NBNodeCont.h>
37 #include <netbuild/NBTypeCont.h>
38 #include <netbuild/NBNetBuilder.h>
44 #include <utils/common/ToString.h>
47 #include "NIXMLNodesHandler.h"
48 #include "NIXMLEdgesHandler.h"
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
55  NBEdgeCont& ec,
56  NBTypeCont& tc,
57  NBDistrictCont& dc,
59  OptionsCont& options) :
60  SUMOSAXHandler("xml-edges - file"),
61  myOptions(options),
62  myNodeCont(nc),
63  myEdgeCont(ec),
64  myTypeCont(tc),
65  myDistrictCont(dc),
66  myTLLogicCont(tlc),
67  myCurrentEdge(nullptr),
68  myCurrentLaneIndex(-1),
69  myHaveReportedAboutOverwriting(false),
70  myHaveReportedAboutTypeOverride(false),
71  myHaveWarnedAboutDeprecatedLaneId(false),
72  myKeepEdgeShape(!options.getBool("plain.extend-edge-shape")) {
73 }
74 
75 
77 
78 
79 void
81  const SUMOSAXAttributes& attrs) {
82  switch (element) {
83  case SUMO_TAG_EDGE:
84  addEdge(attrs);
85  break;
86  case SUMO_TAG_LANE:
87  addLane(attrs);
88  break;
89  case SUMO_TAG_NEIGH:
91  break;
92  case SUMO_TAG_SPLIT:
93  addSplit(attrs);
94  break;
95  case SUMO_TAG_DEL:
96  deleteEdge(attrs);
97  break;
99  addRoundabout(attrs);
100  break;
101  case SUMO_TAG_PARAM:
102  if (myLastParameterised.size() != 0 && myCurrentEdge != nullptr) {
103  bool ok = true;
104  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
105  // circumventing empty string test
106  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
107  myLastParameterised.back()->setParameter(key, val);
108  }
109  break;
110  case SUMO_TAG_STOPOFFSET: {
111  bool ok = true;
112  std::map<SVCPermissions, double> stopOffsets = parseStopOffsets(attrs, ok);
113  assert(stopOffsets.size() == 1);
114  if (!ok) {
115  std::stringstream ss;
116  ss << "(Error encountered at lane " << myCurrentLaneIndex << " of edge '" << myCurrentID << "' while parsing stopOffsets.)";
117  WRITE_ERROR(ss.str());
118  } else {
119  if (myCurrentEdge->getStopOffsets(myCurrentLaneIndex).size() != 0) {
120  std::stringstream ss;
121  ss << "Duplicate definition of stopOffset for ";
122  if (myCurrentLaneIndex != -1) {
123  ss << "lane " << myCurrentLaneIndex << " on ";
124  }
125  ss << "edge " << myCurrentEdge->getID() << ". Ignoring duplicate specification.";
126  WRITE_WARNING(ss.str());
127  return;
128  } else if (stopOffsets.begin()->second > myCurrentEdge->getLength() || stopOffsets.begin()->second < 0) {
129  std::stringstream ss;
130  ss << "Ignoring invalid stopOffset for ";
131  if (myCurrentLaneIndex != -1) {
132  ss << "lane " << myCurrentLaneIndex << " on ";
133  }
134  ss << "edge " << myCurrentEdge->getID();
135  if (stopOffsets.begin()->second > myCurrentEdge->getLength()) {
136  ss << " (offset larger than the edge length).";
137  } else {
138  ss << " (negative offset).";
139  }
140  WRITE_WARNING(ss.str());
141  } else {
143  }
144  }
145  }
146  break;
147  default:
148  break;
149  }
150 }
151 
152 
153 void
155  myIsUpdate = false;
156  bool ok = true;
157  // initialise the edge
158  myCurrentEdge = nullptr;
159  mySplits.clear();
160  // get the id, report an error if not given or empty...
161  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
162  if (!ok) {
163  return;
164  }
166  // check deprecated (unused) attributes
167  // use default values, first
168  myCurrentType = myOptions.getString("default.type");
172  if (myCurrentEdge != nullptr) {
173  // update existing edge. only update lane-specific settings when explicitly requested
174  myIsUpdate = true;
179  } else {
180  // this is a completely new edge. get the type specific defaults
184  }
188  myCurrentStreetName = "";
189  myReinitKeepEdgeShape = false;
192  // check whether a type's values shall be used
193  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
194  myCurrentType = attrs.get<std::string>(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok);
195  if (!ok) {
196  return;
197  }
198  if (!myTypeCont.knows(myCurrentType) && !myOptions.getBool("ignore-errors.edge-type")) {
199  WRITE_ERRORF("Type '%' used by edge '%' was not defined (ignore with option --ignore-errors.edge-type).", myCurrentType, myCurrentID);
200  return;
201  }
209  }
210  // use values from the edge to overwrite if existing, then
211  if (myIsUpdate) {
213  WRITE_MESSAGE("Duplicate edge id occurred ('" + myCurrentID + "'); assuming overwriting is wished.");
215  }
218  WRITE_MESSAGE("Edge '" + myCurrentID + "' changed it's type; assuming type override is wished.");
220  }
221  }
222  if (attrs.getOpt<bool>(SUMO_ATTR_REMOVE, myCurrentID.c_str(), ok, false)) {
224  myCurrentEdge = nullptr;
225  return;
226  }
231  myReinitKeepEdgeShape = true;
232  }
236  }
238  }
239  // speed, priority and the number of lanes have now default values;
240  // try to read the real values from the file
241  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
242  myCurrentSpeed = attrs.get<double>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok);
243  }
244  if (myOptions.getBool("speed-in-kmh") && myCurrentSpeed != NBEdge::UNSPECIFIED_SPEED) {
245  myCurrentSpeed = myCurrentSpeed / (double) 3.6;
246  }
247  // try to get the number of lanes
248  if (attrs.hasAttribute(SUMO_ATTR_NUMLANES)) {
249  myCurrentLaneNo = attrs.get<int>(SUMO_ATTR_NUMLANES, myCurrentID.c_str(), ok);
250  }
251  // try to get the priority
252  if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
253  myCurrentPriority = attrs.get<int>(SUMO_ATTR_PRIORITY, myCurrentID.c_str(), ok);
254  }
255  // try to get the width
256  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
257  myCurrentWidth = attrs.get<double>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok);
258  }
259  // try to get the offset of the stop line from the intersection
260  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
261  myCurrentEndOffset = attrs.get<double>(SUMO_ATTR_ENDOFFSET, myCurrentID.c_str(), ok);
262  }
263  // try to get the street name
264  if (attrs.hasAttribute(SUMO_ATTR_NAME)) {
265  myCurrentStreetName = attrs.get<std::string>(SUMO_ATTR_NAME, myCurrentID.c_str(), ok);
266  if (myCurrentStreetName != "" && myOptions.isDefault("output.street-names")) {
267  myOptions.set("output.street-names", "true");
268  }
269  }
270 
271  // try to get the allowed/disallowed classes
273  std::string allowS = attrs.hasAttribute(SUMO_ATTR_ALLOW) ? attrs.getStringSecure(SUMO_ATTR_ALLOW, "") : "";
274  std::string disallowS = attrs.hasAttribute(SUMO_ATTR_DISALLOW) ? attrs.getStringSecure(SUMO_ATTR_DISALLOW, "") : "";
275  // XXX matter of interpretation: should updated permissions replace or extend previously set permissions?
276  myPermissions = parseVehicleClasses(allowS, disallowS);
277  }
278  // try to set the nodes
279  if (!setNodes(attrs)) {
280  // return if this failed
281  myCurrentEdge = nullptr;
282  return;
283  }
284  // try to get the shape
285  myShape = tryGetShape(attrs);
286  // try to get the spread type
288  // try to get the length
289  myLength = attrs.getOpt<double>(SUMO_ATTR_LENGTH, myCurrentID.c_str(), ok, myLength);
290  // try to get the sidewalkWidth
292  // try to get the bikeLaneWidth
294  // insert the parsed edge into the edges map
295  if (!ok) {
296  myCurrentEdge = nullptr;
297  return;
298  }
299  // check whether a previously defined edge shall be overwritten
300  if (myCurrentEdge != nullptr) {
306  } else {
307  // the edge must be allocated in dependence to whether a shape is given
308  if (myShape.size() == 0) {
312  } else {
317  }
318  }
322  }
323  // try to get the kilometrage/mileage
325 
327 }
328 
329 
330 void
332  if (myCurrentEdge == nullptr) {
333  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
334  WRITE_ERRORF("Additional lane information could not be set - the edge with id '%s' is not known.", myCurrentID);
335  }
336  return;
337  }
338  bool ok = true;
339  int lane;
340  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
341  lane = attrs.get<int>(SUMO_ATTR_ID, myCurrentID.c_str(), ok);
344  WRITE_WARNING("'" + toString(SUMO_ATTR_ID) + "' is deprecated, please use '" + toString(SUMO_ATTR_INDEX) + "' instead.");
345  }
346  } else {
347  lane = attrs.get<int>(SUMO_ATTR_INDEX, myCurrentID.c_str(), ok);
348  }
349  if (!ok) {
350  return;
351  }
352  // check whether this lane exists
353  if (lane >= myCurrentEdge->getNumLanes()) {
354  WRITE_ERROR("Lane index is larger than number of lanes (edge '" + myCurrentID + "').");
355  return;
356  }
357  myCurrentLaneIndex = lane;
358  // set information about allowed / disallowed vehicle classes (if specified)
360  const std::string allowed = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, "");
361  const std::string disallowed = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, "");
362  myCurrentEdge->setPermissions(parseVehicleClasses(allowed, disallowed), lane);
363  }
364  if (attrs.hasAttribute(SUMO_ATTR_PREFER)) {
365  const std::string preferred = attrs.get<std::string>(SUMO_ATTR_PREFER, nullptr, ok);
367  }
368  // try to get the width
369  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
370  myCurrentEdge->setLaneWidth(lane, attrs.get<double>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok));
371  }
372  // try to get the end-offset (lane shortened due to pedestrian crossing etc..)
373  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
374  myCurrentEdge->setEndOffset(lane, attrs.get<double>(SUMO_ATTR_ENDOFFSET, myCurrentID.c_str(), ok));
375  }
376  // try to get lane specific speed (should not occur for german networks)
377  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
378  myCurrentEdge->setSpeed(lane, attrs.get<double>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok));
379  }
380  // check whether this is an acceleration lane
382  myCurrentEdge->setAcceleration(lane, attrs.get<bool>(SUMO_ATTR_ACCELERATION, myCurrentID.c_str(), ok));
383  }
384  // check whether this lane has a custom shape
385  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
386  PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, myCurrentID.c_str(), ok);
388  const std::string laneID = myCurrentID + "_" + toString(lane);
389  WRITE_ERROR("Unable to project coordinates for lane '" + laneID + "'.");
390  }
391  if (shape.size() == 1) {
392  // lane shape of length 1 is not permitted
394  shape.push_back(myCurrentEdge->getToNode()->getPosition());
395  }
396  shape.removeDoublePoints();
397  if (shape.size() < 2) {
398  // ignore lane shape for very short lanes
399  shape.clear();
400  }
401  myCurrentEdge->setLaneShape(lane, shape);
402  }
403  // set custom lane type
404  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
405  myCurrentEdge->setLaneType(lane, attrs.get<std::string>(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok));
406  }
408 }
409 
410 
412  if (myCurrentEdge == nullptr) {
413  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
414  WRITE_WARNING("Ignoring 'split' because it cannot be assigned to an edge");
415  }
416  return;
417  }
418  bool ok = true;
420  e.pos = attrs.get<double>(SUMO_ATTR_POSITION, nullptr, ok);
421  if (ok) {
422  if (fabs(e.pos) > myCurrentEdge->getGeometry().length()) {
423  WRITE_ERROR("Edge '" + myCurrentID + "' has a split at invalid position " + toString(e.pos) + ".");
424  return;
425  }
426  std::vector<NBEdgeCont::Split>::iterator i = find_if(mySplits.begin(), mySplits.end(), split_by_pos_finder(e.pos));
427  if (i != mySplits.end()) {
428  WRITE_ERROR("Edge '" + myCurrentID + "' has already a split at position " + toString(e.pos) + ".");
429  return;
430  }
431  // XXX rounding to int may duplicate the id of another split
432  e.nameID = myCurrentID + "." + toString((int)e.pos);
433  if (e.pos < 0) {
435  }
436  for (const std::string& id : attrs.getOptStringVector(SUMO_ATTR_LANES, myCurrentID.c_str(), ok)) {
437  try {
438  int lane = StringUtils::toInt(id);
439  e.lanes.push_back(lane);
440  } catch (NumberFormatException&) {
441  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
442  } catch (EmptyData&) {
443  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
444  }
445  }
446  if (e.lanes.empty()) {
447  for (int l = 0; l < myCurrentEdge->getNumLanes(); ++l) {
448  e.lanes.push_back(l);
449  }
450  }
451  e.speed = attrs.getOpt(SUMO_ATTR_SPEED, nullptr, ok, myCurrentEdge->getSpeed());
452  if (attrs.hasAttribute(SUMO_ATTR_SPEED) && myOptions.getBool("speed-in-kmh")) {
453  e.speed /= 3.6;
454  }
455  e.idBefore = attrs.getOpt(SUMO_ATTR_ID_BEFORE, nullptr, ok, std::string(""));
456  e.idAfter = attrs.getOpt(SUMO_ATTR_ID_AFTER, nullptr, ok, std::string(""));
457  if (!ok) {
458  return;
459  }
460  const std::string nodeID = attrs.getOpt(SUMO_ATTR_ID, nullptr, ok, e.nameID);
461  if (nodeID == myCurrentEdge->getFromNode()->getID() || nodeID == myCurrentEdge->getToNode()->getID()) {
462  WRITE_ERROR("Invalid split node id for edge '" + myCurrentEdge->getID() + "' (from- and to-node are forbidden)");
463  return;
464  }
465  e.node = myNodeCont.retrieve(nodeID);
466  e.offsetFactor = OptionsCont::getOptions().getBool("lefthand") ? -1 : 1;
467  if (e.node == nullptr) {
468  e.node = new NBNode(nodeID, myCurrentEdge->getGeometry().positionAtOffset(e.pos));
470  }
473  mySplits.push_back(e);
474  }
475 }
476 
477 
478 bool
480  // the names and the coordinates of the beginning and the end node
481  // may be found, try
482  bool ok = true;
483  if (myIsUpdate) {
486  }
487  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
488  const std::string begNodeID = attrs.get<std::string>(SUMO_ATTR_FROM, nullptr, ok);
489  if (begNodeID != "") {
490  myFromNode = myNodeCont.retrieve(begNodeID);
491  if (myFromNode == nullptr) {
492  WRITE_ERROR("Edge's '" + myCurrentID + "' from-node '" + begNodeID + "' is not known.");
493  }
494  }
495  } else if (!myIsUpdate) {
496  WRITE_ERROR("The from-node is not given for edge '" + myCurrentID + "'.");
497  ok = false;
498  }
499  if (attrs.hasAttribute(SUMO_ATTR_TO)) {
500  const std::string endNodeID = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
501  if (endNodeID != "") {
502  myToNode = myNodeCont.retrieve(endNodeID);
503  if (myToNode == nullptr) {
504  WRITE_ERROR("Edge's '" + myCurrentID + "' to-node '" + endNodeID + "' is not known.");
505  }
506  }
507  } else if (!myIsUpdate) {
508  WRITE_ERROR("The to-node is not given for edge '" + myCurrentID + "'.");
509  ok = false;
510  }
511  return ok && myFromNode != nullptr && myToNode != nullptr;
512 }
513 
514 
517  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
518  return myShape;
519  }
520  // try to build shape
521  bool ok = true;
522  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
523  myReinitKeepEdgeShape = false;
524  return PositionVector();
525  }
526  PositionVector shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, PositionVector());
528  WRITE_ERROR("Unable to project coordinates for edge '" + myCurrentID + "'.");
529  }
531  return shape;
532 }
533 
534 
537  bool ok = true;
539  std::string lsfS = toString(result);
540  lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, myCurrentID.c_str(), ok, lsfS);
541  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
543  } else {
544  WRITE_WARNING("Ignoring unknown spreadType '" + lsfS + "' for edge '" + myCurrentID + "'.");
545  }
546  return result;
547 }
548 
549 
550 void
552  bool ok = true;
553  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
554  if (!ok) {
555  return;
556  }
558  if (edge == nullptr) {
559  WRITE_WARNING("Ignoring tag '" + toString(SUMO_TAG_DEL) + "' for unknown edge '" +
560  myCurrentID + "'");
561  return;
562  }
563  const int lane = attrs.getOpt<int>(SUMO_ATTR_INDEX, myCurrentID.c_str(), ok, -1);
564  if (lane < 0) {
565  myEdgeCont.extract(myDistrictCont, edge, true);
566  } else {
567  edge->deleteLane(lane, false, true);
568  }
569 }
570 
571 
572 void
574  if (myCurrentEdge == nullptr) {
575  return;
576  }
577  if (element == SUMO_TAG_EDGE) {
578  myLastParameterised.pop_back();
579  // add bike lane, wait until lanes are loaded to avoid building if it already exists
582  }
583  // add sidewalk, wait until lanes are loaded to avoid building if it already exists
586  }
587  // apply default stopOffsets of edge to all lanes without specified stopOffset.
588  std::map<SVCPermissions, double> stopOffsets = myCurrentEdge->getStopOffsets(-1);
589  if (stopOffsets.size() != 0) {
590  for (int i = 0; i < (int)myCurrentEdge->getLanes().size(); i++) {
591  myCurrentEdge->setStopOffsets(i, stopOffsets, false);
592  }
593  }
594  if (!myIsUpdate) {
595  try {
597  WRITE_ERROR("Duplicate edge occurred. ID='" + myCurrentID + "'");
598  delete myCurrentEdge;
599  }
600  } catch (InvalidArgument& e) {
601  WRITE_ERROR(e.what());
602  throw;
603  } catch (...) {
604  WRITE_ERROR("An important information is missing in edge '" + myCurrentID + "'.");
605  }
606  }
608  myCurrentEdge = nullptr;
609  } else if (element == SUMO_TAG_LANE && myCurrentLaneIndex != -1) {
610  myLastParameterised.pop_back();
611  myCurrentLaneIndex = -1;
612  }
613 }
614 
615 
616 void
618  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
619  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
620  EdgeSet roundabout;
621  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
622  NBEdge* edge = myEdgeCont.retrieve(*it);
623  if (edge == nullptr) {
624  if (!myEdgeCont.wasIgnored(*it)) {
625  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
626  }
627  } else {
628  roundabout.insert(edge);
629  }
630  }
631  myEdgeCont.addRoundabout(roundabout);
632  } else {
633  WRITE_ERROR("Empty edges in roundabout.");
634  }
635 }
636 
637 
638 /****************************************************************************/
#define WRITE_ERRORF(...)
Definition: MsgHandler.h:285
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:49
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
std::map< SVCPermissions, double > parseStopOffsets(const SUMOSAXAttributes &attrs, bool &ok)
Extract stopOffsets from attributes of stopOffset element.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
@ SUMO_TAG_STOPOFFSET
Information on vClass specific stop offsets at lane end.
@ SUMO_TAG_ROUNDABOUT
roundabout defined in junction
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_NEIGH
begin/end of the description of a neighboring lane
@ SUMO_TAG_SPLIT
split something
@ SUMO_TAG_DEL
delete certain element (note: DELETE is a macro)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
@ SUMO_ATTR_PREFER
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ SUMO_ATTR_REMOVE
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_PRIORITY
@ SUMO_ATTR_NUMLANES
@ SUMO_ATTR_LANES
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_NAME
@ SUMO_ATTR_SPREADTYPE
The information about how to spread the lanes from the given position.
@ SUMO_ATTR_ENDOFFSET
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_ACCELERATION
@ SUMO_ATTR_BIKELANEWIDTH
@ SUMO_ATTR_DISTANCE
@ SUMO_ATTR_ID_AFTER
@ SUMO_ATTR_SIDEWALKWIDTH
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_KEY
@ SUMO_ATTR_POSITION
@ SUMO_ATTR_ID_BEFORE
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
A container for districts.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:59
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
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:416
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
Definition: NBEdgeCont.cpp:441
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:409
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:275
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:502
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:178
The representation of a single edge during network building.
Definition: NBEdge.h:91
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
set preferred Vehicle Class
Definition: NBEdge.cpp:3641
double getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:563
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:3627
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
Definition: NBEdge.h:572
void addBikeLane(double width)
add a bicycle lane of the given width and shift existing connctions
Definition: NBEdge.cpp:3829
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3597
const std::string & getStreetName() const
Returns the street name of this edge.
Definition: NBEdge.h:618
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
Definition: NBEdge.h:803
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Definition: NBEdge.h:582
void setDistance(double distance)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.h:1318
const std::string & getID() const
Definition: NBEdge.h:1423
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:677
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:516
void setLaneType(int lane, const std::string &type)
set lane specific type (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3506
double getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:589
double getDistance() const
Definition: NBEdge.h:634
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
Definition: NBEdge.h:339
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3491
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
Definition: NBEdge.cpp:3612
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connctions
Definition: NBEdge.cpp:3817
void reinit(NBNode *from, NBNode *to, const std::string &type, double speed, int nolanes, int priority, PositionVector geom, double width, double endOffset, const std::string &streetName, LaneSpreadFunction spread=LaneSpreadFunction::RIGHT, bool tryIgnoreNodePositions=false)
Resets initial values.
Definition: NBEdge.cpp:380
bool setStopOffsets(int lane, std::map< int, double > offsets, bool overwrite=false)
set lane and vehicle class specific stopOffset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3568
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:490
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:716
void deleteLane(int index, bool recompute, bool shiftIndices)
delete lane
Definition: NBEdge.cpp:3413
const std::map< int, double > & getStopOffsets() const
Returns the stopOffset to the end of the edge.
Definition: NBEdge.h:641
static const double UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:330
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
Definition: NBEdge.cpp:3619
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
Definition: NBEdge.cpp:575
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:497
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:324
const std::string & getTypeID() const
get ID of type
Definition: NBEdge.h:1104
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3552
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:327
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1326
void setLoadedLength(double val)
set loaded length
Definition: NBEdge.cpp:3670
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:509
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:58
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:90
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:119
Represents a single node (junction) during network building.
Definition: NBNode.h:66
const Position & getPosition() const
Definition: NBNode.h:246
A container for traffic light definitions and built programs.
A storage for available edgeTypes of edges.
Definition: NBTypeCont.h:52
double getEdgeTypeSpeed(const std::string &edgeType) const
Returns the maximal velocity for the given edgeType [m/s].
Definition: NBTypeCont.cpp:451
int getEdgeTypePriority(const std::string &edgeType) const
Returns the priority for the given edgeType.
Definition: NBTypeCont.cpp:457
int getEdgeTypeNumLanes(const std::string &edgeType) const
Returns the number of lanes for the given edgeType.
Definition: NBTypeCont.cpp:445
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
Definition: NBTypeCont.cpp:501
SVCPermissions getEdgeTypePermissions(const std::string &edgeType) const
Returns allowed vehicle classes for the given edgeType.
Definition: NBTypeCont.cpp:495
bool knows(const std::string &edgeType) const
Returns whether the named edgeType is in the container.
Definition: NBTypeCont.cpp:270
double getEdgeTypeSidewalkWidth(const std::string &edgeType) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:507
double getEdgeTypeBikeLaneWidth(const std::string &edgeType) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:513
Finds a split at the given position.
std::string myCurrentID
The current edge's id.
SVCPermissions myPermissions
Information about lane permissions.
bool setNodes(const SUMOSAXAttributes &attrs)
Sets from/to node information of the currently parsed edge.
PositionVector myShape
The shape of the edge.
std::string myCurrentStreetName
The current edge's street name.
LaneSpreadFunction tryGetLaneSpread(const SUMOSAXAttributes &attrs)
Tries to parse the spread type.
double myCurrentSpeed
The current edge's maximum speed.
double myBikeLaneWidth
The width of the bike lane that shall be added to the current edge.
~NIXMLEdgesHandler()
Destructor.
int myCurrentLaneNo
The current edge's number of lanes.
OptionsCont & myOptions
A reference to the program's options.
void addRoundabout(const SUMOSAXAttributes &attrs)
Parses a roundabout and stores it in myEdgeCont.
double myCurrentWidth
The current edge's lane width.
NIXMLEdgesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
NBTypeCont & myTypeCont
The types container (for retrieval of type defaults)
double myCurrentEndOffset
The current edge's offset till the destination node.
double myLength
The current edge's length.
int myCurrentPriority
The current edge's priority.
NBNodeCont & myNodeCont
The nodes container (for retrieval of referenced nodes)
PositionVector tryGetShape(const SUMOSAXAttributes &attrs)
Tries to parse the shape definition.
bool myIsUpdate
Whether this edge definition is an update of a previously inserted edge.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
LaneSpreadFunction myLanesSpread
Information about how to spread the lanes.
NBDistrictCont & myDistrictCont
The districts container (needed if an edge must be split)
std::vector< Parameterised * > myLastParameterised
element to receive parameters
NBEdgeCont & myEdgeCont
The edges container (for insertion of build edges)
double mySidewalkWidth
The width of the sidewalk that shall be added to the current edge.
bool myHaveWarnedAboutDeprecatedLaneId
void addSplit(const SUMOSAXAttributes &attrs)
Parses a split and stores it in mySplits. Splits are executed Upon reading the end tag of an edge.
std::string myCurrentType
The current edge's type.
NBEdge * myCurrentEdge
The currently processed edge.
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to (when invalidating tls because of splits)
std::vector< NBEdgeCont::Split > mySplits
The list of this edge's splits.
int myCurrentLaneIndex
The currently processed lane index.
bool myHaveReportedAboutTypeOverride
Information whether at least one edge's type was changed.
NBNode * myFromNode
The nodes the edge starts and ends at.
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and modifies myCurrentEdge according to the given attribures.
void myEndElement(int element)
Called when a closing tag occurs.
const bool myKeepEdgeShape
Whether the edge shape shall be kept generally.
bool myHaveReportedAboutOverwriting
Information whether at least one edge's attributes were overwritten.
void deleteEdge(const SUMOSAXAttributes &attrs)
parses delete tag and deletes the specified edge or lane
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".
static NBNode * processNodeType(const SUMOSAXAttributes &attrs, NBNode *node, const std::string &nodeID, const Position &position, bool updateEdgeGeometries, NBNodeCont &nc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
parses node attributes (not related to positioning)
const std::string & getID() const
Returns the id.
Definition: Named.h:73
A storage for options typed value containers)
Definition: OptionsCont.h:89
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
A list of positions.
double length() const
Returns the length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void removeDoublePoints(double minDist=POSITION_EPS, bool assertLength=false)
Removes positions if too near.
void push_front(const Position &p)
insert in front a Position
Encapsulated SAX-Attributes.
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.
const std::vector< std::string > getOptStringVector(int attr, const char *objectid, bool &ok, bool report=true) const
convenience function to avoid the default argument and the template stuff at getOpt<>
const std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SAX-handler base for SUMO-files.
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
T get(const std::string &str) const
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
std::string oppositeID
An opposite lane ID, if given.
Definition: NBEdge.h:169
A structure which describes changes of lane number or speed along the road.
Definition: NBEdgeCont.h:204
int offsetFactor
direction in which to apply the offset (used by netgenerate for lefthand networks)
Definition: NBEdgeCont.h:222
double speed
The speed after this change.
Definition: NBEdgeCont.h:210
std::string nameID
the default node id
Definition: NBEdgeCont.h:218
std::string idBefore
The id for the edge before the split.
Definition: NBEdgeCont.h:214
double pos
The position of this change.
Definition: NBEdgeCont.h:208
std::vector< int > lanes
The lanes after this change.
Definition: NBEdgeCont.h:206
std::string idAfter
The id for the edge after the split.
Definition: NBEdgeCont.h:216
NBNode * node
The new node that is created for this split.
Definition: NBEdgeCont.h:212