 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
28 #include <xercesc/sax/HandlerBase.hpp>
29 #include <xercesc/sax/AttributeList.hpp>
30 #include <xercesc/sax/SAXParseException.hpp>
31 #include <xercesc/sax/SAXException.hpp>
57 myHaveWarnedAboutDeprecatedLanes(false),
58 myErrorMsgHandler(
OptionsCont::getOptions().getBool(
"ignore-errors.connections") ?
81 if (fromEdge ==
nullptr) {
85 if (toEdge ==
nullptr) {
90 WRITE_WARNINGF(
"Target edge '%' is not connected with '%'; the connection cannot be reset.", toEdge->
getID(), fromEdge->
getID());
98 if (!
parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) {
104 WRITE_WARNINGF(
"Edge '%' has no connection to lane '%'; the connection cannot be reset.", fromEdge->
getID(), toEdge->
getLaneID(toLane));
121 if (fromEdge ==
nullptr) {
125 if (toEdge ==
nullptr && to.length() != 0) {
165 const std::string::size_type div = def.find(
"->");
166 if (div == std::string::npos) {
170 std::string fromDef = def.substr(0, div);
171 std::string toDef = def.substr(div + 2);
175 if (fromDef.find(
'_') != std::string::npos) {
176 fromDef = fromDef.substr(0, fromDef.find(
'_'));
178 if (toDef.find(
'_') != std::string::npos) {
179 toDef = toDef.substr(0, toDef.find(
'_'));
185 if (fromE ==
nullptr) {
189 if (toE ==
nullptr) {
213 " in connection from '%' to '%'.", fromLane, from->
getID(), to->
getID());
218 " in connection from '%' to '%'.", toLane, from->
getID(), to->
getID());
229 if (existing.size() > 0) {
230 assert(existing.size() == 1);
231 defaultCon = existing.front();
248 if (allow ==
"" && disallow ==
"") {
255 WRITE_ERROR(
"Unable to project shape for connection from edge '" + from->
getID() +
"' to edge '" + to->
getID() +
"'.");
261 keepClear, contPos, visibility, speed, customShape, uncontrolled, permissions)) {
266 myEdgeCont.
addPostProcessConnection(from->
getID(), fromLane, to->
getID(), toLane, mayDefinitelyPass, keepClear, contPos, visibility, speed, customShape, uncontrolled,
false, permissions);
275 int* fromLane,
int* toLane) {
287 int* fromLane,
int* toLane) {
298 if (!ok || st.size() != 2) {
300 from->
getID() +
"' to '" + to->
getID() +
"'.");
332 if (node ==
nullptr) {
334 WRITE_ERROR(
"Node '" + nodeID +
"' in crossing is not known.");
340 node->discardAllCrossings(
true);
343 WRITE_ERROR(
"No edges specified for crossing at node '" + nodeID +
"'.");
347 for (
const std::string&
id : attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
349 if (edge ==
nullptr) {
351 WRITE_ERROR(
"Edge '" +
id +
"' for crossing at node '" + nodeID +
"' is not known.");
359 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
364 edges.push_back(edge);
370 if (node->isTLControlled() && !priority) {
372 WRITE_WARNING(
"Crossing at controlled node '" + nodeID +
"' must be prioritized");
377 WRITE_ERROR(
"Unable to project shape for crossing at node '" + node->getID() +
"'.");
380 node->removeCrossing(edges);
382 if (node->checkCrossingDuplicated(edges)) {
390 WRITE_ERROR(
"Crossing with edges '" +
toString(edges) +
"' already exists at node '" + node->getID() +
"'.");
395 width = existing->
width;
406 node->removeCrossing(edges);
409 node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
420 std::vector<std::string> edgeIDs;
422 WRITE_ERROR(
"No edges specified for walkingArea at node '" + nodeID +
"'.");
425 for (
const std::string&
id : attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
427 if (edge ==
nullptr) {
428 WRITE_ERROR(
"Edge '" +
id +
"' for walkingArea at node '" + nodeID +
"' is not known.");
431 if (node ==
nullptr) {
437 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
442 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
446 edges.push_back(edge);
453 WRITE_ERROR(
"Unable to project shape for walkingArea at node '" + node->
getID() +
"'.");
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
const static NBConnection InvalidConnection
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
NBConnection parseConnection(const std::string &defRole, const std::string &def)
Returns the connection described by def.
bool isConnectedTo(const NBEdge *e) const
Returns the information whethe a connection to the given edge has been added (or computed)
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
#define WRITE_WARNING(msg)
Storage for edges, including some functionality operating on multiple edges.
void addPostProcessConnection(const std::string &from, int fromLane, const std::string &to, int toLane, bool mayDefinitelyPass, bool keepClear, double contPos, double visibility, double speed, const PositionVector &customShape, bool uncontrolled, bool warnOnly, SVCPermissions permissions=SVC_UNSPECIFIED)
Adds a connection which could not be set during loading.
SAX-handler base for SUMO-files.
A container for traffic light definitions and built programs.
EdgeBuildingStep getStep() const
The building step of this edge.
bool uncontrolled
check if Connection is uncontrolled
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
double contPos
custom position for internal junction on this connection
void addCrossing(const SUMOSAXAttributes &attrs)
Parses a crossing and updates the referenced node.
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
bool addEdge2EdgeConnection(NBEdge *dest)
Adds a connection to another edge.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
@ EDGE2EDGES
The relationships between edges are computed/loaded.
NBEdge * getFrom() const
returns the from-edge (start of the connection)
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
static OptionsCont & getOptions()
Retrieves the options.
SumoXMLNodeType getType() const
Returns the type of this node.
void addWalkingAreaShape(EdgeVector edges, const PositionVector &shape)
add custom shape for walkingArea
bool parseDeprecatedLaneDefinition(const SUMOSAXAttributes &attributes, NBEdge *fromEdge, NBEdge *toEdge, int *fromLane, int *toLane)
Parses information about lane-2-lane connection in deprecated format.
@ SUMO_ATTR_VISIBILITY_DISTANCE
foe visibility distance of a link
#define WRITE_WARNINGF(...)
@ SUMO_TAG_DELETE
delete certain element
@ L2L_USER
The connection was given by the user.
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
add shorted link FOES
NBEdgeCont & myEdgeCont
The edge container to fill.
Container for nodes during the netbuilding process.
The representation of a single edge during network building.
@ SUMO_TAG_WALKINGAREA
walking area for pedestrians
double speed
custom speed for connection
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
@ SUMO_TAG_PROHIBITION
prohibition of circulation between two edges
void addWalkingArea(const SUMOSAXAttributes &attrs)
Parses a walkingArea and updates the referenced node.
NBNode * getToNode() const
Returns the destination node of the edge.
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 mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
@ SUMO_ATTR_KEEP_CLEAR
Whether vehicles must keep the junction clear.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_ATTR_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
void parseLaneBound(const SUMOSAXAttributes &attrs, NBEdge *from, NBEdge *to)
Parses a connection when it describes a lane-2-lane relationship.
std::string getLaneID(int lane) const
get lane ID
bool priority
whether the pedestrians have priority
@ SUMO_ATTR_EDGES
the edges of a route
NBNodeCont & myNodeCont
The edge container to fill.
A storage for options typed value containers)
static const PositionVector EMPTY
empty Vector
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.
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)
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
int customTLIndex
the custom traffic light index of this crossing (if controlled)
static int toIntSecure(const std::string &sData, int def)
converts a string into the integer value described by it
bool wasRemoved(std::string id) const
Returns whether the node with the id was deleted explicitly.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double width
This crossing's width.
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
NIXMLConnectionsHandler(NBEdgeCont &ec, NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Constructor.
bool keepClear
whether the junction must be kept clear when using this connection
~NIXMLConnectionsHandler()
Destructor.
@ SUMO_TAG_CONNECTION
connectio between two lanes
static const double UNSPECIFIED_WIDTH
unspecified lane width
PositionVector customShape
custom shape for connection
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to (when invalidating tls)
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
MsgHandler *const myErrorMsgHandler
the handler for loading errors
bool myHaveWarnedAboutDeprecatedLanes
Information whether we have a deprecated attribute.
void invalidateTLS(NBTrafficLightLogicCont &tlCont, bool removedConnections, bool addedConnections)
causes the traffic light to be computed anew
bool parseLaneDefinition(const SUMOSAXAttributes &attributes, int *fromLane, int *toLane)
Parses information about lane-2-lane connection.
Represents a single node (junction) during network building.
bool hasConnectionTo(NBEdge *destEdge, int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
A definition of a pedestrian crossing.
A structure which describes a connection between edges or lanes.
double visibility
custom foe visiblity for connection
Encapsulated SAX-Attributes.
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
const std::string & getID() const
Returns the id.
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE, double speed=UNSPECIFIED_SPEED, const PositionVector &customShape=PositionVector::EMPTY, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED, SVCPermissions=SVC_UNSPECIFIED)
Adds a connection between the specified this edge's lane and an approached one.
NBNode * getFromNode() const
Returns the origin node of the edge.
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
@ LANES2LANES_USER
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
@ LANES2EDGES
Lanes to edges - relationships are computed/loaded.
const std::string & getID() const