29 #include <xercesc/sax/HandlerBase.hpp> 30 #include <xercesc/sax/AttributeList.hpp> 31 #include <xercesc/sax/SAXParseException.hpp> 32 #include <xercesc/sax/SAXException.hpp> 58 myHaveWarnedAboutDeprecatedLanes(false),
59 myErrorMsgHandler(
OptionsCont::getOptions().getBool(
"ignore-errors.connections") ?
82 if (fromEdge ==
nullptr) {
86 if (toEdge ==
nullptr) {
91 WRITE_WARNING(
"Target edge '" + toEdge->
getID() +
"' is not connected with '" + fromEdge->
getID() +
"'; the connection cannot be reset.");
99 if (!
parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) {
105 WRITE_WARNING(
"Edge '" + fromEdge->
getID() +
"' has no connection to lane " +
toString(toLane) +
" of edge '" + toEdge->
getID() +
"'; the connection cannot be reset.");
122 if (fromEdge ==
nullptr) {
126 if (toEdge ==
nullptr && to.length() != 0) {
166 const std::string::size_type div = def.find(
"->");
167 if (div == std::string::npos) {
171 std::string fromDef = def.substr(0, div);
172 std::string toDef = def.substr(div + 2);
176 if (fromDef.find(
'_') != std::string::npos) {
177 fromDef = fromDef.substr(0, fromDef.find(
'_'));
179 if (toDef.find(
'_') != std::string::npos) {
180 toDef = toDef.substr(0, toDef.find(
'_'));
186 if (fromE ==
nullptr) {
190 if (toE ==
nullptr) {
215 from->
getID() +
"' to '" + to->
getID() +
"'.");
221 from->
getID() +
"' to '" + to->
getID() +
"'.");
232 if (existing.size() > 0) {
233 assert(existing.size() == 1);
234 defaultCon = existing.front();
241 const bool mayDefinitelyPass = attrs.
getOpt<
bool>(
SUMO_ATTR_PASS,
nullptr, ok, defaultCon.mayDefinitelyPass);
249 WRITE_ERROR(
"Unable to project shape for connection from edge '" + from->
getID() +
"' to edge '" + to->
getID() +
"'.");
255 keepClear, contPos, visibility, speed, customShape, uncontrolled)) {
260 myEdgeCont.
addPostProcessConnection(from->
getID(), fromLane, to->
getID(), toLane, mayDefinitelyPass, keepClear, contPos, visibility, speed, customShape, uncontrolled,
false);
269 int* fromLane,
int* toLane) {
281 int* fromLane,
int* toLane) {
292 if (!ok || st.size() != 2) {
294 from->
getID() +
"' to '" + to->
getID() +
"'.");
326 if (node ==
nullptr) {
328 WRITE_ERROR(
"Node '" + nodeID +
"' in crossing is not known.");
334 node->discardAllCrossings(
true);
337 WRITE_ERROR(
"No edges specified for crossing at node '" + nodeID +
"'.");
341 for (
const std::string&
id : attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
343 if (edge ==
nullptr) {
345 WRITE_ERROR(
"Edge '" +
id +
"' for crossing at node '" + nodeID +
"' is not known.");
353 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
358 edges.push_back(edge);
364 if (node->isTLControlled() && !priority) {
366 WRITE_WARNING(
"Crossing at controlled node '" + nodeID +
"' must be prioritized");
371 WRITE_ERROR(
"Unable to project shape for crossing at node '" + node->getID() +
"'.");
374 node->removeCrossing(edges);
376 if (node->checkCrossingDuplicated(edges)) {
384 WRITE_ERROR(
"Crossing with edges '" +
toString(edges) +
"' already exists at node '" + node->getID() +
"'.");
389 width = existing->
width;
400 node->removeCrossing(edges);
403 node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
414 std::vector<std::string> edgeIDs;
416 WRITE_ERROR(
"No edges specified for walkingArea at node '" + nodeID +
"'.");
419 for (
const std::string&
id : attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES, nodeID.c_str(), ok)) {
421 if (edge ==
nullptr) {
422 WRITE_ERROR(
"Edge '" +
id +
"' for walkingArea at node '" + nodeID +
"' is not known.");
425 if (node ==
nullptr) {
431 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
436 WRITE_ERROR(
"Edge '" +
id +
"' does not touch node '" + nodeID +
"'.");
440 edges.push_back(edge);
447 WRITE_ERROR(
"Unable to project shape for walkingArea at node '" + node->
getID() +
"'.");
static const PositionVector EMPTY
empty Vector
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
A structure which describes a connection between edges or lanes.
Whether vehicles must keep the junction clear.
The relationships between edges are computed/loaded.
bool isConnectedTo(const NBEdge *e) const
Returns the information whethe a connection to the given edge has been added (or computed) ...
void addCrossing(const SUMOSAXAttributes &attrs)
Parses a crossing and updates the referenced node.
static const NBConnection InvalidConnection
A container for traffic light definitions and built programs.
bool myHaveWarnedAboutDeprecatedLanes
Information whether we have a deprecated attribute.
static int toIntSecure(const std::string &sData, int def)
converts a string into the integer value described by it
connectio between two lanes
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.
The representation of a single edge during network building.
foe visibility distance of a link
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
NBEdge * getFrom() const
returns the from-edge (start of the connection)
void parseLaneBound(const SUMOSAXAttributes &attrs, NBEdge *from, NBEdge *to)
Parses a connection when it describes a lane-2-lane relationship.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
SAX-handler base for SUMO-files.
bool parseLaneDefinition(const SUMOSAXAttributes &attributes, int *fromLane, int *toLane)
Parses information about lane-2-lane connection.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
static const double UNSPECIFIED_WIDTH
unspecified lane width
prohibition of circulation between two edges
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
link: the index of the opposite direction link of a pedestrian crossing
bool priority
whether the pedestrians have priority
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)
Adds a connection between the specified this edge's lane and an approached one.
NBEdgeCont & myEdgeCont
The edge container to fill.
void invalidateTLS(NBTrafficLightLogicCont &tlCont, bool removedConnections, bool addedConnections)
causes the traffic light to be computed anew
bool parseDeprecatedLaneDefinition(const SUMOSAXAttributes &attributes, NBEdge *fromEdge, NBEdge *toEdge, int *fromLane, int *toLane)
Parses information about lane-2-lane connection in deprecated format.
bool addEdge2EdgeConnection(NBEdge *dest)
Adds a connection to another edge.
NBConnection parseConnection(const std::string &defRole, const std::string &def)
Returns the connection described by def.
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool wasRemoved(std::string id) const
Returns whether the node with the id was deleted explicitly.
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)
Adds a connection which could not be set during loading.
Encapsulated SAX-Attributes.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
std::string getLaneID(int lane) const
get lane ID
walking area for pedestrians
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
bool hasConnectionTo(NBEdge *destEdge, int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
const std::string & getID() const
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NBNodeCont & myNodeCont
The edge container to fill.
Storage for edges, including some functionality operating on multiple edges.
EdgeBuildingStep getStep() const
The building step of this edge.
edge: the shape in xml-definition
The connection was given by the user.
MsgHandler *const myErrorMsgHandler
the handler for loading errors
void addWalkingAreaShape(EdgeVector edges, const PositionVector &shape)
add custom shape for walkingArea
~NIXMLConnectionsHandler()
Destructor.
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.
double width
This crossing's width.
int customTLIndex
the custom traffic light index of this crossing (if controlled)
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
SumoXMLNodeType getType() const
Returns the type of this node.
NIXMLConnectionsHandler(NBEdgeCont &ec, NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Constructor.
crossing between edges for pedestrians
void addWalkingArea(const SUMOSAXAttributes &attrs)
Parses a walkingArea and updates the referenced node.
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)
Represents a single node (junction) during network building.
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
A definition of a pedestrian crossing.
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
add shorted link FOES
link: the index of the link within the traffic light
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.
Container for nodes during the netbuilding process.
Lanes to edges - relationships are computed/loaded.
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to (when invalidating tls)
NBNode * getToNode() const
Returns the destination node of the edge.