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(
"Target edge '%' is not connected with '%'; the connection cannot be reset.", toEdge->
getID(), fromEdge->
getID());
97 if (!
parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) {
103 WRITE_WARNINGF(
"Edge '%' has no connection to lane '%'; the connection cannot be reset.", fromEdge->
getID(), toEdge->
getLaneID(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());
241 if (existing.size() > 0) {
242 assert(existing.size() == 1);
243 defaultCon = existing.front();
264 if (allow ==
"" && disallow ==
"") {
271 WRITE_ERROR(
"Unable to project shape for connection from edge '" + from->
getID() +
"' to edge '" + to->
getID() +
"'.");
277 keepClear, contPos, visibility, speed, length, customShape, uncontrolled, permissions)) {
282 myEdgeCont.
addPostProcessConnection(from->
getID(), fromLane, to->
getID(), toLane, mayDefinitelyPass, keepClear, contPos, visibility, speed, length, customShape, uncontrolled,
false, permissions);
291 int* fromLane,
int* toLane) {
303 int* fromLane,
int* toLane) {
314 if (!ok || st.size() != 2) {
316 from->
getID() +
"' to '" + to->
getID() +
"'.");
348 if (node ==
nullptr) {
350 WRITE_ERROR(
"Node '" + nodeID +
"' in crossing is not known.");
356 node->discardAllCrossings(
true);
359 WRITE_ERROR(
"No edges specified for crossing at node '" + nodeID +
"'.");
363 for (
const std::string&
id : attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
365 if (edge ==
nullptr) {
367 WRITE_ERROR(
"Edge '" +
id +
"' for crossing at node '" + nodeID +
"' is not known.");
375 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
380 edges.push_back(edge);
386 if (node->isTLControlled() && !priority) {
388 WRITE_WARNING(
"Crossing at controlled node '" + nodeID +
"' must be prioritized");
393 WRITE_ERROR(
"Unable to project shape for crossing at node '" + node->getID() +
"'.");
396 node->removeCrossing(edges);
398 if (node->checkCrossingDuplicated(edges)) {
406 WRITE_ERROR(
"Crossing with edges '" +
toString(edges) +
"' already exists at node '" + node->getID() +
"'.");
411 width = existing->
width;
422 node->removeCrossing(edges);
425 node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
436 std::vector<std::string> edgeIDs;
438 WRITE_ERROR(
"No edges specified for walkingArea at node '" + nodeID +
"'.");
441 for (
const std::string&
id : attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
443 if (edge ==
nullptr) {
444 WRITE_ERROR(
"Edge '" +
id +
"' for walkingArea at node '" + nodeID +
"' is not known.");
447 if (node ==
nullptr) {
453 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
458 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
462 edges.push_back(edge);
469 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_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.
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.
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.
bool addEdge2EdgeConnection(NBEdge *dest, bool overrideRemoval=false)
Adds a connection to another edge.
EdgeBuildingStep getStep() const
The building step of this edge.
const std::string & getID() const
NBNode * getToNode() const
Returns the destination node of the edge.
@ 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.
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.
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.
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.
NBNode * getFromNode() const
Returns the origin node of the edge.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
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.
SumoXMLNodeType getType() const
Returns the type of this node.
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
void addWalkingAreaShape(EdgeVector edges, const PositionVector &shape)
add custom shape for walkingArea
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, 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