Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NIXMLConnectionsHandler.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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>
28#include <netbuild/NBEdge.h>
29#include <netbuild/NBEdgeCont.h>
30#include <netbuild/NBNodeCont.h>
32#include <netbuild/NBNode.h>
42
43
44// ===========================================================================
45// method definitions
46// ===========================================================================
48 SUMOSAXHandler("xml-connection-description"),
49 myEdgeCont(ec),
50 myNodeCont(nc),
51 myTLLogicCont(tlc),
52 myHaveWarnedAboutDeprecatedLanes(false),
53 myErrorMsgHandler(OptionsCont::getOptions().getBool("ignore-errors.connections") ?
54 MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()) {}
55
56
58
59
60void
62 const SUMOSAXAttributes& attrs) {
63 if (element == SUMO_TAG_DEL) {
64 bool ok = true;
65 std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, nullptr, ok);
66 std::string to = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
67 if (!ok) {
68 return;
69 }
70 // these connections were removed when the edge was deleted
71 if (myEdgeCont.wasRemoved(from) || myEdgeCont.wasRemoved(to)) {
72 return;
73 }
74 NBEdge* fromEdge = myEdgeCont.retrieve(from);
75 NBEdge* toEdge = myEdgeCont.retrieve(to);
76 if (fromEdge == nullptr) {
77 myErrorMsgHandler->informf("The connection-source edge '%' to reset is not known.", from);
78 return;
79 }
80 if (toEdge == nullptr) {
81 myErrorMsgHandler->informf("The connection-destination edge '%' to reset is not known.", to);
82 return;
83 }
84 if (!fromEdge->isConnectedTo(toEdge) && fromEdge->getStep() >= NBEdge::EdgeBuildingStep::EDGE2EDGES) {
85 WRITE_WARNINGF(TL("Target edge '%' is not connected with '%'; the connection cannot be reset."), toEdge->getID(), fromEdge->getID());
86 return;
87 }
88 int fromLane = -1; // Assume all lanes are to be reset.
89 int toLane = -1;
93 if (!parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) {
94 return;
95 }
96 // we could be trying to reset a connection loaded from a sumo net and which has become obsolete.
97 // In this case it's ok to encounter invalid lance indices
98 if (!fromEdge->hasConnectionTo(toEdge, toLane) && fromEdge->getStep() >= NBEdge::EdgeBuildingStep::LANES2EDGES) {
99 WRITE_WARNINGF(TL("Edge '%' has no connection to lane '%'; the connection cannot be reset."), fromEdge->getID(), toEdge->getLaneID(toLane));
100 }
101 }
102 fromEdge->removeFromConnections(toEdge, fromLane, toLane, true);
103 }
104
105 if (element == SUMO_TAG_CONNECTION) {
106 bool ok = true;
107 std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, "connection", ok);
108 std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, "connection", ok, "");
109 if (!ok || myEdgeCont.wasIgnored(from) || myEdgeCont.wasIgnored(to)) {
110 return;
111 }
112 // extract edges
113 NBEdge* fromEdge = myEdgeCont.retrieve(from);
114 NBEdge* toEdge = to.length() != 0 ? myEdgeCont.retrieve(to) : nullptr;
115 // check whether they are valid
116 if (fromEdge == nullptr) {
117 myErrorMsgHandler->inform("The connection-source edge '" + from + "' is not known.");
118 return;
119 }
120 if (toEdge == nullptr && to.length() != 0) {
121 myErrorMsgHandler->inform("The connection-destination edge '" + to + "' is not known.");
122 return;
123 }
124 // parse optional lane information
126 parseLaneBound(attrs, fromEdge, toEdge);
127 } else {
128 fromEdge->addEdge2EdgeConnection(toEdge);
129 fromEdge->getToNode()->invalidateTLS(myTLLogicCont, true, false);
140 WRITE_ERROR("No additional connection attributes are permitted in connection from edge '" + fromEdge->getID() + "' unless '"
141 + toString(SUMO_ATTR_FROM_LANE) + "' and '" + toString(SUMO_ATTR_TO_LANE) + "' are set.");
142 }
143 }
144 }
145 if (element == SUMO_TAG_PROHIBITION) {
146 bool ok = true;
147 std::string prohibitor = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITOR, nullptr, ok, "");
148 std::string prohibited = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITED, nullptr, ok, "");
149 if (!ok) {
150 return;
151 }
152 NBConnection prohibitorC = parseConnection("prohibitor", prohibitor);
153 NBConnection prohibitedC = parseConnection("prohibited", prohibited);
154 if (prohibitorC == NBConnection::InvalidConnection || prohibitedC == NBConnection::InvalidConnection) {
155 // something failed
156 return;
157 }
158 NBNode* n = prohibitorC.getFrom()->getToNode();
159 n->addSortedLinkFoes(prohibitorC, prohibitedC);
160 }
161 if (element == SUMO_TAG_CROSSING) {
162 addCrossing(attrs);
163 }
164 if (element == SUMO_TAG_WALKINGAREA) {
165 addWalkingArea(attrs);
166 }
167}
168
169
171NIXMLConnectionsHandler::parseConnection(const std::string& defRole, const std::string& def) {
172 // split from/to
173 const std::string::size_type div = def.find("->");
174 if (div == std::string::npos) {
175 myErrorMsgHandler->inform("Missing connection divider in " + defRole + " '" + def + "'");
177 }
178 std::string fromDef = def.substr(0, div);
179 std::string toDef = def.substr(div + 2);
180
181 // retrieve them now
182 NBEdge* fromE = myEdgeCont.retrieve(fromDef);
183 NBEdge* toE = myEdgeCont.retrieve(toDef);
184 // check
185 if (fromE == nullptr) {
186 myErrorMsgHandler->inform("Could not find edge '" + fromDef + "' in " + defRole + " '" + def + "'");
188 }
189 if (toE == nullptr) {
190 myErrorMsgHandler->inform("Could not find edge '" + toDef + "' in " + defRole + " '" + def + "'");
192 }
193 return NBConnection(fromE, toE);
194}
195
196
197void
199 if (to == nullptr) {
200 // do nothing if it's a dead end
201 return;
202 }
203 bool ok = true;
204 // get the begin and the end lane
205 int fromLane;
206 int toLane;
207 try {
208 if (!parseLaneInfo(attrs, from, to, &fromLane, &toLane)) {
209 return;
210 }
211 if (fromLane < 0) {
212 myErrorMsgHandler->informf("Invalid value '%' for " + toString(SUMO_ATTR_FROM_LANE) +
213 " in connection from '%' to '%'.", fromLane, from->getID(), to->getID());
214 return;
215 }
216 if (toLane < 0) {
217 myErrorMsgHandler->informf("Invalid value '%' for " + toString(SUMO_ATTR_TO_LANE) +
218 " in connection from '%' to '%'.", toLane, from->getID(), to->getID());
219 return;
220 }
221
222 NBEdge::Connection defaultCon(fromLane, to, toLane);
224 // maybe we are patching an existing connection
225 std::vector<NBEdge::Connection> existing = from->getConnectionsFromLane(fromLane, to, toLane);
226 if (existing.size() > 0) {
227 assert(existing.size() == 1);
228 defaultCon = existing.front();
229 // remove the original so we can insert the replacement
230 from->removeFromConnections(defaultCon);
231 } else {
232 from->getToNode()->invalidateTLS(myTLLogicCont, true, false);
233 }
234 }
235 const bool mayDefinitelyPass = attrs.getOpt<bool>(SUMO_ATTR_PASS, nullptr, ok, defaultCon.mayDefinitelyPass);
236 KeepClear keepClear = defaultCon.keepClear;
238 keepClear = attrs.get<bool>(SUMO_ATTR_KEEP_CLEAR, nullptr, ok) ? KEEPCLEAR_TRUE : KEEPCLEAR_FALSE;
239 }
240 const double contPos = attrs.getOpt<double>(SUMO_ATTR_CONTPOS, nullptr, ok, defaultCon.contPos);
241 const double visibility = attrs.getOpt<double>(SUMO_ATTR_VISIBILITY_DISTANCE, nullptr, ok, defaultCon.visibility);
242 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, defaultCon.speed);
243 const double friction = attrs.getOpt<double>(SUMO_ATTR_FRICTION, nullptr, ok, defaultCon.friction);
244 const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, nullptr, ok, defaultCon.customLength);
245 const bool uncontrolled = attrs.getOpt<bool>(SUMO_ATTR_UNCONTROLLED, nullptr, ok, defaultCon.uncontrolled);
246 const bool indirectLeft = attrs.getOpt<bool>(SUMO_ATTR_INDIRECT, nullptr, ok, false);
247 const std::string edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, nullptr, ok, "");
248 PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, defaultCon.customShape);
249 std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, "");
250 std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, "");
251 SVCPermissions permissions;
252 if (allow == "" && disallow == "") {
253 permissions = SVC_UNSPECIFIED;
254 } else {
255 permissions = parseVehicleClasses(attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, ""), attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, ""));
256 }
257 SVCPermissions changeLeft = SVC_UNSPECIFIED;
258 SVCPermissions changeRight = SVC_UNSPECIFIED;
260 changeLeft = parseVehicleClasses(attrs.get<std::string>(SUMO_ATTR_CHANGE_LEFT, nullptr, ok), "");
261 }
263 changeRight = parseVehicleClasses(attrs.get<std::string>(SUMO_ATTR_CHANGE_RIGHT, nullptr, ok), "");
264 }
265
267 WRITE_ERRORF(TL("Unable to project shape for connection from edge '%' to edge '%'."), from->getID(), to->getID());
268 }
269 if (!ok) {
270 return;
271 }
272 if (!from->addLane2LaneConnection(fromLane, to, toLane, NBEdge::Lane2LaneInfoType::USER, true, mayDefinitelyPass,
273 keepClear, contPos, visibility, speed, friction, length, customShape, uncontrolled, permissions, indirectLeft, edgeType, changeLeft, changeRight)) {
274 if (OptionsCont::getOptions().getBool("show-errors.connections-first-try")) {
275 WRITE_WARNINGF(TL("Could not set loaded connection from lane '%' to lane '%'."), from->getLaneID(fromLane), to->getLaneID(toLane));
276 }
277 // set as to be re-applied after network processing
278 myEdgeCont.addPostProcessConnection(from->getID(), fromLane, to->getID(), toLane, mayDefinitelyPass, keepClear, contPos, visibility,
279 speed, friction, length, customShape, uncontrolled, false, permissions, indirectLeft, edgeType, changeLeft, changeRight);
280 }
281 } catch (NumberFormatException&) {
282 myErrorMsgHandler->inform("At least one of the defined lanes was not numeric");
283 }
284}
285
286bool
288 int* fromLane, int* toLane) {
289 if (attributes.hasAttribute(SUMO_ATTR_LANE)) {
290 return parseDeprecatedLaneDefinition(attributes, fromEdge, toEdge, fromLane, toLane);
291 } else {
292 return parseLaneDefinition(attributes, fromLane, toLane);
293 }
294}
295
296
297inline bool
299 NBEdge* from, NBEdge* to,
300 int* fromLane, int* toLane) {
301 bool ok = true;
304 WRITE_WARNING("'" + toString(SUMO_ATTR_LANE) + "' is deprecated, please use '" +
306 "' instead.");
307 }
308
309 std::string laneConn = attributes.get<std::string>(SUMO_ATTR_LANE, nullptr, ok);
310 StringTokenizer st(laneConn, ':');
311 if (!ok || st.size() != 2) {
312 myErrorMsgHandler->inform("Invalid lane to lane connection from '" +
313 from->getID() + "' to '" + to->getID() + "'.");
314 return false; // There was an error.
315 }
316
317 *fromLane = StringUtils::toIntSecure(st.next(), -1);
318 *toLane = StringUtils::toIntSecure(st.next(), -1);
319
320 return true; // We succeeded.
321}
322
323
324inline bool
326 int* fromLane,
327 int* toLane) {
328 bool ok = true;
329 *fromLane = attributes.get<int>(SUMO_ATTR_FROM_LANE, nullptr, ok);
330 *toLane = attributes.get<int>(SUMO_ATTR_TO_LANE, nullptr, ok);
331 return ok;
332}
333
334
335void
337 bool ok = true;
338 EdgeVector edges;
339 const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, nullptr, ok);
340 double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, nodeID.c_str(), ok, NBEdge::UNSPECIFIED_WIDTH, true);
341 const bool discard = attrs.getOpt<bool>(SUMO_ATTR_DISCARD, nodeID.c_str(), ok, false, true);
342 int tlIndex = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok, -1);
343 int tlIndex2 = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX2, nullptr, ok, -1);
344 NBNode* node = myNodeCont.retrieve(nodeID);
345 if (node == nullptr) {
346 if (!discard && myNodeCont.wasRemoved(nodeID)) {
347 WRITE_ERRORF(TL("Node '%' in crossing is not known."), nodeID);
348 }
349 return;
350 }
351 if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
352 if (discard) {
353 node->discardAllCrossings(true);
354 return;
355 } else {
356 WRITE_ERRORF(TL("No edges specified for crossing at node '%'."), nodeID);
357 return;
358 }
359 }
360 for (const std::string& id : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
361 NBEdge* edge = myEdgeCont.retrieve(id);
362 if (edge == nullptr) {
363 if (!(discard && myEdgeCont.wasRemoved(id))) {
364 WRITE_ERRORF(TL("Edge '%' for crossing at node '%' is not known."), id, nodeID);
365 return;
366 } else {
367 edge = myEdgeCont.retrieve(id, true);
368 }
369 } else {
370 if (edge->getToNode() != node && edge->getFromNode() != node) {
371 if (!discard) {
372 WRITE_ERRORF(TL("Edge '%' does not touch node '%'."), id, nodeID);
373 return;
374 }
375 }
376 }
377 edges.push_back(edge);
378 }
379 if (!ok) {
380 return;
381 }
382 bool priority = attrs.getOpt<bool>(SUMO_ATTR_PRIORITY, nodeID.c_str(), ok, node->isTLControlled(), true);
383 if (node->isTLControlled() && !priority) {
384 // traffic_light nodes should always have priority crossings
385 WRITE_WARNINGF(TL("Crossing at controlled node '%' must be prioritized"), nodeID);
386 priority = true;
387 }
389 if (!NBNetBuilder::transformCoordinates(customShape)) {
390 WRITE_ERRORF(TL("Unable to project shape for crossing at node '%'."), node->getID());
391 }
392 if (discard) {
393 node->removeCrossing(edges);
394 } else {
395 if (node->checkCrossingDuplicated(edges)) {
396 // possibly a diff
397 NBNode::Crossing* existing = node->getCrossing(edges);
398 if (!(
399 (attrs.hasAttribute(SUMO_ATTR_WIDTH) && width != existing->width)
400 || (attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX) && tlIndex != existing->customTLIndex)
401 || (attrs.hasAttribute(SUMO_ATTR_TLLINKINDEX2) && tlIndex2 != existing->customTLIndex2)
402 || (attrs.hasAttribute(SUMO_ATTR_PRIORITY) && priority != existing->priority))) {
403 WRITE_ERRORF(TL("Crossing with edges '%' already exists at node '%'."), toString(edges), node->getID());
404 return;
405 } else {
406 // replace existing, keep old attributes
407 if (!attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
408 width = existing->width;
409 }
411 tlIndex = existing->customTLIndex;
412 }
414 tlIndex2 = existing->customTLIndex2;
415 }
416 if (!attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
417 priority = existing->priority;
418 }
419 node->removeCrossing(edges);
420 }
421 }
422 node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
423 }
424}
425
426
427void
429 bool ok = true;
430 NBNode* node = nullptr;
431 EdgeVector edges;
432 const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, nullptr, ok);
433 std::vector<std::string> edgeIDs;
434 if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
435 WRITE_ERRORF(TL("No edges specified for walkingArea at node '%'."), nodeID);
436 return;
437 }
438 for (const std::string& id : attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
439 NBEdge* edge = myEdgeCont.retrieve(id);
440 if (edge == nullptr) {
441 WRITE_ERRORF(TL("Edge '%' for walkingArea at node '%' is not known."), id, nodeID);
442 return;
443 }
444 if (node == nullptr) {
445 if (edge->getToNode()->getID() == nodeID) {
446 node = edge->getToNode();
447 } else if (edge->getFromNode()->getID() == nodeID) {
448 node = edge->getFromNode();
449 } else {
450 WRITE_ERRORF(TL("Edge '%' does not touch node '%'."), id, nodeID);
451 return;
452 }
453 } else {
454 if (edge->getToNode() != node && edge->getFromNode() != node) {
455 WRITE_ERRORF(TL("Edge '%' does not touch node '%'."), id, nodeID);
456 return;
457 }
458 }
459 edges.push_back(edge);
460 }
461 if (!ok) {
462 return;
463 }
465 double customWidth = attrs.getOpt<double>(SUMO_ATTR_WIDTH, nullptr, ok, NBEdge::UNSPECIFIED_WIDTH);
466 if (!NBNetBuilder::transformCoordinates(customShape)) {
467 WRITE_ERRORF(TL("Unable to project shape for walkingArea at node '%'."), node->getID());
468 }
469 node->addWalkingAreaShape(edges, customShape, customWidth);
470}
471
472
473/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:271
#define WRITE_ERRORF(...)
Definition MsgHandler.h:280
#define WRITE_ERROR(msg)
Definition MsgHandler.h:279
#define WRITE_WARNING(msg)
Definition MsgHandler.h:270
#define TL(string)
Definition MsgHandler.h:287
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
connectioon 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
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
Definition MsgHandler.h:122
NBEdge * getFrom() const
returns the from-edge (start of the connection)
static const NBConnection InvalidConnection
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.
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:473
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
Definition NBEdgeCont.h:483
The representation of a single edge during network building.
Definition NBEdge.h:92
NBNode * getToNode() const
Returns the destination node of the edge.
Definition NBEdge.h:536
EdgeBuildingStep getStep() const
The building step of this edge.
Definition NBEdge.h:625
bool addEdge2EdgeConnection(NBEdge *dest, bool overrideRemoval=false, SVCPermissions permission=SVC_UNSPECIFIED)
Adds a connection to another edge.
Definition NBEdge.cpp:1032
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:1067
@ 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:1515
std::vector< Connection > getConnectionsFromLane(int lane, const NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
Definition NBEdge.cpp:1221
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:1382
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:1265
std::string getLaneID(int lane) const
get lane ID
Definition NBEdge.cpp:3870
@ USER
The connection was given by the user.
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition NBEdge.h:529
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition NBEdge.h:341
bool hasConnectionTo(const NBEdge *destEdge, int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
Definition NBEdge.cpp:1259
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
A definition of a pedestrian crossing.
Definition NBNode.h:135
int customTLIndex
the custom traffic light index of this crossing (if controlled)
Definition NBNode.h:163
bool priority
whether the pedestrians have priority
Definition NBNode.h:156
double width
This crossing's width.
Definition NBNode.h:148
Container for nodes during the netbuilding process.
Definition NBNodeCont.h:57
bool wasRemoved(std::string id) const
Returns whether the node with the id was deleted explicitly.
Definition NBNodeCont.h:282
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
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:3594
void invalidateTLS(NBTrafficLightLogicCont &tlCont, bool removedConnections, bool addedConnections)
causes the traffic light to be computed anew
Definition NBNode.cpp:420
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
add shorted link FOES
Definition NBNode.cpp:1843
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.
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:240
KeepClear keepClear
whether the junction must be kept clear when using this connection
Definition NBEdge.h:231
double customLength
custom length for connection
Definition NBEdge.h:246
bool uncontrolled
check if Connection is uncontrolled
Definition NBEdge.h:297
PositionVector customShape
custom shape for connection
Definition NBEdge.h:249
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
Definition NBEdge.h:228
double contPos
custom position for internal junction on this connection
Definition NBEdge.h:234
double visibility
custom foe visiblity for connection
Definition NBEdge.h:237