SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIImporter_OpenStreetMap::RelationHandler Class Reference

A class which extracts relevant relation information from a parsed OSM-file. More...

#include <NIImporter_OpenStreetMap.h>

Inheritance diagram for NIImporter_OpenStreetMap::RelationHandler:
SUMOSAXHandler GenericSAXHandler DefaultHandler

Public Member Functions

void characters (const XMLCh *const chars, const XERCES3_SIZE_t length)
 The inherited method called when characters occured.
void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
 The inherited method called when a tag is being closed.
const std::string & getFileName () const
 returns the current file name
void registerParent (const int tag, GenericSAXHandler *handler)
 Assigning a parent handler which is enabled when the specified tag is closed.
 RelationHandler (const std::map< SUMOLong, NIOSMNode * > &osmNodes, const std::map< SUMOLong, Edge * > &osmEdges)
 Constructor.
void setFileName (const std::string &name)
 Sets the current file name.
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.
 ~RelationHandler ()
 Destructor.
SAX ErrorHandler callbacks
void warning (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Handler for XML-warnings.
void error (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Handler for XML-errors.
void fatalError (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Handler for XML-errors.

Protected Member Functions

std::string buildErrorMessage (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Builds an error message.
virtual void myCharacters (int element, const std::string &chars)
 Callback method for characters to implement by derived classes.
inherited from GenericSAXHandler
void myStartElement (int element, const SUMOSAXAttributes &attrs)
 Called on the opening of a tag;.
void myEndElement (int element)
 Called when a closing tag occurs.

Private Types

enum  RestrictionType { RESTRICTION_ONLY, RESTRICTION_NO, RESTRICTION_UNKNOWN }
 whether the only allowed or the only forbidden connection is defined More...

Private Member Functions

bool applyRestriction () const
 try to apply the parsed restriction and return whether successful
bool checkEdgeRef (SUMOLong ref) const
 check whether a referenced way has a corresponding edge
NBEdgefindEdgeRef (SUMOLong wayRef, const std::vector< NBEdge * > &candidates) const
 try to find the way segment among candidates
RelationHandleroperator= (const RelationHandler &s)
 invalidated assignment operator
 RelationHandler (const RelationHandler &s)
 invalidated copy constructor
void resetValues ()
 reset members to their defaults for parsing a new relation

Private Attributes

SUMOLong myCurrentRelation
 The currently parsed relation.
SUMOLong myFromWay
 the origination way for the current restriction
bool myIsRestriction
 whether the currently parsed relation is a restriction
const std::map< SUMOLong, Edge * > & myOSMEdges
 The previously parsed edges.
const std::map< SUMOLong,
NIOSMNode * > & 
myOSMNodes
 The previously parsed nodes.
std::vector< intmyParentElements
 The element stack.
RestrictionType myRestrictionType
SUMOLong myToWay
 the destination way for the current restriction
SUMOLong myViaNode
 the via node/way for the current restriction
SUMOLong myViaWay

Detailed Description

A class which extracts relevant relation information from a parsed OSM-file.

  • turn restrictions

Definition at line 346 of file NIImporter_OpenStreetMap.h.

Member Enumeration Documentation

whether the only allowed or the only forbidden connection is defined

Enumerator:
RESTRICTION_ONLY 

The only valid connection is declared.

RESTRICTION_NO 

The only invalid connection is declared.

RESTRICTION_UNKNOWN 

The relation tag was missing.

Definition at line 415 of file NIImporter_OpenStreetMap.h.

Constructor & Destructor Documentation

NIImporter_OpenStreetMap::RelationHandler::RelationHandler ( const std::map< SUMOLong, NIOSMNode * > &  osmNodes,
const std::map< SUMOLong, Edge * > &  osmEdges 
)

Constructor.

Parameters
[in]osmNodesThe previously parsed OSM-nodes
[in]osmEdgesThe previously parse OSM-edges

Definition at line 768 of file NIImporter_OpenStreetMap.cpp.

References resetValues().

NIImporter_OpenStreetMap::RelationHandler::~RelationHandler ( )

Destructor.

Definition at line 778 of file NIImporter_OpenStreetMap.cpp.

NIImporter_OpenStreetMap::RelationHandler::RelationHandler ( const RelationHandler s)
private

invalidated copy constructor

Member Function Documentation

bool NIImporter_OpenStreetMap::RelationHandler::applyRestriction ( ) const
private
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 193 of file GenericSAXHandler.cpp.

References GenericSAXHandler::getFileName().

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

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

The inherited method called when characters occured.

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 176 of file GenericSAXHandler.cpp.

References TplConvert::_2str(), and GenericSAXHandler::myCharactersVector.

bool NIImporter_OpenStreetMap::RelationHandler::checkEdgeRef ( SUMOLong  ref) const
private

check whether a referenced way has a corresponding edge

Definition at line 859 of file NIImporter_OpenStreetMap.cpp.

References toString(), and WRITE_WARNING.

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 126 of file GenericSAXHandler.cpp.

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

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 occured exception to process
Exceptions
ProcessErrorOn any call

Definition at line 212 of file GenericSAXHandler.cpp.

References GenericSAXHandler::buildErrorMessage().

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 occured exception to process

Definition at line 218 of file GenericSAXHandler.cpp.

References GenericSAXHandler::buildErrorMessage().

NBEdge * NIImporter_OpenStreetMap::RelationHandler::findEdgeRef ( SUMOLong  wayRef,
const std::vector< NBEdge * > &  candidates 
) const
private

try to find the way segment among candidates

Definition at line 936 of file NIImporter_OpenStreetMap.cpp.

References toString(), and WRITE_WARNING.

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_ITSUMO::Handler.

Definition at line 228 of file GenericSAXHandler.cpp.

Referenced by GenericSAXHandler::endElement().

void NIImporter_OpenStreetMap::RelationHandler::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 870 of file NIImporter_OpenStreetMap.cpp.

References NIImporter_OpenStreetMap::INVALID_ID, SUMO_TAG_RELATION, toString(), and WRITE_WARNING.

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

Called on the opening of a tag;.

Parameters
[in]elementID of the currently opened element
[in]attrsAttributes within the currently opened element
Exceptions
ProcessErrorIf something fails
See Also
GenericSAXHandler::myStartElement

Reimplemented from GenericSAXHandler.

Definition at line 793 of file NIImporter_OpenStreetMap.cpp.

References SUMOSAXAttributes::get(), SUMOSAXAttributes::getStringSecure(), SUMOSAXAttributes::hasAttribute(), NIImporter_OpenStreetMap::INVALID_ID, NIImporter_OpenStreetMap::myOSMNodes, SUMO_ATTR_ID, SUMO_ATTR_K, SUMO_ATTR_REF, SUMO_ATTR_TYPE, SUMO_ATTR_V, SUMO_TAG_MEMBER, SUMO_TAG_RELATION, SUMO_TAG_TAG, SUMOLong, toString(), and WRITE_WARNING.

RelationHandler& NIImporter_OpenStreetMap::RelationHandler::operator= ( const RelationHandler s)
private

invalidated assignment operator

void GenericSAXHandler::registerParent ( const int  tag,
GenericSAXHandler handler 
)
inherited
void NIImporter_OpenStreetMap::RelationHandler::resetValues ( )
private

reset members to their defaults for parsing a new relation

Definition at line 782 of file NIImporter_OpenStreetMap.cpp.

References NIImporter_OpenStreetMap::INVALID_ID.

Referenced by RelationHandler().

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 80 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_OpenDrive::loadNetwork(), and XMLSubSys::runParser().

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 105 of file GenericSAXHandler.cpp.

References TplConvert::_2str(), GenericSAXHandler::convertTag(), FileHelpers::getConfigurationRelative(), GenericSAXHandler::getFileName(), SUMOSAXAttributesImpl_Xerces::getString(), FileHelpers::isAbsolute(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myPredefinedTags, GenericSAXHandler::myPredefinedTagsMML, GenericSAXHandler::myStartElement(), XMLSubSys::runParser(), SUMO_ATTR_HREF, and SUMO_TAG_INCLUDE.

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 occured exception to process

Definition at line 206 of file GenericSAXHandler.cpp.

References GenericSAXHandler::buildErrorMessage(), and WRITE_WARNING.

Field Documentation

SUMOLong NIImporter_OpenStreetMap::RelationHandler::myCurrentRelation
private

The currently parsed relation.

Definition at line 393 of file NIImporter_OpenStreetMap.h.

SUMOLong NIImporter_OpenStreetMap::RelationHandler::myFromWay
private

the origination way for the current restriction

Definition at line 402 of file NIImporter_OpenStreetMap.h.

bool NIImporter_OpenStreetMap::RelationHandler::myIsRestriction
private

whether the currently parsed relation is a restriction

Definition at line 399 of file NIImporter_OpenStreetMap.h.

const std::map<SUMOLong, Edge*>& NIImporter_OpenStreetMap::RelationHandler::myOSMEdges
private

The previously parsed edges.

Definition at line 390 of file NIImporter_OpenStreetMap.h.

const std::map<SUMOLong, NIOSMNode*>& NIImporter_OpenStreetMap::RelationHandler::myOSMNodes
private

The previously parsed nodes.

Definition at line 387 of file NIImporter_OpenStreetMap.h.

std::vector<int> NIImporter_OpenStreetMap::RelationHandler::myParentElements
private

The element stack.

Definition at line 396 of file NIImporter_OpenStreetMap.h.

RestrictionType NIImporter_OpenStreetMap::RelationHandler::myRestrictionType
private

Definition at line 423 of file NIImporter_OpenStreetMap.h.

SUMOLong NIImporter_OpenStreetMap::RelationHandler::myToWay
private

the destination way for the current restriction

Definition at line 405 of file NIImporter_OpenStreetMap.h.

SUMOLong NIImporter_OpenStreetMap::RelationHandler::myViaNode
private

the via node/way for the current restriction

Definition at line 408 of file NIImporter_OpenStreetMap.h.

SUMOLong NIImporter_OpenStreetMap::RelationHandler::myViaWay
private

Definition at line 409 of file NIImporter_OpenStreetMap.h.


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