36 #include <xercesc/sax/HandlerBase.hpp>
37 #include <xercesc/sax/AttributeList.hpp>
38 #include <xercesc/sax/SAXParseException.hpp>
39 #include <xercesc/sax/SAXException.hpp>
53 #ifdef CHECK_MEMORY_LEAKS
55 #endif // CHECK_MEMORY_LEAKS
64 myHaveWarnedAboutDeprecatedLanes(false),
65 myErrorMsgHandler(
OptionsCont::getOptions().getBool(
"ignore-errors.connections") ?
97 WRITE_WARNING(
"Target edge '" + toEdge->
getID() +
"' is not connected with '" + fromEdge->
getID() +
"'; the connection cannot be reset.");
105 if (!
parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) {
111 WRITE_WARNING(
"Edge '" + fromEdge->
getID() +
"' has no connection to lane " +
toString(toLane) +
" of edge '" + toEdge->
getID() +
"'; the connection cannot be reset.");
132 if (toEdge == 0 && to.length() != 0) {
165 size_t 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(
'_'));
230 if (t->
getID().substr(0, t->
getID().find(
'/')) != nFrom->
getID().substr(0, nFrom->
getID().find(
'/'))) {
253 if (keepUncontrolled) {
260 int* fromLane,
int* toLane) {
272 int* fromLane,
int* toLane) {
283 if (!ok || st.size() != 2) {
285 from->
getID() +
"' to '" + to->
getID() +
"'.");
309 if ((!canLanesBeNegative && fromLane < 0) ||
310 static_cast<unsigned int>(fromLane) >= fromEdge->
getNumLanes()) {
313 fromEdge->
getID() +
"' to '" + toEdge->
getID() +
"'.");
316 if ((!canLanesBeNegative && toLane < 0) ||
317 static_cast<unsigned int>(toLane) >= toEdge->
getNumLanes()) {
320 fromEdge->
getID() +
"' to '" + toEdge->
getID() +
"'.");
The relationships between edges are computed/loaded.
bool myHaveWarnedAboutDeprecatedLanes
Information whether we have a deprecated attribute.
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 getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false)
Adds a connection between the specified this edge's lane and an approached one.
bool validateLaneInfo(bool canLanesBeNegative, NBEdge *fromEdge, NBEdge *toEdge, int fromLane, int toLane)
Validates information about lane-2-lane connection. Returns true iff information represents a valid c...
void parseLaneBound(const SUMOSAXAttributes &attrs, NBEdge *from, NBEdge *to)
Parses a connection when it describes a lane-2-lane relationship.
SAX-handler base for SUMO-files.
bool parseLaneDefinition(const SUMOSAXAttributes &attributes, int *fromLane, int *toLane)
Parses information about lane-2-lane connection.
NBEdge * getFrom() const
returns the from-edge (start of the connection)
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
NBEdgeCont & myEdgeCont
The edge container to fill.
const std::string & getID() const
Returns the id.
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.
bool isConnectedTo(NBEdge *e)
Returns the information whethe a connection to the given edge has been added (or computed) ...
std::string getLaneID(unsigned int lane) const
Encapsulated SAX-Attributes.
unsigned int getNumLanes() const
Returns the number of lanes.
EdgeBuildingStep getStep() const
The building step of this edge.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Storage for edges, including some functionality operating on multiple edges.
NIXMLConnectionsHandler(NBEdgeCont &ec)
Constructor.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
The connection was given by the user.
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false)
Removes the specified connection(s)
MsgHandler *const myErrorMsgHandler
the handler for loading errors
~NIXMLConnectionsHandler()
Destructor.
NBNode * getToNode() const
Returns the destination node of the edge.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
void disableConnection4TLS(int fromLane, NBEdge *toEdge, int toLane)
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
Represents a single node (junction) during network building.
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
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.
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
bool hasConnectionTo(NBEdge *destEdge, unsigned int destLane) const
Retrieves info about a connection to a certain lane of a certain edge.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
static int _2intSec(const E *const data, int def)
Lanes to edges - relationships are computed/loaded.
void addPostProcessConnection(const std::string &from, int fromLane, const std::string &to, int toLane, bool mayDefinitelyPass)
Adds a connection which could not be set during loading.