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>
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
64void
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(TL("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;
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(TL("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);
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
175NIXMLConnectionsHandler::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
209void
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
234 NBEdge::Connection defaultCon(fromLane, to, toLane);
236 // maybe we are patching an existing connection
237 std::vector<NBEdge::Connection> existing = from->getConnectionsFromLane(fromLane, to, toLane);
238 if (existing.size() > 0) {
239 assert(existing.size() == 1);
240 defaultCon = existing.front();
241 // remove the original so we can insert the replacement
242 from->removeFromConnections(defaultCon);
243 } else {
244 from->getToNode()->invalidateTLS(myTLLogicCont, true, false);
245 }
246 }
247 const bool mayDefinitelyPass = attrs.getOpt<bool>(SUMO_ATTR_PASS, nullptr, ok, defaultCon.mayDefinitelyPass);
248 KeepClear keepClear = defaultCon.keepClear;
250 keepClear = attrs.get<bool>(SUMO_ATTR_KEEP_CLEAR, nullptr, ok) ? KEEPCLEAR_TRUE : KEEPCLEAR_FALSE;
251 }
252 const double contPos = attrs.getOpt<double>(SUMO_ATTR_CONTPOS, nullptr, ok, defaultCon.contPos);
253 const double visibility = attrs.getOpt<double>(SUMO_ATTR_VISIBILITY_DISTANCE, nullptr, ok, defaultCon.visibility);
254 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, defaultCon.speed);
255 const double friction = attrs.getOpt<double>(SUMO_ATTR_FRICTION, nullptr, ok, defaultCon.friction);
256 const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, nullptr, ok, defaultCon.customLength);
257 const bool uncontrolled = attrs.getOpt<bool>(SUMO_ATTR_UNCONTROLLED, nullptr, ok, defaultCon.uncontrolled);
258 const bool indirectLeft = attrs.getOpt<bool>(SUMO_ATTR_INDIRECT, nullptr, ok, false);
259 const std::string edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, nullptr, ok, "");
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 SVCPermissions changeLeft = SVC_UNSPECIFIED;
270 SVCPermissions changeRight = SVC_UNSPECIFIED;
272 changeLeft = parseVehicleClasses(attrs.get<std::string>(SUMO_ATTR_CHANGE_LEFT, nullptr, ok), "");
273 }
275 changeRight = parseVehicleClasses(attrs.get<std::string>(SUMO_ATTR_CHANGE_RIGHT, nullptr, ok), "");
276 }
277
279 WRITE_ERROR("Unable to project shape for connection from edge '" + from->getID() + "' to edge '" + to->getID() + "'.");
280 }
281 if (!ok) {
282 return;
283 }
284 if (!from->addLane2LaneConnection(fromLane, to, toLane, NBEdge::Lane2LaneInfoType::USER, true, mayDefinitelyPass,
285 keepClear, contPos, visibility, speed, friction, length, customShape, uncontrolled, permissions, indirectLeft, edgeType, changeLeft, changeRight)) {
286 if (OptionsCont::getOptions().getBool("show-errors.connections-first-try")) {
287 WRITE_WARNINGF(TL("Could not set loaded connection from lane '%' to lane '%'."), from->getLaneID(fromLane), to->getLaneID(toLane));
288 }
289 // set as to be re-applied after network processing
290 myEdgeCont.addPostProcessConnection(from->getID(), fromLane, to->getID(), toLane, mayDefinitelyPass, keepClear, contPos, visibility,
291 speed, friction, length, customShape, uncontrolled, false, permissions, indirectLeft, edgeType, changeLeft, changeRight);
292 }
293 } catch (NumberFormatException&) {
294 myErrorMsgHandler->inform("At least one of the defined lanes was not numeric");
295 }
296}
297
298bool
300 int* fromLane, int* toLane) {
301 if (attributes.hasAttribute(SUMO_ATTR_LANE)) {
302 return parseDeprecatedLaneDefinition(attributes, fromEdge, toEdge, fromLane, toLane);
303 } else {
304 return parseLaneDefinition(attributes, fromLane, toLane);
305 }
306}
307
308
309inline bool
311 NBEdge* from, NBEdge* to,
312 int* fromLane, int* toLane) {
313 bool ok = true;
316 WRITE_WARNING("'" + toString(SUMO_ATTR_LANE) + "' is deprecated, please use '" +
318 "' instead.");
319 }
320
321 std::string laneConn = attributes.get<std::string>(SUMO_ATTR_LANE, nullptr, ok);
322 StringTokenizer st(laneConn, ':');
323 if (!ok || st.size() != 2) {
324 myErrorMsgHandler->inform("Invalid lane to lane connection from '" +
325 from->getID() + "' to '" + to->getID() + "'.");
326 return false; // There was an error.
327 }
328
329 *fromLane = StringUtils::toIntSecure(st.next(), -1);
330 *toLane = StringUtils::toIntSecure(st.next(), -1);
331
332 return true; // We succeeded.
333}
334
335
336inline bool
338 int* fromLane,
339 int* toLane) {
340 bool ok = true;
341 *fromLane = attributes.get<int>(SUMO_ATTR_FROM_LANE, nullptr, ok);
342 *toLane = attributes.get<int>(SUMO_ATTR_TO_LANE, nullptr, ok);
343 return ok;
344}
345
346
347void
349 bool ok = true;
350 EdgeVector edges;
351 const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, nullptr, ok);
352 double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, nodeID.c_str(), ok, NBEdge::UNSPECIFIED_WIDTH, true);
353 const bool discard = attrs.getOpt<bool>(SUMO_ATTR_DISCARD, nodeID.c_str(), ok, false, true);
354 int tlIndex = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok, -1);
355 int tlIndex2 = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX2, nullptr, ok, -1);
356 NBNode* node = myNodeCont.retrieve(nodeID);
357 if (node == nullptr) {
358 if (!discard && myNodeCont.wasRemoved(nodeID)) {
359 WRITE_ERROR("Node '" + nodeID + "' in crossing is not known.");
360 }
361 return;
362 }
363 if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
364 if (discard) {
365 node->discardAllCrossings(true);
366 return;
367 } else {
368 WRITE_ERROR("No edges specified for crossing at node '" + nodeID + "'.");
369 return;
370 }
371 }
372 for (const std::string& id : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
373 NBEdge* edge = myEdgeCont.retrieve(id);
374 if (edge == nullptr) {
375 if (!(discard && myEdgeCont.wasRemoved(id))) {
376 WRITE_ERROR("Edge '" + id + "' for crossing at node '" + nodeID + "' is not known.");
377 return;
378 } else {
379 edge = myEdgeCont.retrieve(id, true);
380 }
381 } else {
382 if (edge->getToNode() != node && edge->getFromNode() != node) {
383 if (!discard) {
384 WRITE_ERROR("Edge '" + id + "' does not touch node '" + nodeID + "'.");
385 return;
386 }
387 }
388 }
389 edges.push_back(edge);
390 }
391 if (!ok) {
392 return;
393 }
394 bool priority = attrs.getOpt<bool>(SUMO_ATTR_PRIORITY, nodeID.c_str(), ok, node->isTLControlled(), true);
395 if (node->isTLControlled() && !priority) {
396 // traffic_light nodes should always have priority crossings
397 WRITE_WARNING("Crossing at controlled node '" + nodeID + "' must be prioritized");
398 priority = true;
399 }
401 if (!NBNetBuilder::transformCoordinates(customShape)) {
402 WRITE_ERROR("Unable to project shape for crossing at node '" + node->getID() + "'.");
403 }
404 if (discard) {
405 node->removeCrossing(edges);
406 } else {
407 if (node->checkCrossingDuplicated(edges)) {
408 // possibly a diff
409 NBNode::Crossing* existing = node->getCrossing(edges);
410 if (!(
411 (attrs.hasAttribute(SUMO_ATTR_WIDTH) && width != existing->width)
412 || (attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX) && tlIndex != existing->customTLIndex)
413 || (attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX2) && tlIndex2 != existing->customTLIndex2)
414 || (attrs.hasAttribute(SUMO_ATTR_PRIORITY) && priority != existing->priority))) {
415 WRITE_ERROR("Crossing with edges '" + toString(edges) + "' already exists at node '" + node->getID() + "'.");
416 return;
417 } else {
418 // replace existing, keep old attributes
419 if (!attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
420 width = existing->width;
421 }
423 tlIndex = existing->customTLIndex;
424 }
426 tlIndex2 = existing->customTLIndex2;
427 }
428 if (!attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
429 priority = existing->priority;
430 }
431 node->removeCrossing(edges);
432 }
433 }
434 node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
435 }
436}
437
438
439void
441 bool ok = true;
442 NBNode* node = nullptr;
443 EdgeVector edges;
444 const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, nullptr, ok);
445 std::vector<std::string> edgeIDs;
446 if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
447 WRITE_ERROR("No edges specified for walkingArea at node '" + nodeID + "'.");
448 return;
449 }
450 for (const std::string& id : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
451 NBEdge* edge = myEdgeCont.retrieve(id);
452 if (edge == nullptr) {
453 WRITE_ERROR("Edge '" + id + "' for walkingArea at node '" + nodeID + "' is not known.");
454 return;
455 }
456 if (node == nullptr) {
457 if (edge->getToNode()->getID() == nodeID) {
458 node = edge->getToNode();
459 } else if (edge->getFromNode()->getID() == nodeID) {
460 node = edge->getFromNode();
461 } else {
462 WRITE_ERROR("Edge '" + id + "' does not touch node '" + nodeID + "'.");
463 return;
464 }
465 } else {
466 if (edge->getToNode() != node && edge->getFromNode() != node) {
467 WRITE_ERROR("Edge '" + id + "' does not touch node '" + nodeID + "'.");
468 return;
469 }
470 }
471 edges.push_back(edge);
472 }
473 if (!ok) {
474 return;
475 }
477 double customWidth = attrs.getOpt<double>(SUMO_ATTR_WIDTH, nullptr, ok, NBEdge::UNSPECIFIED_WIDTH);
478 if (!NBNetBuilder::transformCoordinates(customShape)) {
479 WRITE_ERROR("Unable to project shape for walkingArea at node '" + node->getID() + "'.");
480 }
481 node->addWalkingAreaShape(edges, customShape, customWidth);
482}
483
484
485/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:266
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:274
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
#define TL(string)
Definition: MsgHandler.h:282
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:42
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.
@ SUMO_ATTR_FRICTION
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:116
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
Definition: MsgHandler.h:120
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:274
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 friction, 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.
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:495
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
Definition: NBEdgeCont.h:506
The representation of a single edge during network building.
Definition: NBEdge.h:92
bool addEdge2EdgeConnection(NBEdge *dest, bool overrideRemoval=false)
Adds a connection to another edge.
Definition: NBEdge.cpp:1058
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:552
EdgeBuildingStep getStep() const
The building step of this edge.
Definition: NBEdge.h:641
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 friction=UNSPECIFIED_FRICTION, 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:1092
@ 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.
const std::string & getID() const
Definition: NBEdge.h:1526
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
Definition: NBEdge.cpp:1241
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:1402
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:1285
std::string getLaneID(int lane) const
get lane ID
Definition: NBEdge.cpp:3776
@ USER
The connection was given by the user.
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:545
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:357
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:1279
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
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:277
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:120
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:3458
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:1776
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:59
A list of positions.
static const PositionVector EMPTY
empty Vector
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), 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:201
double speed
custom speed for connection
Definition: NBEdge.h:257
KeepClear keepClear
whether the junction must be kept clear when using this connection
Definition: NBEdge.h:248
double customLength
custom length for connection
Definition: NBEdge.h:263
bool uncontrolled
check if Connection is uncontrolled
Definition: NBEdge.h:314
PositionVector customShape
custom shape for connection
Definition: NBEdge.h:266
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
Definition: NBEdge.h:245
double contPos
custom position for internal junction on this connection
Definition: NBEdge.h:251
double visibility
custom foe visiblity for connection
Definition: NBEdge.h:254
double friction
Definition: NBEdge.h:260