
Definition at line 156 of file NIImporter_OpenStreetMap.h.
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 throw () |
| returns the current file name | |
| NodesHandler (std::map< int, NIOSMNode * > &toFill) throw () | |
| Contructor. | |
| void | registerParent (const SumoXMLTag tag, GenericSAXHandler *handler) |
| Assigning a parent handler which is enabled when the specified tag is closed. | |
| void | setFileName (const std::string &name) throw () |
| Sets the current file name. | |
| void | startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs) |
| The inherited method called when a new tag opens. | |
| ~NodesHandler () throw () | |
| Destructor. | |
SAX ErrorHandler callbacks | |
| void | error (const SAXParseException &exception) throw (ProcessError) |
| Handler for XML-errors. | |
| void | fatalError (const SAXParseException &exception) throw (ProcessError) |
| Handler for XML-errors. | |
| void | warning (const SAXParseException &exception) throw () |
| Handler for XML-warnings. | |
Protected Member Functions | |
| std::string | buildErrorMessage (const SAXParseException &exception) throw () |
| Builds an error message. | |
| virtual void | myCharacters (SumoXMLTag element, const std::string &chars) throw (ProcessError) |
| Callback method for characters to implement by derived classes. | |
inherited from GenericSAXHandler | |
| void | myEndElement (SumoXMLTag element) throw (ProcessError) |
| Called when a closing tag occurs. | |
| void | myStartElement (SumoXMLTag element, const SUMOSAXAttributes &attrs) throw (ProcessError) |
| Called on the opening of a tag;. | |
Private Member Functions | |
| NodesHandler (const NodesHandler &s) | |
| invalidated copy constructor | |
| NodesHandler & | operator= (const NodesHandler &s) |
| invalidated assignment operator | |
Private Attributes | |
| int | myHierarchyLevel |
| bool | myIsInValidNodeTag |
| int | myLastNodeID |
| std::map< int, NIOSMNode * > & | myToFill |
| The nodes container to fill. | |
| NIImporter_OpenStreetMap::NodesHandler::NodesHandler | ( | std::map< int, NIOSMNode * > & | toFill | ) | throw () |
Contructor.
| [in] | toFill | The nodes container to fill |
| [in] | options | The options to use |
Definition at line 474 of file NIImporter_OpenStreetMap.cpp.
00475 : SUMOSAXHandler("osm - file"), myToFill(toFill), myLastNodeID(-1), myIsInValidNodeTag(false), myHierarchyLevel(0) {}
| NIImporter_OpenStreetMap::NodesHandler::~NodesHandler | ( | ) | throw () |
| NIImporter_OpenStreetMap::NodesHandler::NodesHandler | ( | const NodesHandler & | s | ) | [private] |
invalidated copy constructor
| std::string SUMOSAXHandler::buildErrorMessage | ( | const SAXParseException & | exception | ) | throw () [protected, inherited] |
Builds an error message.
The error message includes the file name and the line/column information as supported by the given SAXParseException
| [in] | exception | The name of the currently processed file |
Definition at line 55 of file SUMOSAXHandler.cpp.
References GenericSAXHandler::getFileName().
Referenced by SUMOSAXHandler::error(), SUMOSAXHandler::fatalError(), and SUMOSAXHandler::warning().
00055 { 00056 std::ostringstream buf; 00057 char *pMsg = XMLString::transcode(exception.getMessage()); 00058 buf << pMsg << std::endl; 00059 buf << " In file '" << getFileName() << "'" << std::endl; 00060 buf << " At line/column " << exception.getLineNumber()+1 00061 << '/' << exception.getColumnNumber() << "." << std::endl; 00062 XMLString::release(&pMsg); 00063 return buf.str(); 00064 }
| 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.
Definition at line 168 of file GenericSAXHandler.cpp.
References GenericSAXHandler::myCharactersVector.
00169 { 00170 myCharactersVector.push_back(TplConvert<XMLCh>::_2str(chars, length)); 00171 }
| 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.
Definition at line 118 of file GenericSAXHandler.cpp.
References TplConvert< E >::_2str(), GenericSAXHandler::convertTag(), GenericSAXHandler::myCharacters(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myEndElement(), GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, XMLSubSys::setHandler(), SUMO_TAG_INCLUDE, and SUMO_TAG_NOTHING.
00120 { 00121 std::string name = TplConvert<XMLCh>::_2str(qname); 00122 SumoXMLTag element = convertTag(name); 00123 // collect characters 00124 if (myCharactersVector.size()!=0) { 00125 size_t len = 0; 00126 unsigned i; 00127 for (i=0; i<myCharactersVector.size(); ++i) { 00128 len += myCharactersVector[i].length(); 00129 } 00130 char *buf = new char[len+1]; 00131 size_t pos = 0; 00132 for (i=0; i<myCharactersVector.size(); ++i) { 00133 memcpy((unsigned char*) buf+pos, (unsigned char*) myCharactersVector[i].c_str(), 00134 sizeof(char)*myCharactersVector[i].length()); 00135 pos += myCharactersVector[i].length(); 00136 } 00137 buf[pos] = 0; 00138 00139 // call user handler 00140 try { 00141 myCharacters(element, buf); 00142 } catch (std::runtime_error &) { 00143 delete[] buf; 00144 throw; 00145 } 00146 delete[] buf; 00147 } 00148 if (element != SUMO_TAG_INCLUDE) { 00149 myEndElement(element); 00150 if (myParentHandler && myParentIndicator == element) { 00151 XMLSubSys::setHandler(*myParentHandler); 00152 myParentIndicator = SUMO_TAG_NOTHING; 00153 myParentHandler = 0; 00154 } 00155 } 00156 }
| void SUMOSAXHandler::error | ( | const SAXParseException & | exception | ) | throw (ProcessError) [inherited] |
Handler for XML-errors.
The message is built using buildErrorMessage and thrown within a ProcessError.
| [in] | exception | The occured exception to process |
| ProcessError | On any call |
Definition at line 74 of file SUMOSAXHandler.cpp.
References SUMOSAXHandler::buildErrorMessage().
00074 { 00075 throw ProcessError(buildErrorMessage(exception)); 00076 }
| void SUMOSAXHandler::fatalError | ( | const SAXParseException & | exception | ) | throw (ProcessError) [inherited] |
Handler for XML-errors.
The message is built using buildErrorMessage and thrown within a ProcessError.
| ProcessError | On any call |
| [in] | exception | The occured exception to process |
Definition at line 80 of file SUMOSAXHandler.cpp.
References SUMOSAXHandler::buildErrorMessage().
00080 { 00081 throw ProcessError(buildErrorMessage(exception)); 00082 }
| const std::string & GenericSAXHandler::getFileName | ( | ) | const throw () [inherited] |
returns the current file name
Definition at line 78 of file GenericSAXHandler.cpp.
References GenericSAXHandler::myFileName.
Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addEdgeLaneMeanData(), NLHandler::addRouteProbeDetector(), NLHandler::addSource(), NLHandler::addTrigger(), NLHandler::addVTypeProbeDetector(), NLHandler::beginE3Detector(), SUMOSAXHandler::buildErrorMessage(), MSRouteLoader::init(), PCNetProjectionLoader::loadIfSet(), NILoader::loadXMLType(), MSTriggeredXMLReader::myInit(), RODFDetectorHandler::myStartElement(), NLHandler::myStartElement(), NIImporter_OpenDrive::myStartElement(), MSLaneSpeedTrigger::myStartElement(), GUISettingsHandler::myStartElement(), RORDGenerator_ODAmounts::RORDGenerator_ODAmounts(), and GenericSAXHandler::startElement().
00078 { 00079 return myFileName; 00080 }
| void GenericSAXHandler::myCharacters | ( | SumoXMLTag | element, | |
| const std::string & | chars | |||
| ) | throw (ProcessError) [protected, virtual, inherited] |
Callback method for characters to implement by derived classes.
Called by "endElement" (see there).
| [in] | element | The opened element, given as a SumoXMLTag |
| [in] | chars | The complete embedded character string ProcessError These method may throw a ProcessError if something fails |
Reimplemented in ROJTRTurnDefLoader, MSRouteHandler, NIImporter_OpenDrive, NIImporter_SUMO, NLHandler, PCLoaderXML, PCNetProjectionLoader, and RORDLoader_SUMOBase.
Definition at line 189 of file GenericSAXHandler.cpp.
Referenced by GenericSAXHandler::endElement().
| void NIImporter_OpenStreetMap::NodesHandler::myEndElement | ( | SumoXMLTag | element | ) | throw (ProcessError) [protected, virtual] |
Called when a closing tag occurs.
| [in] | element | ID of the currently opened element |
| ProcessError | If something fails |
Reimplemented from GenericSAXHandler.
Definition at line 551 of file NIImporter_OpenStreetMap.cpp.
References myHierarchyLevel, myIsInValidNodeTag, myLastNodeID, and SUMO_TAG_NODE.
00551 { 00552 if (element==SUMO_TAG_NODE && myHierarchyLevel == 2) { 00553 myLastNodeID = -1; 00554 myIsInValidNodeTag = false; 00555 } 00556 --myHierarchyLevel; 00557 }
| void NIImporter_OpenStreetMap::NodesHandler::myStartElement | ( | SumoXMLTag | element, | |
| const SUMOSAXAttributes & | attrs | |||
| ) | throw (ProcessError) [protected, virtual] |
Called on the opening of a tag;.
| [in] | element | ID of the currently opened element |
| [in] | attrs | Attributes within the currently opened element |
| ProcessError | If something fails |
Reimplemented from GenericSAXHandler.
Definition at line 482 of file NIImporter_OpenStreetMap.cpp.
References MsgHandler::getErrorInstance(), NIImporter_OpenStreetMap::NIOSMNode::id, MsgHandler::inform(), NIImporter_OpenStreetMap::NIOSMNode::lat, NIImporter_OpenStreetMap::NIOSMNode::lon, myHierarchyLevel, myIsInValidNodeTag, myLastNodeID, myToFill, SUMO_ATTR_ID, SUMO_ATTR_K, SUMO_ATTR_LAT, SUMO_ATTR_LON, SUMO_ATTR_V, SUMO_TAG_NODE, SUMO_TAG_TAG, NIImporter_OpenStreetMap::NIOSMNode::tlsControlled, and toString().
00482 { 00483 ++myHierarchyLevel; 00484 if (element == SUMO_TAG_NODE) { 00485 if (myHierarchyLevel != 2) { 00486 MsgHandler::getErrorInstance()->inform("Node element on wrong XML hierarchy level."); 00487 return; 00488 } 00489 bool ok = true; 00490 int id = attrs.getIntReporting(SUMO_ATTR_ID, "node", 0, ok); 00491 std::string action = attrs.hasAttribute("action") ? attrs.getStringSecure("action", "") : ""; 00492 if (action=="delete") { 00493 return; 00494 } 00495 if (!ok) { 00496 return; 00497 } 00498 myLastNodeID = -1; 00499 if (myToFill.find(id) == myToFill.end()) { 00500 myLastNodeID = id; 00501 // assume we are loading multiple files... 00502 // ... so we won't report duplicate nodes 00503 bool ok = true; 00504 double tlat, tlon; 00505 std::istringstream lon(attrs.getStringReporting(SUMO_ATTR_LON, "node", toString(id).c_str(), ok)); 00506 if (!ok) { 00507 return; 00508 } 00509 lon >> tlon; 00510 if (lon.fail()) { 00511 MsgHandler::getErrorInstance()->inform("Node's '" + toString(id) + "' lon information is not numeric."); 00512 return; 00513 } 00514 std::istringstream lat(attrs.getStringReporting(SUMO_ATTR_LAT, "node", toString(id).c_str(), ok)); 00515 if (!ok) { 00516 return; 00517 } 00518 lat >> tlat; 00519 if (lat.fail()) { 00520 MsgHandler::getErrorInstance()->inform("Node's '" + toString(id) + "' lat information is not numeric."); 00521 return; 00522 } 00523 NIOSMNode *toAdd = new NIOSMNode(); 00524 toAdd->id = id; 00525 toAdd->tlsControlled = false; 00526 toAdd->lat = tlat; 00527 toAdd->lon = tlon; 00528 myToFill[toAdd->id] = toAdd; 00529 myIsInValidNodeTag = true; 00530 } 00531 } 00532 if (element == SUMO_TAG_TAG && myIsInValidNodeTag) { 00533 if (myHierarchyLevel != 3) { 00534 MsgHandler::getErrorInstance()->inform("Tag element on wrong XML hierarchy level."); 00535 return; 00536 } 00537 bool ok = true; 00538 std::string key = attrs.getStringReporting(SUMO_ATTR_K, "tag", toString(myLastNodeID).c_str(), ok); 00539 std::string value = attrs.getStringReporting(SUMO_ATTR_V, "tag", toString(myLastNodeID).c_str(), ok); 00540 if (!ok) { 00541 return; 00542 } 00543 if (key == "highway" && value.find("traffic_signal") != std::string::npos) { 00544 myToFill[myLastNodeID]->tlsControlled = true; 00545 } 00546 } 00547 }
| NodesHandler& NIImporter_OpenStreetMap::NodesHandler::operator= | ( | const NodesHandler & | s | ) | [private] |
invalidated assignment operator
| void GenericSAXHandler::registerParent | ( | const SumoXMLTag | tag, | |
| GenericSAXHandler * | handler | |||
| ) | [inherited] |
Assigning a parent handler which is enabled when the specified tag is closed.
Definition at line 160 of file GenericSAXHandler.cpp.
References GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, and XMLSubSys::setHandler().
Referenced by NLTriggerBuilder::parseAndBuildLaneSpeedTrigger().
00160 { 00161 myParentHandler = handler; 00162 myParentIndicator = tag; 00163 XMLSubSys::setHandler(*this); 00164 }
| void GenericSAXHandler::setFileName | ( | const std::string & | name | ) | throw () [inherited] |
Sets the current file name.
| [in] | name | The name of the currently processed file |
Definition at line 72 of file GenericSAXHandler.cpp.
References GenericSAXHandler::myFileName.
Referenced by PCNetProjectionLoader::loadIfSet(), ROLoader::loadNet(), NIImporter_OpenStreetMap::loadNetwork(), NILoader::loadXMLType(), and traci::TraCIServer::TraCIServer().
00072 { 00073 myFileName = name; 00074 }
| void GenericSAXHandler::startElement | ( | const XMLCh *const | uri, | |
| const XMLCh *const | localname, | |||
| const XMLCh *const | qname, | |||
| const 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.
Definition at line 97 of file GenericSAXHandler.cpp.
References TplConvert< E >::_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.
00100 { 00101 std::string name = TplConvert<XMLCh>::_2str(qname); 00102 SumoXMLTag element = convertTag(name); 00103 myCharactersVector.clear(); 00104 SUMOSAXAttributesImpl_Xerces na(attrs, myPredefinedTags, myPredefinedTagsMML); 00105 if (element == SUMO_TAG_INCLUDE) { 00106 std::string file = na.getString(SUMO_ATTR_HREF); 00107 if (!FileHelpers::isAbsolute(file)) { 00108 file = FileHelpers::getConfigurationRelative(getFileName(), file); 00109 } 00110 XMLSubSys::runParser(*this, file); 00111 } else { 00112 myStartElement(element, na); 00113 } 00114 }
| void SUMOSAXHandler::warning | ( | const SAXParseException & | exception | ) | throw () [inherited] |
Handler for XML-warnings.
The message is built using buildErrorMessage and reported to the warning-instance of the MsgHandler.
| [in] | exception | The occured exception to process |
Definition at line 68 of file SUMOSAXHandler.cpp.
References SUMOSAXHandler::buildErrorMessage(), MsgHandler::getWarningInstance(), and MsgHandler::inform().
00068 { 00069 MsgHandler::getWarningInstance()->inform(buildErrorMessage(exception)); 00070 }
int NIImporter_OpenStreetMap::NodesHandler::myHierarchyLevel [private] |
Definition at line 199 of file NIImporter_OpenStreetMap.h.
Referenced by myEndElement(), and myStartElement().
Definition at line 198 of file NIImporter_OpenStreetMap.h.
Referenced by myEndElement(), and myStartElement().
int NIImporter_OpenStreetMap::NodesHandler::myLastNodeID [private] |
Definition at line 197 of file NIImporter_OpenStreetMap.h.
Referenced by myEndElement(), and myStartElement().
std::map<int, NIOSMNode*>& NIImporter_OpenStreetMap::NodesHandler::myToFill [private] |
The nodes container to fill.
Definition at line 195 of file NIImporter_OpenStreetMap.h.
Referenced by myStartElement().
1.5.6