Eclipse SUMO - Simulation of Urban MObility
NIXMLConnectionsHandler.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-2022 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 /****************************************************************************/
21 // Importer for edge connections stored in XML
22 /****************************************************************************/
23 #include <config.h>
24 
25 #include <string>
26 #include <iostream>
27 #include <xercesc/sax/HandlerBase.hpp>
28 #include <xercesc/sax/AttributeList.hpp>
29 #include <xercesc/sax/SAXParseException.hpp>
30 #include <xercesc/sax/SAXException.hpp>
32 #include <netbuild/NBEdge.h>
33 #include <netbuild/NBEdgeCont.h>
34 #include <netbuild/NBNodeCont.h>
36 #include <netbuild/NBNode.h>
37 #include <netbuild/NBNetBuilder.h>
41 #include <utils/common/ToString.h>
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
52  SUMOSAXHandler("xml-connection-description"),
53  myEdgeCont(ec),
54  myNodeCont(nc),
55  myTLLogicCont(tlc),
56  myHaveWarnedAboutDeprecatedLanes(false),
57  myErrorMsgHandler(OptionsCont::getOptions().getBool("ignore-errors.connections") ?
58  MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()) {}
59 
60 
62 
63 
64 void
66  const SUMOSAXAttributes& attrs) {
67  if (element == SUMO_TAG_DEL) {
68  bool ok = true;
69  std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, nullptr, ok);
70  std::string to = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
71  if (!ok) {
72  return;
73  }
74  // these connections were removed when the edge was deleted
75  if (myEdgeCont.wasRemoved(from) || myEdgeCont.wasRemoved(to)) {
76  return;
77  }
78  NBEdge* fromEdge = myEdgeCont.retrieve(from);
79  NBEdge* toEdge = myEdgeCont.retrieve(to);
80  if (fromEdge == nullptr) {
81  myErrorMsgHandler->informf("The connection-source edge '%' to reset is not known.", from);
82  return;
83  }
84  if (toEdge == nullptr) {
85  myErrorMsgHandler->informf("The connection-destination edge '%' to reset is not known.", to);
86  return;
87  }
88  if (!fromEdge->isConnectedTo(toEdge) && fromEdge->getStep() >= NBEdge::EdgeBuildingStep::EDGE2EDGES) {
89  WRITE_WARNINGF("Target edge '%' is not connected with '%'; the connection cannot be reset.", toEdge->getID(), fromEdge->getID());
90  return;
91  }
92  int fromLane = -1; // Assume all lanes are to be reset.
93  int toLane = -1;
94  if (attrs.hasAttribute(SUMO_ATTR_LANE)
96  || attrs.hasAttribute(SUMO_ATTR_TO_LANE)) {
97  if (!parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) {
98  return;
99  }
100  // we could be trying to reset a connection loaded from a sumo net and which has become obsolete.
101  // In this case it's ok to encounter invalid lance indices
102  if (!fromEdge->hasConnectionTo(toEdge, toLane) && fromEdge->getStep() >= NBEdge::EdgeBuildingStep::LANES2EDGES) {
103  WRITE_WARNINGF("Edge '%' has no connection to lane '%'; the connection cannot be reset.", fromEdge->getID(), toEdge->getLaneID(toLane));
104  }
105  }
106  fromEdge->removeFromConnections(toEdge, fromLane, toLane, true);
107  }
108 
109  if (element == SUMO_TAG_CONNECTION) {
110  bool ok = true;
111  std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, "connection", ok);
112  std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, "connection", ok, "");
113  if (!ok || myEdgeCont.wasIgnored(from) || myEdgeCont.wasIgnored(to)) {
114  return;
115  }
116  // extract edges
117  NBEdge* fromEdge = myEdgeCont.retrieve(from);
118  NBEdge* toEdge = to.length() != 0 ? myEdgeCont.retrieve(to) : nullptr;
119  // check whether they are valid
120  if (fromEdge == nullptr) {
121  myErrorMsgHandler->inform("The connection-source edge '" + from + "' is not known.");
122  return;
123  }
124  if (toEdge == nullptr && to.length() != 0) {
125  myErrorMsgHandler->inform("The connection-destination edge '" + to + "' is not known.");
126  return;
127  }
128  // parse optional lane information
130  parseLaneBound(attrs, fromEdge, toEdge);
131  } else {
132  fromEdge->addEdge2EdgeConnection(toEdge);
133  fromEdge->getToNode()->invalidateTLS(myTLLogicCont, true, false);
134  if (attrs.hasAttribute(SUMO_ATTR_PASS)
138  || attrs.hasAttribute(SUMO_ATTR_SPEED)
141  || attrs.hasAttribute(SUMO_ATTR_SHAPE)
142  || attrs.hasAttribute(SUMO_ATTR_ALLOW)
143  || attrs.hasAttribute(SUMO_ATTR_DISALLOW)) {
144  WRITE_ERROR("No additional connection attributes are permitted in connection from edge '" + fromEdge->getID() + "' unless '"
145  + toString(SUMO_ATTR_FROM_LANE) + "' and '" + toString(SUMO_ATTR_TO_LANE) + "' are set.");
146  }
147  }
148  }
149  if (element == SUMO_TAG_PROHIBITION) {
150  bool ok = true;
151  std::string prohibitor = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITOR, nullptr, ok, "");
152  std::string prohibited = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITED, nullptr, ok, "");
153  if (!ok) {
154  return;
155  }
156  NBConnection prohibitorC = parseConnection("prohibitor", prohibitor);
157  NBConnection prohibitedC = parseConnection("prohibited", prohibited);
158  if (prohibitorC == NBConnection::InvalidConnection || prohibitedC == NBConnection::InvalidConnection) {
159  // something failed
160  return;
161  }
162  NBNode* n = prohibitorC.getFrom()->getToNode();
163  n->addSortedLinkFoes(prohibitorC, prohibitedC);
164  }
165  if (element == SUMO_TAG_CROSSING) {
166  addCrossing(attrs);
167  }
168  if (element == SUMO_TAG_WALKINGAREA) {
169  addWalkingArea(attrs);
170  }
171 }
172 
173 
175 NIXMLConnectionsHandler::parseConnection(const std::string& defRole, const std::string& def) {
176  // split from/to
177  const std::string::size_type div = def.find("->");
178  if (div == std::string::npos) {
179  myErrorMsgHandler->inform("Missing connection divider in " + defRole + " '" + def + "'");
181  }
182  std::string fromDef = def.substr(0, div);
183  std::string toDef = def.substr(div + 2);
184 
185  // retrieve the edges
186  // check whether the definition includes a lane information (do not process it)
187  if (fromDef.find('_') != std::string::npos) {
188  fromDef = fromDef.substr(0, fromDef.find('_'));
189  }
190  if (toDef.find('_') != std::string::npos) {
191  toDef = toDef.substr(0, toDef.find('_'));
192  }
193  // retrieve them now
194  NBEdge* fromE = myEdgeCont.retrieve(fromDef);
195  NBEdge* toE = myEdgeCont.retrieve(toDef);
196  // check
197  if (fromE == nullptr) {
198  myErrorMsgHandler->inform("Could not find edge '" + fromDef + "' in " + defRole + " '" + def + "'");
200  }
201  if (toE == nullptr) {
202  myErrorMsgHandler->inform("Could not find edge '" + toDef + "' in " + defRole + " '" + def + "'");
204  }
205  return NBConnection(fromE, toE);
206 }
207 
208 
209 void
211  if (to == nullptr) {
212  // do nothing if it's a dead end
213  return;
214  }
215  bool ok = true;
216  // get the begin and the end lane
217  int fromLane;
218  int toLane;
219  try {
220  if (!parseLaneInfo(attrs, from, to, &fromLane, &toLane)) {
221  return;
222  }
223  if (fromLane < 0) {
224  myErrorMsgHandler->informf("Invalid value '%' for " + toString(SUMO_ATTR_FROM_LANE) +
225  " in connection from '%' to '%'.", fromLane, from->getID(), to->getID());
226  return;
227  }
228  if (toLane < 0) {
229  myErrorMsgHandler->informf("Invalid value '%' for " + toString(SUMO_ATTR_TO_LANE) +
230  " in connection from '%' to '%'.", toLane, from->getID(), to->getID());
231  return;
232  }
233  if (from->hasConnectionTo(to, toLane) && from->getToNode()->getType() != SumoXMLNodeType::ZIPPER) {
234  WRITE_WARNINGF("Target lane '%' is already connected from '%'.", to->getLaneID(toLane), from->getID());
235  }
236 
237  NBEdge::Connection defaultCon(fromLane, to, toLane);
239  // maybe we are patching an existing connection
240  std::vector<NBEdge::Connection> existing = from->getConnectionsFromLane(fromLane, to, toLane);
241  if (existing.size() > 0) {
242  assert(existing.size() == 1);
243  defaultCon = existing.front();
244  // remove the original so we can insert the replacement
245  from->removeFromConnections(defaultCon);
246  } else {
247  from->getToNode()->invalidateTLS(myTLLogicCont, true, false);
248  }
249  }
250  const bool mayDefinitelyPass = attrs.getOpt<bool>(SUMO_ATTR_PASS, nullptr, ok, defaultCon.mayDefinitelyPass);
251  KeepClear keepClear = defaultCon.keepClear;
252  if (attrs.hasAttribute(SUMO_ATTR_KEEP_CLEAR)) {
253  keepClear = attrs.get<bool>(SUMO_ATTR_KEEP_CLEAR, nullptr, ok) ? KEEPCLEAR_TRUE : KEEPCLEAR_FALSE;
254  }
255  const double contPos = attrs.getOpt<double>(SUMO_ATTR_CONTPOS, nullptr, ok, defaultCon.contPos);
256  const double visibility = attrs.getOpt<double>(SUMO_ATTR_VISIBILITY_DISTANCE, nullptr, ok, defaultCon.visibility);
257  const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, defaultCon.speed);
258  const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, nullptr, ok, defaultCon.customLength);
259  const bool uncontrolled = attrs.getOpt<bool>(SUMO_ATTR_UNCONTROLLED, nullptr, ok, defaultCon.uncontrolled);
260  const bool indirectLeft = attrs.getOpt<bool>(SUMO_ATTR_INDIRECT, nullptr, ok, false);
261  const std::string edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, nullptr, ok, "");
262  PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, defaultCon.customShape);
263  std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, "");
264  std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, "");
265  SVCPermissions permissions;
266  if (allow == "" && disallow == "") {
267  permissions = SVC_UNSPECIFIED;
268  } else {
269  permissions = parseVehicleClasses(attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, ""), attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, ""));
270  }
271  SVCPermissions changeLeft = SVC_UNSPECIFIED;
272  SVCPermissions changeRight = SVC_UNSPECIFIED;
273  if (attrs.hasAttribute(SUMO_ATTR_CHANGE_LEFT)) {
274  changeLeft = parseVehicleClasses(attrs.get<std::string>(SUMO_ATTR_CHANGE_LEFT, nullptr, ok), "");
275  }
277  changeRight = parseVehicleClasses(attrs.get<std::string>(SUMO_ATTR_CHANGE_RIGHT, nullptr, ok), "");
278  }
279 
281  WRITE_ERROR("Unable to project shape for connection from edge '" + from->getID() + "' to edge '" + to->getID() + "'.");
282  }
283  if (!ok) {
284  return;
285  }
286  if (!from->addLane2LaneConnection(fromLane, to, toLane, NBEdge::Lane2LaneInfoType::USER, true, mayDefinitelyPass,
287  keepClear, contPos, visibility, speed, length, customShape, uncontrolled, permissions, indirectLeft, edgeType, changeLeft, changeRight)) {
288  if (OptionsCont::getOptions().getBool("show-errors.connections-first-try")) {
289  WRITE_WARNINGF("Could not set loaded connection from lane '%' to lane '%'.", from->getLaneID(fromLane), to->getLaneID(toLane));
290  }
291  // set as to be re-applied after network processing
292  myEdgeCont.addPostProcessConnection(from->getID(), fromLane, to->getID(), toLane, mayDefinitelyPass, keepClear, contPos, visibility,
293  speed, length, customShape, uncontrolled, false, permissions, indirectLeft, edgeType, changeLeft, changeRight);
294  }
295  } catch (NumberFormatException&) {
296  myErrorMsgHandler->inform("At least one of the defined lanes was not numeric");
297  }
298 }
299 
300 bool
302  int* fromLane, int* toLane) {
303  if (attributes.hasAttribute(SUMO_ATTR_LANE)) {
304  return parseDeprecatedLaneDefinition(attributes, fromEdge, toEdge, fromLane, toLane);
305  } else {
306  return parseLaneDefinition(attributes, fromLane, toLane);
307  }
308 }
309 
310 
311 inline bool
313  NBEdge* from, NBEdge* to,
314  int* fromLane, int* toLane) {
315  bool ok = true;
318  WRITE_WARNING("'" + toString(SUMO_ATTR_LANE) + "' is deprecated, please use '" +
320  "' instead.");
321  }
322 
323  std::string laneConn = attributes.get<std::string>(SUMO_ATTR_LANE, nullptr, ok);
324  StringTokenizer st(laneConn, ':');
325  if (!ok || st.size() != 2) {
326  myErrorMsgHandler->inform("Invalid lane to lane connection from '" +
327  from->getID() + "' to '" + to->getID() + "'.");
328  return false; // There was an error.
329  }
330 
331  *fromLane = StringUtils::toIntSecure(st.next(), -1);
332  *toLane = StringUtils::toIntSecure(st.next(), -1);
333 
334  return true; // We succeeded.
335 }
336 
337 
338 inline bool
340  int* fromLane,
341  int* toLane) {
342  bool ok = true;
343  *fromLane = attributes.get<int>(SUMO_ATTR_FROM_LANE, nullptr, ok);
344  *toLane = attributes.get<int>(SUMO_ATTR_TO_LANE, nullptr, ok);
345  return ok;
346 }
347 
348 
349 void
351  bool ok = true;
352  EdgeVector edges;
353  const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, nullptr, ok);
354  double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, nodeID.c_str(), ok, NBEdge::UNSPECIFIED_WIDTH, true);
355  const bool discard = attrs.getOpt<bool>(SUMO_ATTR_DISCARD, nodeID.c_str(), ok, false, true);
356  int tlIndex = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok, -1);
357  int tlIndex2 = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX2, nullptr, ok, -1);
358  NBNode* node = myNodeCont.retrieve(nodeID);
359  if (node == nullptr) {
360  if (!discard && myNodeCont.wasRemoved(nodeID)) {
361  WRITE_ERROR("Node '" + nodeID + "' in crossing is not known.");
362  }
363  return;
364  }
365  if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
366  if (discard) {
367  node->discardAllCrossings(true);
368  return;
369  } else {
370  WRITE_ERROR("No edges specified for crossing at node '" + nodeID + "'.");
371  return;
372  }
373  }
374  for (const std::string& id : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
375  NBEdge* edge = myEdgeCont.retrieve(id);
376  if (edge == nullptr) {
377  if (!(discard && myEdgeCont.wasRemoved(id))) {
378  WRITE_ERROR("Edge '" + id + "' for crossing at node '" + nodeID + "' is not known.");
379  return;
380  } else {
381  edge = myEdgeCont.retrieve(id, true);
382  }
383  } else {
384  if (edge->getToNode() != node && edge->getFromNode() != node) {
385  if (!discard) {
386  WRITE_ERROR("Edge '" + id + "' does not touch node '" + nodeID + "'.");
387  return;
388  }
389  }
390  }
391  edges.push_back(edge);
392  }
393  if (!ok) {
394  return;
395  }
396  bool priority = attrs.getOpt<bool>(SUMO_ATTR_PRIORITY, nodeID.c_str(), ok, node->isTLControlled(), true);
397  if (node->isTLControlled() && !priority) {
398  // traffic_light nodes should always have priority crossings
399  WRITE_WARNING("Crossing at controlled node '" + nodeID + "' must be prioritized");
400  priority = true;
401  }
402  PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, PositionVector::EMPTY);
403  if (!NBNetBuilder::transformCoordinates(customShape)) {
404  WRITE_ERROR("Unable to project shape for crossing at node '" + node->getID() + "'.");
405  }
406  if (discard) {
407  node->removeCrossing(edges);
408  } else {
409  if (node->checkCrossingDuplicated(edges)) {
410  // possibly a diff
411  NBNode::Crossing* existing = node->getCrossing(edges);
412  if (!(
413  (attrs.hasAttribute(SUMO_ATTR_WIDTH) && width != existing->width)
414  || (attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX) && tlIndex != existing->customTLIndex)
415  || (attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX2) && tlIndex2 != existing->customTLIndex2)
416  || (attrs.hasAttribute(SUMO_ATTR_PRIORITY) && priority != existing->priority))) {
417  WRITE_ERROR("Crossing with edges '" + toString(edges) + "' already exists at node '" + node->getID() + "'.");
418  return;
419  } else {
420  // replace existing, keep old attributes
421  if (!attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
422  width = existing->width;
423  }
424  if (!attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX)) {
425  tlIndex = existing->customTLIndex;
426  }
427  if (!attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX2)) {
428  tlIndex2 = existing->customTLIndex2;
429  }
430  if (!attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
431  priority = existing->priority;
432  }
433  node->removeCrossing(edges);
434  }
435  }
436  node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
437  }
438 }
439 
440 
441 void
443  bool ok = true;
444  NBNode* node = nullptr;
445  EdgeVector edges;
446  const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, nullptr, ok);
447  std::vector<std::string> edgeIDs;
448  if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
449  WRITE_ERROR("No edges specified for walkingArea at node '" + nodeID + "'.");
450  return;
451  }
452  for (const std::string& id : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
453  NBEdge* edge = myEdgeCont.retrieve(id);
454  if (edge == nullptr) {
455  WRITE_ERROR("Edge '" + id + "' for walkingArea at node '" + nodeID + "' is not known.");
456  return;
457  }
458  if (node == nullptr) {
459  if (edge->getToNode()->getID() == nodeID) {
460  node = edge->getToNode();
461  } else if (edge->getFromNode()->getID() == nodeID) {
462  node = edge->getFromNode();
463  } else {
464  WRITE_ERROR("Edge '" + id + "' does not touch node '" + nodeID + "'.");
465  return;
466  }
467  } else {
468  if (edge->getToNode() != node && edge->getFromNode() != node) {
469  WRITE_ERROR("Edge '" + id + "' does not touch node '" + nodeID + "'.");
470  return;
471  }
472  }
473  edges.push_back(edge);
474  }
475  if (!ok) {
476  return;
477  }
478  PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, PositionVector::EMPTY);
479  double customWidth = attrs.getOpt<double>(SUMO_ATTR_WIDTH, nullptr, ok, NBEdge::UNSPECIFIED_WIDTH);
480  if (!NBNetBuilder::transformCoordinates(customShape)) {
481  WRITE_ERROR("Unable to project shape for walkingArea at node '" + node->getID() + "'.");
482  }
483  node->addWalkingAreaShape(edges, customShape, customWidth);
484 }
485 
486 
487 /****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:281
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:35
KeepClear
keepClear status of connections
Definition: NBCont.h:58
@ KEEPCLEAR_FALSE
Definition: NBCont.h:59
@ KEEPCLEAR_TRUE
Definition: NBCont.h:60
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_PROHIBITION
prohibition of circulation between two edges
@ SUMO_TAG_CONNECTION
connectio between two lanes
@ SUMO_TAG_WALKINGAREA
walking area for pedestrians
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
@ SUMO_TAG_DEL
delete certain element (note: DELETE is a macro)
@ SUMO_ATTR_NODE
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ SUMO_ATTR_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_INDIRECT
Whether this connection is an indirect (left) turn.
@ SUMO_ATTR_FROM_LANE
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_PROHIBITED
@ SUMO_ATTR_PRIORITY
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_CHANGE_LEFT
@ SUMO_ATTR_PASS
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_CHANGE_RIGHT
@ SUMO_ATTR_TO_LANE
@ SUMO_ATTR_UNCONTROLLED
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_DISCARD
@ SUMO_ATTR_VISIBILITY_DISTANCE
foe visibility distance of a link
@ SUMO_ATTR_PROHIBITOR
@ SUMO_ATTR_CONTPOS
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
@ SUMO_ATTR_KEEP_CLEAR
Whether vehicles must keep the junction clear.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:117
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
Definition: MsgHandler.h:114
NBEdge * getFrom() const
returns the from-edge (start of the connection)
static const NBConnection InvalidConnection
Definition: NBConnection.h:124
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:59
void addPostProcessConnection(const std::string &from, int fromLane, const std::string &to, int toLane, bool mayDefinitelyPass, KeepClear keepClear, double contPos, double visibility, double speed, double length, const PositionVector &customShape, bool uncontrolled, bool warnOnly, SVCPermissions permissions=SVC_UNSPECIFIED, bool indirectLeft=false, const std::string &edgeType="", SVCPermissions changeLeft=SVC_UNSPECIFIED, SVCPermissions changeRight=SVC_UNSPECIFIED)
Adds a connection which could not be set during loading.
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 wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
Definition: NBEdgeCont.h:513
The representation of a single edge during network building.
Definition: NBEdge.h:91
bool addEdge2EdgeConnection(NBEdge *dest, bool overrideRemoval=false)
Adds a connection to another edge.
Definition: NBEdge.cpp:1026
EdgeBuildingStep getStep() const
The building step of this edge.
Definition: NBEdge.h:623
const std::string & getID() const
Definition: NBEdge.h:1465
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:541
@ EDGE2EDGES
The relationships between edges are computed/loaded.
@ LANES2EDGES
Lanes to edges - relationships are computed/loaded.
@ LANES2LANES_USER
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
Definition: NBEdge.cpp:1206
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, KeepClear keepClear=KEEPCLEAR_UNSPECIFIED, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE, double speed=UNSPECIFIED_SPEED, double length=myDefaultConnectionLength, const PositionVector &customShape=PositionVector::EMPTY, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED, SVCPermissions permissions=SVC_UNSPECIFIED, const bool indirectLeft=false, const std::string &edgeType="", SVCPermissions changeLeft=SVC_UNSPECIFIED, SVCPermissions changeRight=SVC_UNSPECIFIED, bool postProcess=false)
Adds a connection between the specified this edge's lane and an approached one.
Definition: NBEdge.cpp:1060
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false, const bool adaptToLaneRemoval=false, const bool keepPossibleTurns=false)
Removes the specified connection(s)
Definition: NBEdge.cpp:1372
bool isConnectedTo(const NBEdge *e, const bool ignoreTurnaround=false) const
Returns the information whethe a connection to the given edge has been added (or computed)
Definition: NBEdge.cpp:1255
std::string getLaneID(int lane) const
get lane ID
Definition: NBEdge.cpp:3693
@ USER
The connection was given by the user.
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:349
bool hasConnectionTo(NBEdge *destEdge, int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
Definition: NBEdge.cpp:1249
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:534
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
A definition of a pedestrian crossing.
Definition: NBNode.h:129
int customTLIndex
the custom traffic light index of this crossing (if controlled)
Definition: NBNode.h:157
int customTLIndex2
Definition: NBNode.h:158
bool priority
whether the pedestrians have priority
Definition: NBNode.h:150
double width
This crossing's width.
Definition: NBNode.h:142
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:58
bool wasRemoved(std::string id) const
Returns whether the node with the id was deleted explicitly.
Definition: NBNodeCont.h:270
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
void addWalkingAreaShape(EdgeVector edges, const PositionVector &shape, double width)
add custom shape for walkingArea
Definition: NBNode.cpp:3333
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:273
void invalidateTLS(NBTrafficLightLogicCont &tlCont, bool removedConnections, bool addedConnections)
causes the traffic light to be computed anew
Definition: NBNode.cpp:395
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
add shorted link FOES
Definition: NBNode.cpp:1774
A container for traffic light definitions and built programs.
MsgHandler *const myErrorMsgHandler
the handler for loading errors
bool parseLaneInfo(const SUMOSAXAttributes &attributes, NBEdge *fromEdge, NBEdge *toEdge, int *fromLane, int *toLane)
Parses information about lane-2-lane connection when it describes a lane-2-lane relationship.
bool parseLaneDefinition(const SUMOSAXAttributes &attributes, int *fromLane, int *toLane)
Parses information about lane-2-lane connection.
bool myHaveWarnedAboutDeprecatedLanes
Information whether we have a deprecated attribute.
NIXMLConnectionsHandler(NBEdgeCont &ec, NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Constructor.
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to (when invalidating tls)
bool parseDeprecatedLaneDefinition(const SUMOSAXAttributes &attributes, NBEdge *fromEdge, NBEdge *toEdge, int *fromLane, int *toLane)
Parses information about lane-2-lane connection in deprecated format.
NBEdgeCont & myEdgeCont
The edge container to fill.
NBConnection parseConnection(const std::string &defRole, const std::string &def)
Returns the connection described by def.
void addWalkingArea(const SUMOSAXAttributes &attrs)
Parses a walkingArea and updates the referenced node.
NBNodeCont & myNodeCont
The edge container to fill.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void parseLaneBound(const SUMOSAXAttributes &attrs, NBEdge *from, NBEdge *to)
Parses a connection when it describes a lane-2-lane relationship.
void addCrossing(const SUMOSAXAttributes &attrs)
Parses a crossing and updates the referenced node.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A storage for options typed value containers)
Definition: OptionsCont.h:89
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
A list of positions.
static const PositionVector EMPTY
empty Vector
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.
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.
SAX-handler base for SUMO-files.
static int toIntSecure(const std::string &sData, int def)
converts a string into the integer value described by it
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:197
double speed
custom speed for connection
Definition: NBEdge.h:252
KeepClear keepClear
whether the junction must be kept clear when using this connection
Definition: NBEdge.h:243
double customLength
custom length for connection
Definition: NBEdge.h:255
bool uncontrolled
check if Connection is uncontrolled
Definition: NBEdge.h:306
PositionVector customShape
custom shape for connection
Definition: NBEdge.h:258
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
Definition: NBEdge.h:240
double contPos
custom position for internal junction on this connection
Definition: NBEdge.h:246
double visibility
custom foe visiblity for connection
Definition: NBEdge.h:249