#include <NIImporter_SUMO.h>

Definition at line 53 of file NIImporter_SUMO.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 | |
| 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. | |
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. | |
Static Public Member Functions | |
| static void | loadNetwork (const OptionsCont &oc, NBNetBuilder &nb) |
| Loads content of the optionally given SUMO file. | |
Protected Member Functions | |
| std::string | buildErrorMessage (const SAXParseException &exception) throw () |
| Builds an error message. | |
| NIImporter_SUMO (NBNodeCont &nc) | |
| Constructor. | |
| ~NIImporter_SUMO () throw () | |
| Destructor. | |
inherited from GenericSAXHandler | |
| void | myCharacters (SumoXMLTag element, const std::string &chars) throw (ProcessError) |
| Called when characters occure. | |
| 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 | |
Object instance parsing methods | |
| void | addEdge (const SUMOSAXAttributes &attrs) |
| Parses an edge and stores the values in "myCurrentEdge". | |
| void | addJunction (const SUMOSAXAttributes &attrs) |
| Parses a junction and saves it in the node control. | |
| void | addLane (const SUMOSAXAttributes &attrs) |
| Parses a lane and stores the values in "myCurrentLane". | |
| void | addSuccEdge (const SUMOSAXAttributes &attrs) |
| Parses a succedge-definition and saves it by assigning "myCurrentEdge" and "myCurrentLane" to the read values. | |
| void | addSuccLane (const SUMOSAXAttributes &attrs) |
| Parses a succlane-definition and saves it into the lane's definition stored in "myCurrentLane". | |
Private Attributes | |
| EdgeAttrs * | myCurrentEdge |
| The currently parsed edge's definition (to add loaded lanes to). | |
| LaneAttrs * | myCurrentLane |
| The currently parsed lanes's definition (to add the shape to). | |
| std::map< std::string, EdgeAttrs * > | myEdges |
| Loaded edge definitions. | |
| NBNodeCont & | myNodeCont |
| The node container to fill. | |
Data Structures | |
| struct | EdgeAttrs |
| Describes the values found in an edge's definition and this edge's lanes. More... | |
| struct | EdgeLane |
| A connection description, made of a destination lane. More... | |
| struct | LaneAttrs |
| Describes the values found in a lane's definition. More... | |
| NIImporter_SUMO::NIImporter_SUMO | ( | NBNodeCont & | nc | ) | [protected] |
Constructor.
| [in] | nc | The node control to fill |
Definition at line 147 of file NIImporter_SUMO.cpp.
00148 : SUMOSAXHandler("sumo-network"), 00149 myNodeCont(nc), myCurrentEdge(0) {}
| NIImporter_SUMO::~NIImporter_SUMO | ( | ) | throw () [protected] |
| void NIImporter_SUMO::addEdge | ( | const SUMOSAXAttributes & | attrs | ) | [private] |
Parses an edge and stores the values in "myCurrentEdge".
| [in] | attrs | The attributes to get the edge's values from |
Definition at line 220 of file NIImporter_SUMO.cpp.
References NIImporter_SUMO::EdgeAttrs::builtEdge, NIImporter_SUMO::EdgeAttrs::fromNode, SUMOSAXAttributes::getOptIntReporting(), SUMOSAXAttributes::getOptStringReporting(), NIImporter_SUMO::EdgeAttrs::id, NIImporter_SUMO::EdgeAttrs::maxSpeed, myCurrentEdge, NIImporter_SUMO::EdgeAttrs::priority, SUMOSAXAttributes::setIDFromAttributes(), SUMO_ATTR_FROM, SUMO_ATTR_PRIORITY, SUMO_ATTR_TO, SUMO_ATTR_TYPE, NIImporter_SUMO::EdgeAttrs::toNode, and NIImporter_SUMO::EdgeAttrs::type.
Referenced by myStartElement().
00220 { 00221 // get the id, report an error if not given or empty... 00222 std::string id; 00223 if (!attrs.setIDFromAttributes("edge", id)) { 00224 return; 00225 } 00226 bool ok = true; 00227 myCurrentEdge = new EdgeAttrs; 00228 myCurrentEdge->id = id; 00229 // get the type 00230 myCurrentEdge->type = attrs.getOptStringReporting(SUMO_ATTR_TYPE, "edge", id.c_str(), ok, ""); 00231 // get the origin and the destination node 00232 myCurrentEdge->fromNode = attrs.getOptStringReporting(SUMO_ATTR_FROM, "edge", id.c_str(), ok, ""); 00233 myCurrentEdge->toNode = attrs.getOptStringReporting(SUMO_ATTR_TO, "edge", id.c_str(), ok, ""); 00234 myCurrentEdge->priority = attrs.getOptIntReporting(SUMO_ATTR_PRIORITY, "edge", id.c_str(), ok, -1); 00235 myCurrentEdge->maxSpeed = 0; 00236 myCurrentEdge->builtEdge = 0; 00237 }
| void NIImporter_SUMO::addJunction | ( | const SUMOSAXAttributes & | attrs | ) | [private] |
Parses a junction and saves it in the node control.
| [in] | attrs | The attributes to get the junction's values from |
Definition at line 254 of file NIImporter_SUMO.cpp.
References MsgHandler::getErrorInstance(), SUMOSAXAttributes::getOptSUMORealReporting(), MsgHandler::inform(), NBNodeCont::insert(), myNodeCont, SUMOSAXAttributes::setIDFromAttributes(), SUMO_ATTR_X, SUMO_ATTR_Y, SUMOReal, and GeoConvHelper::x2cartesian().
Referenced by myStartElement().
00254 { 00255 // get the id, report an error if not given or empty... 00256 std::string id; 00257 if (!attrs.setIDFromAttributes("junction", id)) { 00258 return; 00259 } 00260 if (id[0]==':') { 00261 return; 00262 } 00263 bool ok = true; 00264 SUMOReal x = attrs.getOptSUMORealReporting(SUMO_ATTR_X, "junction", id.c_str(), ok, -1); 00265 SUMOReal y = attrs.getOptSUMORealReporting(SUMO_ATTR_Y, "junction", id.c_str(), ok, -1); 00266 // !!! this is too simplified! A proper error check should be done 00267 if (x==-1||y==-1) { 00268 MsgHandler::getErrorInstance()->inform("Junction '" + id + "' has an invalid position."); 00269 return; 00270 } 00271 Position2D pos(x, y); 00272 if (!GeoConvHelper::x2cartesian(pos)) { 00273 MsgHandler::getErrorInstance()->inform("Unable to project coordinates for junction " + id + "."); 00274 return; 00275 } 00276 NBNode *node = new NBNode(id, pos); 00277 if (!myNodeCont.insert(node)) { 00278 MsgHandler::getErrorInstance()->inform("Problems on adding junction '" + id + "'."); 00279 delete node; 00280 return; 00281 } 00282 }
| void NIImporter_SUMO::addLane | ( | const SUMOSAXAttributes & | attrs | ) | [private] |
Parses a lane and stores the values in "myCurrentLane".
| [in] | attrs | The attributes to get the lane's values from |
Definition at line 241 of file NIImporter_SUMO.cpp.
References NIImporter_SUMO::LaneAttrs::depart, SUMOSAXAttributes::getOptBoolReporting(), SUMOSAXAttributes::getOptSUMORealReporting(), SUMOSAXAttributes::getStringReporting(), SUMOSAXAttributes::hasAttribute(), NIImporter_SUMO::LaneAttrs::maxSpeed, myCurrentLane, GeomConvHelper::parseShapeReporting(), NIImporter_SUMO::LaneAttrs::shape, SUMO_ATTR_DEPART, SUMO_ATTR_MAXSPEED, and SUMO_ATTR_SHAPE.
Referenced by myStartElement().
00241 { 00242 myCurrentLane = new LaneAttrs; 00243 bool ok = true; 00244 myCurrentLane->maxSpeed = attrs.getOptSUMORealReporting(SUMO_ATTR_MAXSPEED, "lane", 0, ok, -1); 00245 myCurrentLane->depart = attrs.getOptBoolReporting(SUMO_ATTR_DEPART, 0, 0, ok, false); 00246 if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) { 00247 // @deprecated At some time, SUMO_ATTR_SHAPE will be mandatory 00248 myCurrentLane->shape = GeomConvHelper::parseShapeReporting(attrs.getStringReporting(SUMO_ATTR_SHAPE, "lane", 0, ok), "lane", 0, ok, false); 00249 } 00250 }
| void NIImporter_SUMO::addSuccEdge | ( | const SUMOSAXAttributes & | attrs | ) | [private] |
Parses a succedge-definition and saves it by assigning "myCurrentEdge" and "myCurrentLane" to the read values.
| [in] | attrs | The attributes to get the succedge-definition from |
Definition at line 286 of file NIImporter_SUMO.cpp.
References TplConvert< E >::_2int(), MsgHandler::getErrorInstance(), SUMOSAXAttributes::getOptStringReporting(), MsgHandler::inform(), myCurrentEdge, myCurrentLane, myEdges, and SUMO_ATTR_LANE.
Referenced by myStartElement().
00286 { 00287 bool ok = true; 00288 std::string lane = attrs.getOptStringReporting(SUMO_ATTR_LANE, 0, 0, ok, ""); 00289 std::string edge = lane.substr(0, lane.find('_')); 00290 int index = TplConvert<char>::_2int(lane.substr(lane.find('_')+1).c_str()); 00291 myCurrentEdge = 0; 00292 myCurrentLane = 0; 00293 if (myEdges.find(edge)==myEdges.end()) { 00294 MsgHandler::getErrorInstance()->inform("Unknown edge '" + edge + "' given in succedge."); 00295 return; 00296 } 00297 myCurrentEdge = myEdges.find(edge)->second; 00298 // !!! externalize retrieval of lane index by name 00299 if (myCurrentEdge->lanes.size()<(size_t) index) { 00300 MsgHandler::getErrorInstance()->inform("Unknown lane '" + lane + "' given in succedge."); 00301 return; 00302 } 00303 myCurrentLane = myCurrentEdge->lanes[(size_t) index]; 00304 }
| void NIImporter_SUMO::addSuccLane | ( | const SUMOSAXAttributes & | attrs | ) | [private] |
Parses a succlane-definition and saves it into the lane's definition stored in "myCurrentLane".
| [in] | attrs | The attributes to get the succlane-definition from |
Definition at line 308 of file NIImporter_SUMO.cpp.
References NIImporter_SUMO::LaneAttrs::connections, SUMOSAXAttributes::getOptStringReporting(), NIImporter_SUMO::EdgeLane::lane, myCurrentLane, and SUMO_ATTR_LANE.
Referenced by myStartElement().
00308 { 00309 if (myCurrentLane==0) { 00310 // had error 00311 return; 00312 } 00313 bool ok = true; 00314 std::string lane = attrs.getOptStringReporting(SUMO_ATTR_LANE, 0, 0, ok, ""); 00315 EdgeLane el; 00316 el.lane = lane; 00317 myCurrentLane->connections.push_back(el); 00318 }
| 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 NIImporter_SUMO::loadNetwork | ( | const OptionsCont & | oc, | |
| NBNetBuilder & | nb | |||
| ) | [static] |
Loads content of the optionally given SUMO file.
If the option "sumo-net" is set, the file stored therein is read and the network definition stored therein is stored within the given network builder.
If the option "sumo-net" is not set, this method simply returns.
The loading is done by parsing the network definition as an XML file using the SAXinterface and handling the incoming data via this class' methods.
| [in] | oc | The options to use |
| [in] | nb | The network builder to fill |
Definition at line 59 of file NIImporter_SUMO.cpp.
References TplConvert< E >::_2int(), NBEdge::addLane2LaneConnection(), MsgHandler::beginProcessMsg(), NIImporter_SUMO::EdgeAttrs::builtEdge, MsgHandler::endProcessMsg(), FileHelpers::exists(), NIImporter_SUMO::EdgeAttrs::fromNode, NBNetBuilder::getEdgeCont(), MsgHandler::getErrorInstance(), MsgHandler::getMessageInstance(), NBNetBuilder::getNodeCont(), OptionsCont::getStringVector(), NIImporter_SUMO::EdgeAttrs::id, MsgHandler::inform(), NBEdgeCont::insert(), OptionsCont::isUsableFileList(), NBEdge::L2L_VALIDATED, NIImporter_SUMO::EdgeAttrs::lanes, NIImporter_SUMO::EdgeAttrs::maxSpeed, NIImporter_SUMO::EdgeAttrs::priority, NBEdgeCont::retrieve(), NBNodeCont::retrieve(), XMLSubSys::runParser(), NIImporter_SUMO::EdgeAttrs::toNode, and NIImporter_SUMO::EdgeAttrs::type.
Referenced by NILoader::load().
00059 { 00060 // check whether the option is set (properly) 00061 if (!oc.isUsableFileList("sumo-net")) { 00062 return; 00063 } 00064 // build the handler 00065 NIImporter_SUMO handler(nb.getNodeCont()); 00066 // parse file(s) 00067 std::vector<std::string> files = oc.getStringVector("sumo-net"); 00068 for (std::vector<std::string>::const_iterator file=files.begin(); file!=files.end(); ++file) { 00069 if (!FileHelpers::exists(*file)) { 00070 MsgHandler::getErrorInstance()->inform("Could not open sumo-net-file '" + *file + "'."); 00071 return; 00072 } 00073 handler.setFileName(*file); 00074 MsgHandler::getMessageInstance()->beginProcessMsg("Parsing sumo-net from '" + *file + "'..."); 00075 XMLSubSys::runParser(handler, *file); 00076 MsgHandler::getMessageInstance()->endProcessMsg("done."); 00077 } 00078 // build edges 00079 std::map<std::string, EdgeAttrs*> &loadedEdges = handler.myEdges; 00080 NBNodeCont &nodesCont = nb.getNodeCont(); 00081 NBEdgeCont &edgesCont = nb.getEdgeCont(); 00082 for (std::map<std::string, EdgeAttrs*>::const_iterator i=loadedEdges.begin(); i!=loadedEdges.end(); ++i) { 00083 EdgeAttrs *ed = (*i).second; 00084 // get and check the nodes 00085 NBNode *from = nodesCont.retrieve(ed->fromNode); 00086 NBNode *to = nodesCont.retrieve(ed->toNode); 00087 if (from==0) { 00088 MsgHandler::getErrorInstance()->inform("Edge's '" + ed->id + "' from-node '" + ed->fromNode + "' is not known."); 00089 continue; 00090 } 00091 if (to==0) { 00092 MsgHandler::getErrorInstance()->inform("Edge's '" + ed->id + "' to-node '" + ed->toNode + "' is not known."); 00093 continue; 00094 } 00095 // build and insert the edge 00096 NBEdge *e = new NBEdge(ed->id, from, to, ed->type, ed->maxSpeed, (unsigned int) ed->lanes.size(), ed->priority); 00097 if (!edgesCont.insert(e)) { 00098 MsgHandler::getErrorInstance()->inform("Could not insert edge '" + ed->id + "'."); 00099 delete e; 00100 continue; 00101 } 00102 ed->builtEdge = edgesCont.retrieve(ed->id); 00103 } 00104 // assign lane attributes (edges are built) 00105 for (std::map<std::string, EdgeAttrs*>::const_iterator i=loadedEdges.begin(); i!=loadedEdges.end(); ++i) { 00106 EdgeAttrs *ed = (*i).second; 00107 if (ed->builtEdge==0) { 00108 // earlier errors 00109 continue; 00110 } 00111 for (unsigned int j=0; j<(unsigned int) ed->lanes.size(); ++j) { 00112 const std::vector<EdgeLane> &connections = ed->lanes[j]->connections; 00113 for (std::vector<EdgeLane>::const_iterator k=connections.begin(); k!=connections.end(); ++k) { 00114 if ((*k).lane!="SUMO_NO_DESTINATION") { 00115 std::string lane = (*k).lane; 00116 std::string edge = lane.substr(0, lane.find('_')); 00117 int index = TplConvert<char>::_2int(lane.substr(lane.find('_')+1).c_str()); 00118 if (loadedEdges.find(edge)==loadedEdges.end()) { 00119 MsgHandler::getErrorInstance()->inform("Unknown edge given in succlane (for lane '" + lane + "')."); 00120 continue; 00121 } 00122 NBEdge *ce = loadedEdges.find(edge)->second->builtEdge; 00123 if (ce==0) { 00124 // earlier error or edge removal 00125 continue; 00126 } 00127 ed->builtEdge->addLane2LaneConnection(j, ce, index, NBEdge::L2L_VALIDATED); 00128 } 00129 } 00130 } 00131 } 00132 // clean up 00133 for (std::map<std::string, EdgeAttrs*>::const_iterator i=loadedEdges.begin(); i!=loadedEdges.end(); ++i) { 00134 EdgeAttrs *ed = (*i).second; 00135 for (std::vector<LaneAttrs*>::const_iterator j=ed->lanes.begin(); j!=ed->lanes.end(); ++j) { 00136 delete *j; 00137 } 00138 delete ed; 00139 } 00140 }
| void NIImporter_SUMO::myCharacters | ( | SumoXMLTag | element, | |
| const std::string & | chars | |||
| ) | throw (ProcessError) [protected, virtual] |
Called when characters occure.
| [in] | element | ID of the last opened element |
| [in] | chars | The read characters (complete) |
| ProcessError | If something fails |
Reimplemented from GenericSAXHandler.
Definition at line 182 of file NIImporter_SUMO.cpp.
References myCurrentLane, GeomConvHelper::parseShapeReporting(), NIImporter_SUMO::LaneAttrs::shape, and SUMO_TAG_LANE.
00183 { 00184 switch (element) { 00185 case SUMO_TAG_LANE: 00186 // @deprecated At some time, SUMO_ATTR_SHAPE will be mandatory 00187 if (myCurrentLane!=0&&chars.length()!=0) { 00188 bool ok = true; 00189 myCurrentLane->shape = GeomConvHelper::parseShapeReporting(chars, "lane", 0, ok, false); 00190 } 00191 break; 00192 } 00193 }
| void NIImporter_SUMO::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 198 of file NIImporter_SUMO.cpp.
References MsgHandler::getErrorInstance(), NIImporter_SUMO::EdgeAttrs::id, MsgHandler::inform(), NIImporter_SUMO::EdgeAttrs::lanes, MAX2(), NIImporter_SUMO::LaneAttrs::maxSpeed, NIImporter_SUMO::EdgeAttrs::maxSpeed, myCurrentEdge, myCurrentLane, myEdges, SUMO_TAG_EDGE, and SUMO_TAG_LANE.
00198 { 00199 switch (element) { 00200 case SUMO_TAG_EDGE: 00201 if (myEdges.find(myCurrentEdge->id)!=myEdges.end()) { 00202 MsgHandler::getErrorInstance()->inform("Edge '" + myCurrentEdge->id + "' occured at least twice in the input."); 00203 } else { 00204 myEdges[myCurrentEdge->id] = myCurrentEdge; 00205 } 00206 myCurrentEdge = 0; 00207 break; 00208 case SUMO_TAG_LANE: 00209 if (myCurrentEdge!=0) { 00210 myCurrentEdge->maxSpeed = MAX2(myCurrentEdge->maxSpeed, myCurrentLane->maxSpeed); 00211 myCurrentEdge->lanes.push_back(myCurrentLane); 00212 } 00213 myCurrentLane = 0; 00214 break; 00215 } 00216 }
| void NIImporter_SUMO::myStartElement | ( | SumoXMLTag | element, | |
| const SUMOSAXAttributes & | attrs | |||
| ) | throw (ProcessError) [protected, virtual] |
Called on the opening of a tag;.
In dependence to the obtained type, an appropriate parsing method is called ("addEdge" if an edge encounters, f.e.).
| [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 157 of file NIImporter_SUMO.cpp.
References addEdge(), addJunction(), addLane(), addSuccEdge(), addSuccLane(), myCurrentEdge, SUMO_TAG_EDGE, SUMO_TAG_JUNCTION, SUMO_TAG_LANE, SUMO_TAG_SUCC, and SUMO_TAG_SUCCLANE.
00158 { 00159 switch (element) { 00160 case SUMO_TAG_EDGE: 00161 addEdge(attrs); 00162 break; 00163 case SUMO_TAG_LANE: 00164 if (myCurrentEdge!=0) { 00165 addLane(attrs); 00166 } 00167 break; 00168 case SUMO_TAG_JUNCTION: 00169 addJunction(attrs); 00170 break; 00171 case SUMO_TAG_SUCC: 00172 addSuccEdge(attrs); 00173 break; 00174 case SUMO_TAG_SUCCLANE: 00175 addSuccLane(attrs); 00176 break; 00177 } 00178 }
| 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 }
EdgeAttrs* NIImporter_SUMO::myCurrentEdge [private] |
The currently parsed edge's definition (to add loaded lanes to).
Definition at line 215 of file NIImporter_SUMO.h.
Referenced by addEdge(), addSuccEdge(), myEndElement(), and myStartElement().
LaneAttrs* NIImporter_SUMO::myCurrentLane [private] |
The currently parsed lanes's definition (to add the shape to).
Definition at line 218 of file NIImporter_SUMO.h.
Referenced by addLane(), addSuccEdge(), addSuccLane(), myCharacters(), and myEndElement().
std::map<std::string, EdgeAttrs*> NIImporter_SUMO::myEdges [private] |
Loaded edge definitions.
Definition at line 209 of file NIImporter_SUMO.h.
Referenced by addSuccEdge(), and myEndElement().
NBNodeCont& NIImporter_SUMO::myNodeCont [private] |
The node container to fill.
Definition at line 212 of file NIImporter_SUMO.h.
Referenced by addJunction().
1.5.6