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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
20 // Importer for network edges stored in XML
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <iostream>
31 #include <map>
32 #include <cmath>
33 #include <xercesc/sax/HandlerBase.hpp>
34 #include <xercesc/sax/AttributeList.hpp>
35 #include <xercesc/sax/SAXParseException.hpp>
36 #include <xercesc/sax/SAXException.hpp>
38 #include <netbuild/NBNodeCont.h>
39 #include <netbuild/NBTypeCont.h>
40 #include <netbuild/NBNetBuilder.h>
46 #include <utils/common/ToString.h>
49 #include "NIXMLNodesHandler.h"
50 #include "NIXMLEdgesHandler.h"
51 
52 
53 // ===========================================================================
54 // method definitions
55 // ===========================================================================
57  NBEdgeCont& ec,
58  NBTypeCont& tc,
59  NBDistrictCont& dc,
61  OptionsCont& options) :
62  SUMOSAXHandler("xml-edges - file"),
63  myOptions(options),
64  myNodeCont(nc),
65  myEdgeCont(ec),
66  myTypeCont(tc),
67  myDistrictCont(dc),
68  myTLLogicCont(tlc),
69  myCurrentEdge(nullptr),
70  myCurrentLaneIndex(-1),
71  myHaveReportedAboutOverwriting(false),
72  myHaveReportedAboutTypeOverride(false),
73  myHaveWarnedAboutDeprecatedLaneId(false),
74  myKeepEdgeShape(!options.getBool("plain.extend-edge-shape")) {
75 }
76 
77 
79 
80 
81 void
83  const SUMOSAXAttributes& attrs) {
84  switch (element) {
85  case SUMO_TAG_EDGE:
86  addEdge(attrs);
87  break;
88  case SUMO_TAG_LANE:
89  addLane(attrs);
90  break;
91  case SUMO_TAG_NEIGH:
93  break;
94  case SUMO_TAG_SPLIT:
95  addSplit(attrs);
96  break;
97  case SUMO_TAG_DELETE:
98  deleteEdge(attrs);
99  break;
100  case SUMO_TAG_ROUNDABOUT:
101  addRoundabout(attrs);
102  break;
103  case SUMO_TAG_PARAM:
104  if (myLastParameterised.size() != 0 && myCurrentEdge != nullptr) {
105  bool ok = true;
106  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
107  // circumventing empty string test
108  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
109  myLastParameterised.back()->setParameter(key, val);
110  }
111  break;
112  case SUMO_TAG_STOPOFFSET: {
113  bool ok = true;
114  std::map<SVCPermissions, double> stopOffsets = parseStopOffsets(attrs, ok);
115  assert(stopOffsets.size() == 1);
116  if (!ok) {
117  std::stringstream ss;
118  ss << "(Error encountered at lane " << myCurrentLaneIndex << " of edge '" << myCurrentID << "' while parsing stopOffsets.)";
119  WRITE_ERROR(ss.str());
120  } else {
121  if (myCurrentEdge->getStopOffsets(myCurrentLaneIndex).size() != 0) {
122  std::stringstream ss;
123  ss << "Duplicate definition of stopOffset for ";
124  if (myCurrentLaneIndex != -1) {
125  ss << "lane " << myCurrentLaneIndex << " on ";
126  }
127  ss << "edge " << myCurrentEdge->getID() << ". Ignoring duplicate specification.";
128  WRITE_WARNING(ss.str());
129  return;
130  } else if (stopOffsets.begin()->second > myCurrentEdge->getLength() || stopOffsets.begin()->second < 0) {
131  std::stringstream ss;
132  ss << "Ignoring invalid stopOffset for ";
133  if (myCurrentLaneIndex != -1) {
134  ss << "lane " << myCurrentLaneIndex << " on ";
135  }
136  ss << "edge " << myCurrentEdge->getID();
137  if (stopOffsets.begin()->second > myCurrentEdge->getLength()) {
138  ss << " (offset larger than the edge length).";
139  } else {
140  ss << " (negative offset).";
141  }
142  WRITE_WARNING(ss.str());
143  } else {
145  }
146  }
147  }
148  break;
149  default:
150  break;
151  }
152 }
153 
154 
155 void
157  myIsUpdate = false;
158  bool ok = true;
159  // initialise the edge
160  myCurrentEdge = nullptr;
161  mySplits.clear();
162  // get the id, report an error if not given or empty...
163  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
164  if (!ok) {
165  return;
166  }
168  // check deprecated (unused) attributes
169  // use default values, first
173  if (myCurrentEdge != nullptr) {
174  // update existing edge. only update lane-specific settings when explicitly requested
175  myIsUpdate = true;
179  } else {
180  // this is a completely new edge. get the type specific defaults
184  }
185  myCurrentType = "";
189  myCurrentStreetName = "";
190  myReinitKeepEdgeShape = false;
193  // check whether a type's values shall be used
194  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
195  myCurrentType = attrs.get<std::string>(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok);
196  if (!ok) {
197  return;
198  }
199  if (!myTypeCont.knows(myCurrentType) && !myOptions.getBool("ignore-errors.edge-type")) {
200  WRITE_ERROR("Type '" + myCurrentType + "' used by edge '" + myCurrentID + "' was not defined (ignore with option --ignore-errors.edge-type).");
201  return;
202  }
210  }
211  // use values from the edge to overwrite if existing, then
212  if (myIsUpdate) {
214  WRITE_MESSAGE("Duplicate edge id occurred ('" + myCurrentID + "'); assuming overwriting is wished.");
216  }
219  WRITE_MESSAGE("Edge '" + myCurrentID + "' changed it's type; assuming type override is wished.");
221  }
222  }
223  if (attrs.getOpt<bool>(SUMO_ATTR_REMOVE, myCurrentID.c_str(), ok, false)) {
225  myCurrentEdge = nullptr;
226  return;
227  }
232  myReinitKeepEdgeShape = true;
233  }
237  }
239  }
240  // speed, priority and the number of lanes have now default values;
241  // try to read the real values from the file
242  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
243  myCurrentSpeed = attrs.get<double>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok);
244  }
245  if (myOptions.getBool("speed-in-kmh") && myCurrentSpeed != NBEdge::UNSPECIFIED_SPEED) {
246  myCurrentSpeed = myCurrentSpeed / (double) 3.6;
247  }
248  // try to get the number of lanes
249  if (attrs.hasAttribute(SUMO_ATTR_NUMLANES)) {
250  myCurrentLaneNo = attrs.get<int>(SUMO_ATTR_NUMLANES, myCurrentID.c_str(), ok);
251  }
252  // try to get the priority
253  if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
254  myCurrentPriority = attrs.get<int>(SUMO_ATTR_PRIORITY, myCurrentID.c_str(), ok);
255  }
256  // try to get the width
257  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
258  myCurrentWidth = attrs.get<double>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok);
259  }
260  // try to get the offset of the stop line from the intersection
261  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
262  myCurrentEndOffset = attrs.get<double>(SUMO_ATTR_ENDOFFSET, myCurrentID.c_str(), ok);
263  }
264  // try to get the street name
265  if (attrs.hasAttribute(SUMO_ATTR_NAME)) {
266  myCurrentStreetName = attrs.get<std::string>(SUMO_ATTR_NAME, myCurrentID.c_str(), ok);
267  if (myCurrentStreetName != "" && myOptions.isDefault("output.street-names")) {
268  myOptions.set("output.street-names", "true");
269  }
270  }
271 
272  // try to get the allowed/disallowed classes
274  std::string allowS = attrs.hasAttribute(SUMO_ATTR_ALLOW) ? attrs.getStringSecure(SUMO_ATTR_ALLOW, "") : "";
275  std::string disallowS = attrs.hasAttribute(SUMO_ATTR_DISALLOW) ? attrs.getStringSecure(SUMO_ATTR_DISALLOW, "") : "";
276  // XXX matter of interpretation: should updated permissions replace or extend previously set permissions?
277  myPermissions = parseVehicleClasses(allowS, disallowS);
278  }
279  // try to set the nodes
280  if (!setNodes(attrs)) {
281  // return if this failed
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  return;
297  }
298  // check whether a previously defined edge shall be overwritten
299  if (myCurrentEdge != nullptr) {
305  } else {
306  // the edge must be allocated in dependence to whether a shape is given
307  if (myShape.size() == 0) {
311  } else {
316  }
317  }
321  }
323 }
324 
325 
326 void
328  if (myCurrentEdge == nullptr) {
329  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
330  WRITE_ERROR("Additional lane information could not be set - the edge with id '" + myCurrentID + "' is not known.");
331  }
332  return;
333  }
334  bool ok = true;
335  int lane;
336  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
337  lane = attrs.get<int>(SUMO_ATTR_ID, myCurrentID.c_str(), ok);
340  WRITE_WARNING("'" + toString(SUMO_ATTR_ID) + "' is deprecated, please use '" + toString(SUMO_ATTR_INDEX) + "' instead.");
341  }
342  } else {
343  lane = attrs.get<int>(SUMO_ATTR_INDEX, myCurrentID.c_str(), ok);
344  }
345  if (!ok) {
346  return;
347  }
348  // check whether this lane exists
349  if (lane >= myCurrentEdge->getNumLanes()) {
350  WRITE_ERROR("Lane index is larger than number of lanes (edge '" + myCurrentID + "').");
351  return;
352  }
353  myCurrentLaneIndex = lane;
354  // set information about allowed / disallowed vehicle classes (if specified)
356  const std::string allowed = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, "");
357  const std::string disallowed = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, "");
358  myCurrentEdge->setPermissions(parseVehicleClasses(allowed, disallowed), lane);
359  }
360  if (attrs.hasAttribute(SUMO_ATTR_PREFER)) {
361  const std::string preferred = attrs.get<std::string>(SUMO_ATTR_PREFER, nullptr, ok);
363  }
364  // try to get the width
365  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
366  myCurrentEdge->setLaneWidth(lane, attrs.get<double>(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok));
367  }
368  // try to get the end-offset (lane shortened due to pedestrian crossing etc..)
369  if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
370  myCurrentEdge->setEndOffset(lane, attrs.get<double>(SUMO_ATTR_ENDOFFSET, myCurrentID.c_str(), ok));
371  }
372  // try to get lane specific speed (should not occur for german networks)
373  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
374  myCurrentEdge->setSpeed(lane, attrs.get<double>(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok));
375  }
376  // check whether this is an acceleration lane
378  myCurrentEdge->setAcceleration(lane, attrs.get<bool>(SUMO_ATTR_ACCELERATION, myCurrentID.c_str(), ok));
379  }
380 
381  // check whether this is an acceleration lane
382  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
383  PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, myCurrentID.c_str(), ok);
385  const std::string laneID = myCurrentID + "_" + toString(lane);
386  WRITE_ERROR("Unable to project coordinates for lane '" + laneID + "'.");
387  }
388  myCurrentEdge->setLaneShape(lane, shape);
389  }
391 }
392 
393 
395  if (myCurrentEdge == nullptr) {
396  if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
397  WRITE_WARNING("Ignoring 'split' because it cannot be assigned to an edge");
398  }
399  return;
400  }
401  bool ok = true;
403  e.pos = attrs.get<double>(SUMO_ATTR_POSITION, nullptr, ok);
404  if (ok) {
405  if (fabs(e.pos) > myCurrentEdge->getGeometry().length()) {
406  WRITE_ERROR("Edge '" + myCurrentID + "' has a split at invalid position " + toString(e.pos) + ".");
407  return;
408  }
409  std::vector<NBEdgeCont::Split>::iterator i = find_if(mySplits.begin(), mySplits.end(), split_by_pos_finder(e.pos));
410  if (i != mySplits.end()) {
411  WRITE_ERROR("Edge '" + myCurrentID + "' has already a split at position " + toString(e.pos) + ".");
412  return;
413  }
414  e.nameID = myCurrentID + "." + toString((int)e.pos);
415  if (e.pos < 0) {
417  }
418  std::vector<std::string> lanes;
419  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LANES, nullptr, ok, ""), lanes);
420  for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) {
421  try {
422  int lane = StringUtils::toInt((*i));
423  e.lanes.push_back(lane);
424  } catch (NumberFormatException&) {
425  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
426  } catch (EmptyData&) {
427  WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
428  }
429  }
430  if (e.lanes.empty()) {
431  for (int l = 0; l < myCurrentEdge->getNumLanes(); ++l) {
432  e.lanes.push_back(l);
433  }
434  }
435  e.speed = attrs.getOpt(SUMO_ATTR_SPEED, nullptr, ok, myCurrentEdge->getSpeed());
436  if (attrs.hasAttribute(SUMO_ATTR_SPEED) && myOptions.getBool("speed-in-kmh")) {
437  e.speed /= (double) 3.6;
438  }
439  e.idBefore = attrs.getOpt(SUMO_ATTR_ID_BEFORE, nullptr, ok, std::string(""));
440  e.idAfter = attrs.getOpt(SUMO_ATTR_ID_AFTER, nullptr, ok, std::string(""));
441  if (!ok) {
442  return;
443  }
444  const std::string nodeID = attrs.getOpt(SUMO_ATTR_ID, nullptr, ok, e.nameID);
445  if (nodeID == myCurrentEdge->getFromNode()->getID() || nodeID == myCurrentEdge->getToNode()->getID()) {
446  WRITE_ERROR("Invalid split node id for edge '" + myCurrentEdge->getID() + "' (from- and to-node are forbidden)");
447  return;
448  }
449  e.node = myNodeCont.retrieve(nodeID);
450  if (e.node == nullptr) {
451  e.node = new NBNode(nodeID, myCurrentEdge->getGeometry().positionAtOffset(e.pos));
452  }
455  mySplits.push_back(e);
456  }
457 }
458 
459 
460 bool
462  // the names and the coordinates of the beginning and the end node
463  // may be found, try
464  bool ok = true;
465  std::string begNodeID = myIsUpdate ? myCurrentEdge->getFromNode()->getID() : "";
466  std::string endNodeID = myIsUpdate ? myCurrentEdge->getToNode()->getID() : "";
467  std::string oldBegID = begNodeID;
468  std::string oldEndID = endNodeID;
469  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
470  begNodeID = attrs.get<std::string>(SUMO_ATTR_FROM, nullptr, ok);
471  } else if (!myIsUpdate) {
472  WRITE_ERROR("The from-node is not given for edge '" + myCurrentID + "'.");
473  ok = false;
474  }
475  if (attrs.hasAttribute(SUMO_ATTR_TO)) {
476  endNodeID = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
477  } else if (!myIsUpdate) {
478  WRITE_ERROR("The to-node is not given for edge '" + myCurrentID + "'.");
479  ok = false;
480  }
481  if (!ok) {
482  return false;
483  }
484  myFromNode = myNodeCont.retrieve(begNodeID);
485  myToNode = myNodeCont.retrieve(endNodeID);
486  if (myFromNode == nullptr) {
487  WRITE_ERROR("Edge's '" + myCurrentID + "' from-node '" + begNodeID + "' is not known.");
488  }
489  if (myToNode == nullptr) {
490  WRITE_ERROR("Edge's '" + myCurrentID + "' to-node '" + endNodeID + "' is not known.");
491  }
492  if (myFromNode != nullptr && myToNode != nullptr) {
493  if (myIsUpdate && (myFromNode->getID() != oldBegID || myToNode->getID() != oldEndID)) {
495  }
496  }
497  return myFromNode != nullptr && myToNode != nullptr;
498 }
499 
500 
503  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
504  return myShape;
505  }
506  // try to build shape
507  bool ok = true;
508  if (!attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
509  myReinitKeepEdgeShape = false;
510  return PositionVector();
511  }
512  PositionVector shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, PositionVector());
514  WRITE_ERROR("Unable to project coordinates for edge '" + myCurrentID + "'.");
515  }
517  return shape;
518 }
519 
520 
523  bool ok = true;
525  std::string lsfS = toString(result);
526  lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, myCurrentID.c_str(), ok, lsfS);
527  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
529  } else {
530  WRITE_WARNING("Ignoring unknown spreadType '" + lsfS + "' for edge '" + myCurrentID + "'.");
531  }
532  return result;
533 }
534 
535 
536 void
538  bool ok = true;
539  myCurrentID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
540  if (!ok) {
541  return;
542  }
544  if (edge == nullptr) {
545  WRITE_WARNING("Ignoring tag '" + toString(SUMO_TAG_DELETE) + "' for unknown edge '" +
546  myCurrentID + "'");
547  return;
548  }
549  const int lane = attrs.getOpt<int>(SUMO_ATTR_INDEX, myCurrentID.c_str(), ok, -1);
550  if (lane < 0) {
551  myEdgeCont.extract(myDistrictCont, edge, true);
552  } else {
553  edge->deleteLane(lane, false, true);
554  }
555 }
556 
557 
558 void
560  if (element == SUMO_TAG_EDGE && myCurrentEdge != nullptr) {
561  myLastParameterised.pop_back();
562  // add bike lane, wait until lanes are loaded to avoid building if it already exists
565  }
566  // add sidewalk, wait until lanes are loaded to avoid building if it already exists
569  }
570  // apply default stopOffsets of edge to all lanes without specified stopOffset.
571  std::map<SVCPermissions, double> stopOffsets = myCurrentEdge->getStopOffsets(-1);
572  if (stopOffsets.size() != 0) {
573  for (int i = 0; i < (int)myCurrentEdge->getLanes().size(); i++) {
574  myCurrentEdge->setStopOffsets(i, stopOffsets, false);
575  }
576  }
577  if (!myIsUpdate) {
578  try {
580  WRITE_ERROR("Duplicate edge occurred. ID='" + myCurrentID + "'");
581  delete myCurrentEdge;
582  }
583  } catch (InvalidArgument& e) {
584  WRITE_ERROR(e.what());
585  throw;
586  } catch (...) {
587  WRITE_ERROR("An important information is missing in edge '" + myCurrentID + "'.");
588  }
589  }
591  myCurrentEdge = nullptr;
592  } else if (element == SUMO_TAG_LANE) {
593  myLastParameterised.pop_back();
594  myCurrentLaneIndex = -1;
595  }
596 }
597 
598 
599 void
601  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
602  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
603  EdgeSet roundabout;
604  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
605  NBEdge* edge = myEdgeCont.retrieve(*it);
606  if (edge == nullptr) {
607  if (!myEdgeCont.wasIgnored(*it)) {
608  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
609  }
610  } else {
611  roundabout.insert(edge);
612  }
613  }
614  myEdgeCont.addRoundabout(roundabout);
615  } else {
616  WRITE_ERROR("Empty edges in roundabout.");
617  }
618 }
619 
620 
621 /****************************************************************************/
622 
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge&#39;s lanes&#39; lateral offset is computed.
Definition: NBEdge.h:704
The information about how to spread the lanes from the given position.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:108
double getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:488
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:174
LaneSpreadFunction myLanesSpread
Information about how to spread the lanes.
split something
Finds a split at the given position.
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
Definition: NBEdge.h:273
const std::map< int, double > & getStopOffsets() const
Returns the stopOffset to the end of the edge.
Definition: NBEdge.h:562
begin/end of the description of a single lane
A structure which describes changes of lane number or speed along the road.
Definition: NBEdgeCont.h:206
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3222
std::string myCurrentID
The current edge&#39;s id.
static NBNode * 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)
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
PositionVector myShape
The shape of the edge.
A container for traffic light definitions and built programs.
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3272
void addRoundabout(const SUMOSAXAttributes &attrs)
Parses a roundabout and stores it in myEdgeCont.
bool setNodes(const SUMOSAXAttributes &attrs)
Sets from/to node information of the currently parsed edge.
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:427
const std::string & getTypeID() const
get ID of type
Definition: NBEdge.h:1004
std::string nameID
the default node id
Definition: NBEdgeCont.h:221
double myCurrentSpeed
The current edge&#39;s maximum speed.
The representation of a single edge during network building.
Definition: NBEdge.h:65
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:180
NBNode * myFromNode
The nodes the edge starts and ends at.
A container for districts.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:261
NIXMLEdgesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
std::map< SVCPermissions, double > parseStopOffsets(const SUMOSAXAttributes &attrs, bool &ok)
Extract stopOffsets from attributes of stopOffset element.
bool myHaveReportedAboutOverwriting
Information whether at least one edge&#39;s attributes were overwritten.
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Definition: NBEdge.h:507
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:3303
void setLoadedLength(double val)
set loaded lenght
Definition: NBEdge.cpp:3346
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:589
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
std::string idAfter
The id for the edge after the split.
Definition: NBEdgeCont.h:219
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:168
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
Definition: Named.h:78
NBDistrictCont & myDistrictCont
The districts container (needed if an edge must be split)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1206
SAX-handler base for SUMO-files.
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:3238
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connctions
Definition: NBEdge.cpp:3458
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:258
std::vector< Parameterised * > myLastParameterised
element to receive parameters
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:241
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
Definition: NBEdge.cpp:3295
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:210
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
Definition: NBEdge.cpp:3287
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
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.
static const double UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:264
double pos
The position of this change.
Definition: NBEdgeCont.h:211
NBNode * node
The new node that is created for this split.
Definition: NBEdgeCont.h:215
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:68
double getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
Definition: NBTypeCont.cpp:222
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:46
the edges of a route
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:152
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
double getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Definition: NBTypeCont.cpp:216
bool myHaveWarnedAboutDeprecatedLaneId
Encapsulated SAX-Attributes.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
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:386
void deleteEdge(const SUMOSAXAttributes &attrs)
parses delete tag and deletes the specified edge or lane
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:420
parameter associated to a certain key
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...
T get(const std::string &str) const
void deleteLane(int index, bool recompute, bool shiftIndices)
delete lane
Definition: NBEdge.cpp:3096
std::string myCurrentType
The current edge&#39;s type.
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
Definition: NBEdge.cpp:535
double myLength
The current edge&#39;s length.
roundabout defined in junction
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:61
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
Definition: NBEdgeCont.cpp:411
const std::string & getStreetName() const
Returns the street name of this edge.
Definition: NBEdge.h:543
double myCurrentEndOffset
The current edge&#39;s offset till the destination node.
NBNodeCont & myNodeCont
The nodes container (for retrieval of referenced nodes)
edge: the shape in xml-definition
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) ...
std::vector< int > lanes
The lanes after this change.
Definition: NBEdgeCont.h:209
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
LaneSpreadFunction tryGetLaneSpread(const SUMOSAXAttributes &attrs)
Tries to parse the spread type.
begin/end of the description of a neighboring lane
int myCurrentLaneIndex
The currently processed lane index.
double myBikeLaneWidth
The width of the bike lane that shall be added to the current edge.
begin/end of the description of an edge
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=LANESPREAD_RIGHT, bool tryIgnoreNodePositions=false)
Resets initial values.
Definition: NBEdge.cpp:351
double getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:514
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:622
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:247
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.
SVCPermissions myPermissions
Information about lane permissions.
double length() const
Returns the length.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
bool myIsUpdate
Whether this edge definition is an update of a previously inserted edge.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:245
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
set preferred Vehicle Class
Definition: NBEdge.cpp:3317
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:92
NBEdge * myCurrentEdge
The currently processed edge.
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:379
void addBikeLane(double width)
add a bicycle lane of the given width and shift existing connctions
Definition: NBEdge.cpp:3470
OptionsCont & myOptions
A reference to the program&#39;s options.
double myCurrentWidth
The current edge&#39;s lane width.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge&#39;s lateral offset shal...
double speed
The speed after this change.
Definition: NBEdgeCont.h:213
NBTypeCont & myTypeCont
The types container (for retrieval of type defaults)
const Position & getPosition() const
Definition: NBNode.h:242
Represents a single node (junction) during network building.
Definition: NBNode.h:68
bool myHaveReportedAboutTypeOverride
Information whether at least one edge&#39;s type was changed.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:434
NBEdgeCont & myEdgeCont
The edges container (for insertion of build edges)
int myCurrentLaneNo
The current edge&#39;s number of lanes.
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:503
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
std::string myCurrentStreetName
The current edge&#39;s street name.
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
delete certain element
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:497
double mySidewalkWidth
The width of the sidewalk that shall be added to the current edge.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:242
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and modifies myCurrentEdge according to the given attribures.
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:441
int myCurrentPriority
The current edge&#39;s priority.
std::string idBefore
The id for the edge before the split.
Definition: NBEdgeCont.h:217
std::vector< NBEdgeCont::Split > mySplits
The list of this edge&#39;s splits.
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3174
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:204
A storage for available types of edges.
Definition: NBTypeCont.h:55
PositionVector tryGetShape(const SUMOSAXAttributes &attrs)
Tries to parse the shape definition.
Information on vClass specific stop offsets at lane end.