SUMO - Simulation of Urban MObility
RONetHandler Class Reference

The handler that parses a SUMO-network for its usage in a router. More...

#include <RONetHandler.h>

Inheritance diagram for RONetHandler:
Inheritance graph
Collaboration diagram for RONetHandler:
Collaboration graph

Public Member Functions

void characters (const XMLCh *const chars, const XERCES3_SIZE_t length)
 The inherited method called when characters occurred. More...
 
void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
 The inherited method called when a tag is being closed. More...
 
const std::string & getFileName () const
 returns the current file name More...
 
void registerParent (const int tag, GenericSAXHandler *handler)
 Assigning a parent handler which is enabled when the specified tag is closed. More...
 
 RONetHandler (RONet &net, ROAbstractEdgeBuilder &eb, const bool ignoreInternal)
 Constructor. More...
 
void setFileName (const std::string &name)
 Sets the current file name. More...
 
void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const XERCES_CPP_NAMESPACE::Attributes &attrs)
 The inherited method called when a new tag opens. More...
 
virtual ~RONetHandler ()
 Destructor. More...
 
SAX ErrorHandler callbacks
void warning (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Handler for XML-warnings. More...
 
void error (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Handler for XML-errors. More...
 
void fatalError (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Handler for XML-errors. More...
 

Protected Member Functions

std::string buildErrorMessage (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Builds an error message. More...
 
virtual void myCharacters (int element, const std::string &chars)
 Callback method for characters to implement by derived classes. More...
 
void setSchemaSeen (const bool schemaSeen=true)
 
inherited from GenericSAXHandler
virtual void myStartElement (int element, const SUMOSAXAttributes &attrs)
 Called on the opening of a tag;. More...
 
virtual void myEndElement (int element)
 Called when a closing tag occurs. More...
 
called from myStartElement
void parseEdge (const SUMOSAXAttributes &attrs)
 Parses and builds an edge. More...
 
virtual void parseLane (const SUMOSAXAttributes &attrs)
 Parses and builds a lane. More...
 
void parseJunction (const SUMOSAXAttributes &attrs)
 Parses a junction's position. More...
 
void parseConnection (const SUMOSAXAttributes &attrs)
 
void parseStoppingPlace (const SUMOSAXAttributes &attrs, const SumoXMLTag element)
 
void parseAccess (const SUMOSAXAttributes &attrs)
 
void parseDistrict (const SUMOSAXAttributes &attrs)
 
void parseDistrictEdge (const SUMOSAXAttributes &attrs, bool isSource)
 

Protected Attributes

ROEdgemyCurrentEdge
 The currently built edge. More...
 
std::string myCurrentName
 The name of the edge/node that is currently processed. More...
 
SUMOVehicleParameter::StopmyCurrentStoppingPlace
 The currently built stopping place. More...
 
std::string myCurrentTypeID
 The id of the currently processed edge type. More...
 
ROAbstractEdgeBuildermyEdgeBuilder
 The object used to build of edges of the desired type. More...
 
const bool myIgnoreInternal
 whether to ignore junction internal edges More...
 
RONetmyNet
 The net to store the information into. More...
 
std::set< std::string > myUnseenNodeIDs
 temporary data for checking node initialisation after network parsing is finished More...
 

Private Member Functions

RONetHandleroperator= (const RONetHandler &src)
 Invalidated assignment operator. More...
 
 RONetHandler (const RONetHandler &src)
 Invalidated copy constructor. More...
 

Detailed Description

The handler that parses a SUMO-network for its usage in a router.

SAX2-Handler for SUMO-network loading. As this class is used for both the dua- and the jtrrouter, a reference to the edge builder is given.

Definition at line 53 of file RONetHandler.h.

Constructor & Destructor Documentation

◆ RONetHandler() [1/2]

RONetHandler::RONetHandler ( RONet net,
ROAbstractEdgeBuilder eb,
const bool  ignoreInternal 
)

Constructor.

Parameters
[in]netThe network instance to fill
[in]ebThe abstract edge builder to use

Definition at line 48 of file RONetHandler.cpp.

◆ ~RONetHandler()

RONetHandler::~RONetHandler ( )
virtual

Destructor.

Definition at line 54 of file RONetHandler.cpp.

◆ RONetHandler() [2/2]

RONetHandler::RONetHandler ( const RONetHandler src)
private

Invalidated copy constructor.

Member Function Documentation

◆ buildErrorMessage()

std::string GenericSAXHandler::buildErrorMessage ( const XERCES_CPP_NAMESPACE::SAXParseException &  exception)
protectedinherited

Builds an error message.

The error message includes the file name and the line/column information as supported by the given SAXParseException

Parameters
[in]exceptionThe name of the currently processed file
Returns
A string describing the given exception

Definition at line 187 of file GenericSAXHandler.cpp.

References GenericSAXHandler::getFileName().

Referenced by GenericSAXHandler::error(), GenericSAXHandler::fatalError(), and GenericSAXHandler::warning().

◆ characters()

void GenericSAXHandler::characters ( const XMLCh *const  chars,
const XERCES3_SIZE_t  length 
)
inherited

The inherited method called when characters occurred.

The retrieved characters are converted into a string and appended into a private buffer. They are reported as soon as the element ends.

Todo:

recheck/describe what happens with characters when a new element is opened

describe characters processing in the class' head

Definition at line 170 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myCharactersVector, and StringUtils::transcode().

◆ endElement()

void GenericSAXHandler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname 
)
inherited

The inherited method called when a tag is being closed.

This method calls the user-implemented methods myCharacters with the previously collected and converted characters.

Then, myEndElement is called, supplying it the qname converted to its enum- and string-representations.

Todo:

recheck/describe encoding of the string-representation

do not generate and report the string-representation

Definition at line 121 of file GenericSAXHandler.cpp.

References GenericSAXHandler::convertTag(), GenericSAXHandler::myCharacters(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myEndElement(), GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, XMLSubSys::setHandler(), SUMO_TAG_INCLUDE, SUMO_TAG_NOTHING, and StringUtils::transcode().

◆ error()

void GenericSAXHandler::error ( const XERCES_CPP_NAMESPACE::SAXParseException &  exception)
inherited

Handler for XML-errors.

The message is built using buildErrorMessage and thrown within a ProcessError.

Parameters
[in]exceptionThe occurred exception to process
Exceptions
ProcessErrorOn any call

Definition at line 206 of file GenericSAXHandler.cpp.

References GenericSAXHandler::buildErrorMessage().

Referenced by MSRouteHandler::closeContainer(), MSRouteHandler::closePerson(), NIImporter_OpenDrive::geomFromSpiral(), and MSRouteHandler::myStartElement().

◆ fatalError()

void GenericSAXHandler::fatalError ( const XERCES_CPP_NAMESPACE::SAXParseException &  exception)
inherited

Handler for XML-errors.

The message is built using buildErrorMessage and thrown within a ProcessError.

Exceptions
ProcessErrorOn any call
Parameters
[in]exceptionThe occurred exception to process

Definition at line 212 of file GenericSAXHandler.cpp.

References GenericSAXHandler::buildErrorMessage().

◆ getFileName()

◆ myCharacters()

void GenericSAXHandler::myCharacters ( int  element,
const std::string &  chars 
)
protectedvirtualinherited

Callback method for characters to implement by derived classes.

Called by "endElement" (see there).

Parameters
[in]elementThe opened element, given as a int
[in]charsThe complete embedded character string ProcessError These method may throw a ProcessError if something fails

Reimplemented in NIImporter_OpenDrive, and NIImporter_ITSUMO::Handler.

Definition at line 222 of file GenericSAXHandler.cpp.

Referenced by GenericSAXHandler::endElement().

◆ myEndElement()

void RONetHandler::myEndElement ( int  element)
protectedvirtual

Called when a closing tag occurs.

Parameters
[in]elementID of the currently opened element
Exceptions
ProcessErrorIf something fails
See also
GenericSAXHandler::myEndElement

Reimplemented from GenericSAXHandler.

Definition at line 115 of file RONetHandler.cpp.

References myUnseenNodeIDs, SUMO_TAG_NET, and WRITE_ERROR.

◆ myStartElement()

void RONetHandler::myStartElement ( int  element,
const SUMOSAXAttributes attrs 
)
protectedvirtual

◆ operator=()

RONetHandler& RONetHandler::operator= ( const RONetHandler src)
private

Invalidated assignment operator.

◆ parseAccess()

void RONetHandler::parseAccess ( const SUMOSAXAttributes attrs)
protected

Parses an access point to a train stop Called on the occurence of an "access" element

Parameters
[in]attrsThe attributes to parse

Definition at line 315 of file RONetHandler.cpp.

References SUMOVehicleParameter::Stop::accessPos, SUMORouteHandler::checkStopPos(), SUMOSAXAttributes::get(), RONet::getEdgeForLaneID(), SUMOSAXAttributes::getOpt(), myCurrentStoppingPlace, myNet, SUMO_ATTR_FRIENDLY_POS, SUMO_ATTR_LANE, SUMO_ATTR_LENGTH, SUMO_ATTR_POSITION, and toString().

Referenced by myStartElement().

◆ parseConnection()

void RONetHandler::parseConnection ( const SUMOSAXAttributes attrs)
protected

Parses a connection Called on the occurence of a "connection" element

Parameters
[in]attrsThe attributes (of the "connection"-element) to parse

Definition at line 249 of file RONetHandler.cpp.

References ROEdge::addSuccessor(), SUMOSAXAttributes::get(), RONet::getEdge(), ROEdge::getLanes(), SUMOSAXAttributes::getOpt(), myIgnoreInternal, myNet, SUMO_ATTR_DIR, SUMO_ATTR_FROM, SUMO_ATTR_FROM_LANE, SUMO_ATTR_TO, SUMO_ATTR_TO_LANE, SUMO_ATTR_VIA, and toString().

Referenced by myStartElement().

◆ parseDistrict()

void RONetHandler::parseDistrict ( const SUMOSAXAttributes attrs)
protected

Parses a district and creates a pseudo edge for it

Called on the occurence of a "district" element, this method retrieves the id of the district and creates a district type edge with this id.

Parameters
[in]attrsThe attributes (of the "district"-element) to parse
Exceptions
ProcessErrorIf an edge given in district is not known

Definition at line 336 of file RONetHandler.cpp.

References RONet::addDistrict(), RONet::addDistrictEdge(), ROAbstractEdgeBuilder::buildEdge(), SUMOSAXAttributes::get(), SUMOSAXAttributes::getStringVector(), SUMOSAXAttributes::hasAttribute(), myCurrentEdge, myCurrentName, myEdgeBuilder, myNet, SUMO_ATTR_EDGES, and SUMO_ATTR_ID.

Referenced by myStartElement().

◆ parseDistrictEdge()

void RONetHandler::parseDistrictEdge ( const SUMOSAXAttributes attrs,
bool  isSource 
)
protected

Parses a district edge and connects it to the district

Called on the occurence of a "dsource" or "dsink" element, this method retrieves the id of the approachable edge. If this edge is known and valid, the approaching edge is informed about it (by calling "ROEdge::addFollower").

Parameters
[in]attrsThe attributes to parse
[in]isSourcewhether a "dsource or a "dsink" was given
Todo:
No exception?

Definition at line 355 of file RONetHandler.cpp.

References RONet::addDistrictEdge(), SUMOSAXAttributes::get(), myCurrentName, myNet, and SUMO_ATTR_ID.

Referenced by myStartElement().

◆ parseEdge()

void RONetHandler::parseEdge ( const SUMOSAXAttributes attrs)
protected

Parses and builds an edge.

Parses attributes from an "edge"-element (id, from/to-nodes, function, etc.). If the given nodes are not yet known, they are added to the network. Uses the internal edge builder to build the edge and adds the edge to the network.

Parameters
[in]attrsThe attributes (of the "edge"-element) to parse
Todo:

The edge is "built" first, then the nodes are added; should be done while constructing, probably a legacy issue

No exception?

Definition at line 130 of file RONetHandler.cpp.

References RONet::addEdge(), RONode::addIncoming(), RONet::addNode(), RONode::addOutgoing(), ROAbstractEdgeBuilder::buildEdge(), EDGEFUNC_CROSSING, EDGEFUNC_INTERNAL, EDGEFUNC_WALKINGAREA, SUMOSAXAttributes::get(), SUMOSAXAttributes::getEdgeFunc(), RONet::getNode(), SUMOSAXAttributes::getOpt(), RONet::getRestrictions(), myCurrentEdge, myCurrentName, myEdgeBuilder, myNet, myUnseenNodeIDs, ROEdge::setFunction(), ROEdge::setRestrictions(), SUMO_ATTR_FROM, SUMO_ATTR_ID, SUMO_ATTR_PRIORITY, SUMO_ATTR_TO, SUMO_ATTR_TYPE, and WRITE_ERROR.

Referenced by myStartElement().

◆ parseJunction()

void RONetHandler::parseJunction ( const SUMOSAXAttributes attrs)
protected

Parses a junction's position.

Parses the position of the junction. Sets it to the junction.

Parameters
[in]attrsThe attributes (of the "lane"-element) to parse
Todo:

In fact, the junction should be built given its position.

No exception?

Definition at line 224 of file RONetHandler.cpp.

References SUMOSAXAttributes::get(), RONet::getNode(), SUMOSAXAttributes::getNodeType(), SUMOSAXAttributes::getOpt(), myNet, myUnseenNodeIDs, NODETYPE_INTERNAL, RONode::setPosition(), SUMO_ATTR_ID, SUMO_ATTR_X, SUMO_ATTR_Y, SUMO_ATTR_Z, and WRITE_WARNING.

Referenced by myStartElement().

◆ parseLane()

void RONetHandler::parseLane ( const SUMOSAXAttributes attrs)
protectedvirtual

Parses and builds a lane.

Parses attributes from an "lane"-element (speed, length, vehicle classes, etc.). Builds a ROLane using these attributes (if they are valid) and adds it to the edge.

Parameters
[in]attrsThe attributes (of the "lane"-element) to parse
Todo:
No exception?

Definition at line 189 of file RONetHandler.cpp.

References ROEdge::addLane(), SUMOSAXAttributes::get(), SUMOSAXAttributes::getOpt(), myCurrentEdge, myNet, parseVehicleClasses(), RONet::setPermissionsFound(), SUMO_ATTR_ALLOW, SUMO_ATTR_DISALLOW, SUMO_ATTR_ID, SUMO_ATTR_LENGTH, SUMO_ATTR_SPEED, SVCAll, toString(), and WRITE_WARNING.

Referenced by myStartElement().

◆ parseStoppingPlace()

void RONetHandler::parseStoppingPlace ( const SUMOSAXAttributes attrs,
const SumoXMLTag  element 
)
protected

◆ registerParent()

void GenericSAXHandler::registerParent ( const int  tag,
GenericSAXHandler handler 
)
inherited

◆ setFileName()

void GenericSAXHandler::setFileName ( const std::string &  name)
inherited

Sets the current file name.

Parameters
[in]nameThe name of the currently processed file
Todo:
Hmmm - this is as unsafe as having a direct access to the variable; recheck

Definition at line 69 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myFileName.

Referenced by NIImporter_SUMO::_loadNetwork(), GUISettingsHandler::GUISettingsHandler(), PCNetProjectionLoader::load(), NIImporter_OpenStreetMap::load(), loadNet(), ROLoader::loadNet(), NIImporter_ITSUMO::loadNetwork(), NIImporter_MATSim::loadNetwork(), NIImporter_Vissim::loadXML(), NILoader::loadXMLType(), main(), and XMLSubSys::runParser().

◆ setSchemaSeen()

void GenericSAXHandler::setSchemaSeen ( const bool  schemaSeen = true)
inlineprotectedinherited

◆ startElement()

void GenericSAXHandler::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname,
const XERCES_CPP_NAMESPACE::Attributes &  attrs 
)
inherited

The inherited method called when a new tag opens.

The method parses the supplied XMLCh*-qname using the internal name/enum-map to obtain the enum representation of the attribute name.

Then, "myStartElement" is called supplying the enumeration value, the string-representation of the name and the attributes.

Todo:

recheck/describe encoding of the string-representation

do not generate and report the string-representation

Definition at line 94 of file GenericSAXHandler.cpp.

References GenericSAXHandler::convertTag(), FileHelpers::getConfigurationRelative(), GenericSAXHandler::getFileName(), SUMOSAXAttributesImpl_Xerces::getString(), FileHelpers::isAbsolute(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myExpectedRoot, GenericSAXHandler::myPredefinedTags, GenericSAXHandler::myPredefinedTagsMML, GenericSAXHandler::mySchemaSeen, GenericSAXHandler::myStartElement(), XMLSubSys::runParser(), SUMO_ATTR_HREF, SUMO_TAG_INCLUDE, and StringUtils::transcode().

◆ warning()

void GenericSAXHandler::warning ( const XERCES_CPP_NAMESPACE::SAXParseException &  exception)
inherited

Handler for XML-warnings.

The message is built using buildErrorMessage and reported to the warning-instance of the MsgHandler.

Parameters
[in]exceptionThe occurred exception to process

Definition at line 200 of file GenericSAXHandler.cpp.

References GenericSAXHandler::buildErrorMessage(), and WRITE_WARNING.

Field Documentation

◆ myCurrentEdge

ROEdge* RONetHandler::myCurrentEdge
protected

The currently built edge.

Definition at line 196 of file RONetHandler.h.

Referenced by parseDistrict(), parseEdge(), and parseLane().

◆ myCurrentName

std::string RONetHandler::myCurrentName
protected

The name of the edge/node that is currently processed.

Definition at line 190 of file RONetHandler.h.

Referenced by parseDistrict(), parseDistrictEdge(), and parseEdge().

◆ myCurrentStoppingPlace

SUMOVehicleParameter::Stop* RONetHandler::myCurrentStoppingPlace
protected

The currently built stopping place.

Definition at line 199 of file RONetHandler.h.

Referenced by parseAccess(), and parseStoppingPlace().

◆ myCurrentTypeID

std::string RONetHandler::myCurrentTypeID
protected

The id of the currently processed edge type.

Definition at line 193 of file RONetHandler.h.

Referenced by myStartElement().

◆ myEdgeBuilder

ROAbstractEdgeBuilder& RONetHandler::myEdgeBuilder
protected

The object used to build of edges of the desired type.

Definition at line 184 of file RONetHandler.h.

Referenced by parseDistrict(), and parseEdge().

◆ myIgnoreInternal

const bool RONetHandler::myIgnoreInternal
protected

whether to ignore junction internal edges

Definition at line 187 of file RONetHandler.h.

Referenced by parseConnection().

◆ myNet

RONet& RONetHandler::myNet
protected

The net to store the information into.

Definition at line 181 of file RONetHandler.h.

Referenced by myStartElement(), parseAccess(), parseConnection(), parseDistrict(), parseDistrictEdge(), parseEdge(), parseJunction(), parseLane(), and parseStoppingPlace().

◆ myUnseenNodeIDs

std::set<std::string> RONetHandler::myUnseenNodeIDs
protected

temporary data for checking node initialisation after network parsing is finished

Definition at line 202 of file RONetHandler.h.

Referenced by myEndElement(), parseEdge(), and parseJunction().


The documentation for this class was generated from the following files: