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-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 /****************************************************************************/
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  PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, defaultCon.customShape);
261  std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, "");
262  std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, "");
263  SVCPermissions permissions;
264  if (allow == "" && disallow == "") {
265  permissions = SVC_UNSPECIFIED;
266  } else {
267  permissions = parseVehicleClasses(attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, ""), attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, ""));
268  }
269 
271  WRITE_ERROR("Unable to project shape for connection from edge '" + from->getID() + "' to edge '" + to->getID() + "'.");
272  }
273  if (!ok) {
274  return;
275  }
276  if (!from->addLane2LaneConnection(fromLane, to, toLane, NBEdge::Lane2LaneInfoType::USER, true, mayDefinitelyPass,
277  keepClear, contPos, visibility, speed, length, customShape, uncontrolled, permissions)) {
278  if (OptionsCont::getOptions().getBool("show-errors.connections-first-try")) {
279  WRITE_WARNINGF("Could not set loaded connection from lane '%' to lane '%'.", from->getLaneID(fromLane), to->getLaneID(toLane));
280  }
281  // set as to be re-applied after network processing
282  myEdgeCont.addPostProcessConnection(from->getID(), fromLane, to->getID(), toLane, mayDefinitelyPass, keepClear, contPos, visibility, speed, length, customShape, uncontrolled, false, permissions);
283  }
284  } catch (NumberFormatException&) {
285  myErrorMsgHandler->inform("At least one of the defined lanes was not numeric");
286  }
287 }
288 
289 bool
291  int* fromLane, int* toLane) {
292  if (attributes.hasAttribute(SUMO_ATTR_LANE)) {
293  return parseDeprecatedLaneDefinition(attributes, fromEdge, toEdge, fromLane, toLane);
294  } else {
295  return parseLaneDefinition(attributes, fromLane, toLane);
296  }
297 }
298 
299 
300 inline bool
302  NBEdge* from, NBEdge* to,
303  int* fromLane, int* toLane) {
304  bool ok = true;
307  WRITE_WARNING("'" + toString(SUMO_ATTR_LANE) + "' is deprecated, please use '" +
309  "' instead.");
310  }
311 
312  std::string laneConn = attributes.get<std::string>(SUMO_ATTR_LANE, nullptr, ok);
313  StringTokenizer st(laneConn, ':');
314  if (!ok || st.size() != 2) {
315  myErrorMsgHandler->inform("Invalid lane to lane connection from '" +
316  from->getID() + "' to '" + to->getID() + "'.");
317  return false; // There was an error.
318  }
319 
320  *fromLane = StringUtils::toIntSecure(st.next(), -1);
321  *toLane = StringUtils::toIntSecure(st.next(), -1);
322 
323  return true; // We succeeded.
324 }
325 
326 
327 inline bool
329  int* fromLane,
330  int* toLane) {
331  bool ok = true;
332  *fromLane = attributes.get<int>(SUMO_ATTR_FROM_LANE, nullptr, ok);
333  *toLane = attributes.get<int>(SUMO_ATTR_TO_LANE, nullptr, ok);
334  return ok;
335 }
336 
337 
338 void
340  bool ok = true;
341  EdgeVector edges;
342  const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, nullptr, ok);
343  double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, nodeID.c_str(), ok, NBEdge::UNSPECIFIED_WIDTH, true);
344  const bool discard = attrs.getOpt<bool>(SUMO_ATTR_DISCARD, nodeID.c_str(), ok, false, true);
345  int tlIndex = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok, -1);
346  int tlIndex2 = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX2, nullptr, ok, -1);
347  NBNode* node = myNodeCont.retrieve(nodeID);
348  if (node == nullptr) {
349  if (!discard && myNodeCont.wasRemoved(nodeID)) {
350  WRITE_ERROR("Node '" + nodeID + "' in crossing is not known.");
351  }
352  return;
353  }
354  if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
355  if (discard) {
356  node->discardAllCrossings(true);
357  return;
358  } else {
359  WRITE_ERROR("No edges specified for crossing at node '" + nodeID + "'.");
360  return;
361  }
362  }
363  for (const std::string& id : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
364  NBEdge* edge = myEdgeCont.retrieve(id);
365  if (edge == nullptr) {
366  if (!(discard && myEdgeCont.wasRemoved(id))) {
367  WRITE_ERROR("Edge '" + id + "' for crossing at node '" + nodeID + "' is not known.");
368  return;
369  } else {
370  edge = myEdgeCont.retrieve(id, true);
371  }
372  } else {
373  if (edge->getToNode() != node && edge->getFromNode() != node) {
374  if (!discard) {
375  WRITE_ERROR("Edge '" + id + "' does not touch node '" + nodeID + "'.");
376  return;
377  }
378  }
379  }
380  edges.push_back(edge);
381  }
382  if (!ok) {
383  return;
384  }
385  bool priority = attrs.getOpt<bool>(SUMO_ATTR_PRIORITY, nodeID.c_str(), ok, node->isTLControlled(), true);
386  if (node->isTLControlled() && !priority) {
387  // traffic_light nodes should always have priority crossings
388  WRITE_WARNING("Crossing at controlled node '" + nodeID + "' must be prioritized");
389  priority = true;
390  }
391  PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, PositionVector::EMPTY);
392  if (!NBNetBuilder::transformCoordinates(customShape)) {
393  WRITE_ERROR("Unable to project shape for crossing at node '" + node->getID() + "'.");
394  }
395  if (discard) {
396  node->removeCrossing(edges);
397  } else {
398  if (node->checkCrossingDuplicated(edges)) {
399  // possibly a diff
400  NBNode::Crossing* existing = node->getCrossing(edges);
401  if (!(
402  (attrs.hasAttribute(SUMO_ATTR_WIDTH) && width != existing->width)
403  || (attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX) && tlIndex != existing->customTLIndex)
404  || (attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX2) && tlIndex2 != existing->customTLIndex2)
405  || (attrs.hasAttribute(SUMO_ATTR_PRIORITY) && priority != existing->priority))) {
406  WRITE_ERROR("Crossing with edges '" + toString(edges) + "' already exists at node '" + node->getID() + "'.");
407  return;
408  } else {
409  // replace existing, keep old attributes
410  if (!attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
411  width = existing->width;
412  }
413  if (!attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX)) {
414  tlIndex = existing->customTLIndex;
415  }
416  if (!attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX2)) {
417  tlIndex2 = existing->customTLIndex2;
418  }
419  if (!attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
420  priority = existing->priority;
421  }
422  node->removeCrossing(edges);
423  }
424  }
425  node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
426  }
427 }
428 
429 
430 void
432  bool ok = true;
433  NBNode* node = nullptr;
434  EdgeVector edges;
435  const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, nullptr, ok);
436  std::vector<std::string> edgeIDs;
437  if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
438  WRITE_ERROR("No edges specified for walkingArea at node '" + nodeID + "'.");
439  return;
440  }
441  for (const std::string& id : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
442  NBEdge* edge = myEdgeCont.retrieve(id);
443  if (edge == nullptr) {
444  WRITE_ERROR("Edge '" + id + "' for walkingArea at node '" + nodeID + "' is not known.");
445  return;
446  }
447  if (node == nullptr) {
448  if (edge->getToNode()->getID() == nodeID) {
449  node = edge->getToNode();
450  } else if (edge->getFromNode()->getID() == nodeID) {
451  node = edge->getFromNode();
452  } else {
453  WRITE_ERROR("Edge '" + id + "' does not touch node '" + nodeID + "'.");
454  return;
455  }
456  } else {
457  if (edge->getToNode() != node && edge->getFromNode() != node) {
458  WRITE_ERROR("Edge '" + id + "' does not touch node '" + nodeID + "'.");
459  return;
460  }
461  }
462  edges.push_back(edge);
463  }
464  if (!ok) {
465  return;
466  }
467  PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, PositionVector::EMPTY);
468  if (!NBNetBuilder::transformCoordinates(customShape)) {
469  WRITE_ERROR("Unable to project shape for walkingArea at node '" + node->getID() + "'.");
470  }
471  node->addWalkingAreaShape(edges, customShape);
472 }
473 
474 
475 /****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:277
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
KeepClear
keepClear status of connections
Definition: NBCont.h:57
@ KEEPCLEAR_FALSE
Definition: NBCont.h:58
@ KEEPCLEAR_TRUE
Definition: NBCont.h:59
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_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_PASS
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_TO_LANE
@ SUMO_ATTR_UNCONTROLLED
@ 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:44
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:113
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
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
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)
Adds a connection which could not be set during loading.
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:985
EdgeBuildingStep getStep() const
The building step of this edge.
Definition: NBEdge.h:598
const std::string & getID() const
Definition: NBEdge.h:1423
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:516
@ 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:1152
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:1318
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:1201
std::string getLaneID(int lane) const
get lane ID
Definition: NBEdge.cpp:3345
@ USER
The connection was given by the user.
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:324
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:1195
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=SVC_UNSPECIFIED, bool postProcess=false)
Adds a connection between the specified this edge's lane and an approached one.
Definition: NBEdge.cpp:1019
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)
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:266
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
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:271
void invalidateTLS(NBTrafficLightLogicCont &tlCont, bool removedConnections, bool addedConnections)
causes the traffic light to be computed anew
Definition: NBNode.cpp:394
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
add shorted link FOES
Definition: NBNode.cpp:1681
void addWalkingAreaShape(EdgeVector edges, const PositionVector &shape)
add custom shape for walkingArea
Definition: NBNode.cpp:3183
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:73
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:188
double speed
custom speed for connection
Definition: NBEdge.h:239
KeepClear keepClear
whether the junction must be kept clear when using this connection
Definition: NBEdge.h:230
double customLength
custom length for connection
Definition: NBEdge.h:242
bool uncontrolled
check if Connection is uncontrolled
Definition: NBEdge.h:281
PositionVector customShape
custom shape for connection
Definition: NBEdge.h:245
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
Definition: NBEdge.h:227
double contPos
custom position for internal junction on this connection
Definition: NBEdge.h:233
double visibility
custom foe visiblity for connection
Definition: NBEdge.h:236