27#include <xercesc/sax/HandlerBase.hpp>
28#include <xercesc/sax/AttributeList.hpp>
29#include <xercesc/sax/SAXParseException.hpp>
30#include <xercesc/sax/SAXException.hpp>
56 myHaveWarnedAboutDeprecatedLanes(false),
57 myErrorMsgHandler(
OptionsCont::getOptions().getBool(
"ignore-errors.connections") ?
80 if (fromEdge ==
nullptr) {
84 if (toEdge ==
nullptr) {
89 WRITE_WARNINGF(
TL(
"Target edge '%' is not connected with '%'; the connection cannot be reset."), toEdge->
getID(), fromEdge->
getID());
97 if (!
parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) {
120 if (fromEdge ==
nullptr) {
124 if (toEdge ==
nullptr && to.length() != 0) {
144 WRITE_ERROR(
"No additional connection attributes are permitted in connection from edge '" + fromEdge->
getID() +
"' unless '"
177 const std::string::size_type div = def.find(
"->");
178 if (div == std::string::npos) {
182 std::string fromDef = def.substr(0, div);
183 std::string toDef = def.substr(div + 2);
187 if (fromDef.find(
'_') != std::string::npos) {
188 fromDef = fromDef.substr(0, fromDef.find(
'_'));
190 if (toDef.find(
'_') != std::string::npos) {
191 toDef = toDef.substr(0, toDef.find(
'_'));
197 if (fromE ==
nullptr) {
201 if (toE ==
nullptr) {
225 " in connection from '%' to '%'.", fromLane, from->
getID(), to->
getID());
230 " in connection from '%' to '%'.", toLane, from->
getID(), to->
getID());
238 if (existing.size() > 0) {
239 assert(existing.size() == 1);
240 defaultCon = existing.front();
264 if (allow ==
"" && disallow ==
"") {
279 WRITE_ERROR(
"Unable to project shape for connection from edge '" + from->
getID() +
"' to edge '" + to->
getID() +
"'.");
285 keepClear, contPos, visibility, speed, friction, length, customShape, uncontrolled, permissions, indirectLeft, edgeType, changeLeft, changeRight)) {
291 speed, friction, length, customShape, uncontrolled,
false, permissions, indirectLeft, edgeType, changeLeft, changeRight);
300 int* fromLane,
int* toLane) {
312 int* fromLane,
int* toLane) {
323 if (!ok || st.size() != 2) {
325 from->
getID() +
"' to '" + to->
getID() +
"'.");
357 if (node ==
nullptr) {
359 WRITE_ERROR(
"Node '" + nodeID +
"' in crossing is not known.");
365 node->discardAllCrossings(
true);
368 WRITE_ERROR(
"No edges specified for crossing at node '" + nodeID +
"'.");
372 for (
const std::string&
id : attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
374 if (edge ==
nullptr) {
376 WRITE_ERROR(
"Edge '" +
id +
"' for crossing at node '" + nodeID +
"' is not known.");
384 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
389 edges.push_back(edge);
395 if (node->isTLControlled() && !priority) {
397 WRITE_WARNING(
"Crossing at controlled node '" + nodeID +
"' must be prioritized");
402 WRITE_ERROR(
"Unable to project shape for crossing at node '" + node->getID() +
"'.");
405 node->removeCrossing(edges);
407 if (node->checkCrossingDuplicated(edges)) {
415 WRITE_ERROR(
"Crossing with edges '" +
toString(edges) +
"' already exists at node '" + node->getID() +
"'.");
420 width = existing->
width;
431 node->removeCrossing(edges);
434 node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
445 std::vector<std::string> edgeIDs;
447 WRITE_ERROR(
"No edges specified for walkingArea at node '" + nodeID +
"'.");
450 for (
const std::string&
id : attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
452 if (edge ==
nullptr) {
453 WRITE_ERROR(
"Edge '" +
id +
"' for walkingArea at node '" + nodeID +
"' is not known.");
456 if (node ==
nullptr) {
462 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
467 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
471 edges.push_back(edge);
479 WRITE_ERROR(
"Unable to project shape for walkingArea at node '" + node->
getID() +
"'.");
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
KeepClear
keepClear status of connections
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_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ SUMO_ATTR_INDIRECT
Whether this connection is an indirect (left) turn.
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_VISIBILITY_DISTANCE
foe visibility distance of a link
@ 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)
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
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.
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.
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
The representation of a single edge during network building.
bool addEdge2EdgeConnection(NBEdge *dest, bool overrideRemoval=false)
Adds a connection to another edge.
NBNode * getToNode() const
Returns the destination node of the edge.
EdgeBuildingStep getStep() const
The building step of this edge.
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.
@ 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
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
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)
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)
std::string getLaneID(int lane) const
get lane ID
@ USER
The connection was given by the user.
NBNode * getFromNode() const
Returns the origin node of the edge.
static const double UNSPECIFIED_WIDTH
unspecified lane width
bool hasConnectionTo(NBEdge *destEdge, int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
A definition of a pedestrian crossing.
int customTLIndex
the custom traffic light index of this crossing (if controlled)
bool priority
whether the pedestrians have priority
double width
This crossing's width.
Container for nodes during the netbuilding process.
bool wasRemoved(std::string id) const
Returns whether the node with the id was deleted explicitly.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Represents a single node (junction) during network building.
void addWalkingAreaShape(EdgeVector edges, const PositionVector &shape, double width)
add custom shape for walkingArea
void invalidateTLS(NBTrafficLightLogicCont &tlCont, bool removedConnections, bool addedConnections)
causes the traffic light to be computed anew
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
add shorted link FOES
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.
~NIXMLConnectionsHandler()
Destructor.
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.
A storage for options typed value containers)
static OptionsCont & getOptions()
Retrieves the options.
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.
double speed
custom speed for connection
KeepClear keepClear
whether the junction must be kept clear when using this connection
double customLength
custom length for connection
bool uncontrolled
check if Connection is uncontrolled
PositionVector customShape
custom shape for connection
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
double contPos
custom position for internal junction on this connection
double visibility
custom foe visiblity for connection