RONetHandler Class Reference

#include <RONetHandler.h>

Inheritance diagram for RONetHandler:

SUMOSAXHandler GenericSAXHandler

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 jp-router, a reference to the edge builder is given.

Definition at line 57 of file RONetHandler.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.
 RONetHandler (RONet &net, ROAbstractEdgeBuilder &eb)
 Constructor.
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.
virtual ~RONetHandler () 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.
virtual void myEndElement (SumoXMLTag element) throw (ProcessError)
 Callback method for a closing tag to implement by derived classes.
inherited from GenericSAXHandler
virtual void myStartElement (SumoXMLTag element, const SUMOSAXAttributes &attrs) throw (ProcessError)
 Called on the opening of a tag;.
called from myStartElement
void parseConnectedEdge (const SUMOSAXAttributes &attrs)
void parseConnectingEdge (const SUMOSAXAttributes &attrs) throw (ProcessError)
void parseDistrict (const SUMOSAXAttributes &attrs) throw (ProcessError)
void parseDistrictEdge (const SUMOSAXAttributes &attrs, bool isSource)
void parseEdge (const SUMOSAXAttributes &attrs)
 Parses and builds an edge.
void parseJunction (const SUMOSAXAttributes &attrs)
 Parses a junction's position.
virtual void parseLane (const SUMOSAXAttributes &attrs)
 Parses and builds a lane.

Protected Attributes

ROEdgemyCurrentEdge
 The currently built edge.
std::string myCurrentName
 The name of the edge/node that is currently processed.
ROAbstractEdgeBuildermyEdgeBuilder
 The object used to build of edges of the desired type.
bool myHaveWarnedAboutDeprecatedVClass
 Whether deprecated usage of the "vclass" attribute was reported already.
RONetmyNet
 The net to store the information into.
bool myProcess
 An indicator whether the next edge shall be read (internal edges are not read by now).

Private Member Functions

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

Constructor & Destructor Documentation

RONetHandler::RONetHandler ( RONet net,
ROAbstractEdgeBuilder eb 
)

Constructor.

Parameters:
[in] net The network instance to fill
[in] eb The abstract edge builder to use

Definition at line 52 of file RONetHandler.cpp.

00054         : SUMOSAXHandler("sumo-network"),
00055         myNet(net), myCurrentName(),
00056         myCurrentEdge(0), myEdgeBuilder(eb), myHaveWarnedAboutDeprecatedVClass(false) {}

RONetHandler::~RONetHandler (  )  throw () [virtual]

Destructor.

Definition at line 59 of file RONetHandler.cpp.

00059 {}

RONetHandler::RONetHandler ( const RONetHandler src  )  [private]

Invalidated copy constructor.


Member Function Documentation

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

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

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.

Todo:
recheck/describe what happens with characters when a new element is opened
Todo:
describe characters processing in the class' head

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.

Todo:
recheck/describe encoding of the string-representation
Todo:
do not generate and report the string-representation

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.

Parameters:
[in] exception The occured exception to process
Exceptions:
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.

Exceptions:
ProcessError On any call
Parameters:
[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]

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).

Parameters:
[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().

00189 {}

void GenericSAXHandler::myEndElement ( SumoXMLTag  element  )  throw (ProcessError) [protected, virtual, inherited]

Callback method for a closing tag to implement by derived classes.

Called by "endElement" (see there).

Parameters:
[in] element The closed element, given as a SumoXMLTag ProcessError These method may throw a ProcessError if something fails

Reimplemented in MSRouteHandler, MSLaneSpeedTrigger, MSTriggeredRerouter, NIImporter_OpenDrive, NIImporter_OpenStreetMap::NodesHandler, NIImporter_OpenStreetMap::EdgesHandler, NIImporter_SUMO, NIXMLEdgesHandler, NLHandler, ODDistrictHandler, PCLoaderOSM::NodesHandler, PCLoaderOSM::EdgesHandler, RORDGenerator_ODAmounts, RORDLoader_SUMOBase, RORDLoader_TripDefs, traci::TraCIHandler, and SAXWeightsHandler.

Definition at line 193 of file GenericSAXHandler.cpp.

Referenced by GenericSAXHandler::endElement().

00193 {}

void RONetHandler::myStartElement ( SumoXMLTag  element,
const SUMOSAXAttributes attrs 
) throw (ProcessError) [protected, virtual]

Called on the opening of a tag;.

Parameters:
[in] element ID of the currently opened element
[in] attrs Attributes within the currently opened element
Exceptions:
ProcessError If something fails
See also:
GenericSAXHandler::myStartElement

Reimplemented from GenericSAXHandler.

Definition at line 63 of file RONetHandler.cpp.

References myProcess, parseConnectedEdge(), parseConnectingEdge(), parseDistrict(), parseDistrictEdge(), parseEdge(), parseJunction(), parseLane(), SUMO_TAG_DISTRICT, SUMO_TAG_DSINK, SUMO_TAG_DSOURCE, SUMO_TAG_EDGE, SUMO_TAG_JUNCTION, SUMO_TAG_LANE, SUMO_TAG_SUCC, and SUMO_TAG_SUCCLANE.

00064                                                                                  {
00065     switch (element) {
00066     case SUMO_TAG_EDGE:
00067         // in the first step, we do need the name to allocate the edge
00068         // in the second, we need it to know to which edge we have to add
00069         //  the following edges to
00070         parseEdge(attrs);
00071         break;
00072     case SUMO_TAG_LANE:
00073         if (myProcess) {
00074             parseLane(attrs);
00075         }
00076         break;
00077     case SUMO_TAG_JUNCTION:
00078         parseJunction(attrs);
00079         break;
00080     case SUMO_TAG_SUCC:
00081         parseConnectingEdge(attrs);
00082         break;
00083     case SUMO_TAG_SUCCLANE:
00084         parseConnectedEdge(attrs);
00085         break;
00086     case SUMO_TAG_DISTRICT:
00087         parseDistrict(attrs);
00088         break;
00089     case SUMO_TAG_DSOURCE:
00090         parseDistrictEdge(attrs, true);
00091         break;
00092     case SUMO_TAG_DSINK:
00093         parseDistrictEdge(attrs, false);
00094         break;
00095     default:
00096         break;
00097     }
00098 }

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

Invalidated assignment operator.

void RONetHandler::parseConnectedEdge ( const SUMOSAXAttributes attrs  )  [protected]

Parses an approached edge and lets the approaching know about the connection

Called on the occurence of a "succlane" 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] attrs The attributes (of the "succlane"-element) to parse
Todo:
No exception?

Definition at line 228 of file RONetHandler.cpp.

References ROEdge::addFollower(), RONet::getEdge(), MsgHandler::getErrorInstance(), SUMOSAXAttributes::getStringReporting(), MsgHandler::inform(), myCurrentEdge, myCurrentName, myNet, and SUMO_ATTR_LANE.

Referenced by myStartElement().

00228                                                                {
00229     if (myCurrentEdge==0) {
00230         // earlier error or internal link
00231         return;
00232     }
00233     bool ok = true;
00234     std::string id = attrs.getStringReporting(SUMO_ATTR_LANE, "lane", myCurrentName.c_str(), ok);
00235     if (id=="SUMO_NO_DESTINATION") {
00236         return;
00237     }
00238     ROEdge *succ = myNet.getEdge(id.substr(0, id.rfind('_')));
00239     if (succ!=0) {
00240         // connect edge
00241         myCurrentEdge->addFollower(succ);
00242     } else {
00243         MsgHandler::getErrorInstance()->inform("At edge '" + myCurrentName + "': succeeding edge '" + id + "' does not exist.");
00244     }
00245 }

void RONetHandler::parseConnectingEdge ( const SUMOSAXAttributes attrs  )  throw (ProcessError) [protected]

Begins parsing edges that are approached by an edge

Called on the occurence of a "succ" element, this method retrieves the id of the edge described herein and - using it - the edge itself. Stores the so retrieved edge in "myCurrentEdge". If the given edge is not known, a ProcessError is thrown.

Parameters:
[in] attrs The attributes (of the "succ"-element) to parse
Exceptions:
ProcessError If the edge given in cedge is not known

Definition at line 213 of file RONetHandler.cpp.

References RONet::getEdge(), myCurrentEdge, myNet, and SUMO_ATTR_EDGE.

Referenced by myStartElement().

00213                                                                                     {
00214     bool ok = true;
00215     std::string id = attrs.getStringReporting(SUMO_ATTR_EDGE, 0,0, ok);
00216     if (id[0]==':') {
00217         myCurrentEdge = 0;
00218         return;
00219     }
00220     myCurrentEdge = myNet.getEdge(id);
00221     if (myCurrentEdge==0) {
00222         throw ProcessError("An unknown edge occured (id='" + id + "').");
00223     }
00224 }

void RONetHandler::parseDistrict ( const SUMOSAXAttributes attrs  )  throw (ProcessError) [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] attrs The attributes (of the "district"-element) to parse
Exceptions:
ProcessError If an edge given in district is not known

Definition at line 249 of file RONetHandler.cpp.

References RONet::addEdge(), ROEdge::addFollower(), ROAbstractEdgeBuilder::buildEdge(), ROEdge::ET_DISTRICT, RONet::getEdge(), myCurrentEdge, myCurrentName, myEdgeBuilder, myNet, ROEdge::setType(), and SUMO_ATTR_EDGES.

Referenced by myStartElement().

00249                                                                               {
00250     if (!attrs.setIDFromAttributes("district", myCurrentName)) {
00251         return;
00252     }
00253     myCurrentEdge = myEdgeBuilder.buildEdge(myCurrentName, 0, 0);
00254     myCurrentEdge->setType(ROEdge::ET_DISTRICT);
00255     myNet.addEdge(myCurrentEdge);
00256     myCurrentEdge = myEdgeBuilder.buildEdge(myCurrentName + "-source", 0, 0);
00257     myCurrentEdge->setType(ROEdge::ET_DISTRICT);
00258     myNet.addEdge(myCurrentEdge);
00259     if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
00260         std::vector<std::string> desc = StringTokenizer(attrs.getString(SUMO_ATTR_EDGES)).getVector();
00261         for (std::vector<std::string>::const_iterator i=desc.begin(); i!=desc.end(); ++i) {
00262             ROEdge *edge = myNet.getEdge(*i);
00263             // check whether the edge exists
00264             if (edge==0) {
00265                 throw ProcessError("The edge '" + *i + "' within district '" + myCurrentName + "' is not known.");
00266             }
00267             myCurrentEdge->addFollower(edge);
00268             edge->addFollower(myNet.getEdge(myCurrentName));
00269         }
00270     }
00271 }

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] attrs The attributes to parse
[in] isSource whether a "dsource or a "dsink" was given
Todo:
No exception?

Definition at line 275 of file RONetHandler.cpp.

References ROEdge::addFollower(), RONet::getEdge(), MsgHandler::getErrorInstance(), SUMOSAXAttributes::getStringReporting(), MsgHandler::inform(), myCurrentEdge, myCurrentName, myNet, and SUMO_ATTR_ID.

Referenced by myStartElement().

00275                                                                              {
00276     if (myCurrentEdge==0) {
00277         // earlier error or internal link
00278         return;
00279     }
00280     bool ok = true;
00281     std::string id = attrs.getStringReporting(SUMO_ATTR_ID, "district", myCurrentName.c_str(), ok);
00282     ROEdge *succ = myNet.getEdge(id);
00283     if (succ!=0) {
00284         // connect edge
00285         if (isSource) {
00286             myCurrentEdge->addFollower(succ);
00287         } else {
00288             succ->addFollower(myNet.getEdge(myCurrentName));
00289         }
00290     } else {
00291         MsgHandler::getErrorInstance()->inform("At district '" + myCurrentName + "': succeeding edge '" + id + "' does not exist.");
00292     }
00293 }

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] attrs The 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
Todo:
No exception?

Definition at line 102 of file RONetHandler.cpp.

References RONet::addEdge(), RONet::addNode(), ROAbstractEdgeBuilder::buildEdge(), ROEdge::ET_NORMAL, ROEdge::ET_SINK, ROEdge::ET_SOURCE, MsgHandler::getErrorInstance(), RONet::getNode(), SUMOSAXAttributes::getStringReporting(), MsgHandler::inform(), myCurrentEdge, myCurrentName, myEdgeBuilder, myNet, myProcess, SUMOSAXAttributes::setIDFromAttributes(), ROEdge::setType(), SUMO_ATTR_FROM, SUMO_ATTR_FUNCTION, and SUMO_ATTR_TO.

Referenced by myStartElement().

00102                                                       {
00103     // get the id, report an error if not given or empty...
00104     if (!attrs.setIDFromAttributes("edge", myCurrentName)) {
00105         throw ProcessError();
00106     }
00107     // get the edge
00108     myCurrentEdge = 0;
00109     if (myCurrentName[0]==':') {
00110         // this is an internal edge - we will not use it
00111         //  !!! recheck this; internal edges may be of importance during the dua
00112         return;
00113     }
00114     bool ok = true;
00115     std::string from = attrs.getStringReporting(SUMO_ATTR_FROM, "edge", myCurrentName.c_str(), ok);
00116     std::string to = attrs.getStringReporting(SUMO_ATTR_TO, "edge", myCurrentName.c_str(), ok);
00117     std::string type = attrs.getStringReporting(SUMO_ATTR_FUNCTION, "edge", myCurrentName.c_str(), ok);
00118     if (!ok) {
00119         return;
00120     }
00121     RONode *fromNode = myNet.getNode(from);
00122     if (fromNode==0) {
00123         fromNode = new RONode(from);
00124         myNet.addNode(fromNode);
00125     }
00126     RONode *toNode = myNet.getNode(to);
00127     if (toNode==0) {
00128         toNode = new RONode(to);
00129         myNet.addNode(toNode);
00130     }
00131     // build the edge
00132     myCurrentEdge = myEdgeBuilder.buildEdge(myCurrentName, fromNode, toNode);
00133     myNet.addEdge(myCurrentEdge); // !!! where is the edge deleted when failing?
00134     // !!! secure??
00135     // get the type of the edge
00136     myProcess = true;
00137     if (type=="normal"||type=="connector") {
00138         myCurrentEdge->setType(ROEdge::ET_NORMAL);
00139     } else if (type=="source") {
00140         myCurrentEdge->setType(ROEdge::ET_SOURCE);
00141     } else if (type=="sink") {
00142         myCurrentEdge->setType(ROEdge::ET_SINK);
00143     } else if (type=="internal") {
00144         myProcess = false;
00145     } else {
00146         MsgHandler::getErrorInstance()->inform("Edge '" + myCurrentName + "' has an unknown type.");
00147         return;
00148     }
00149 }

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] attrs The attributes (of the "lane"-element) to parse
Todo:
In fact, the junction should be built given its position.
Todo:
No exception?

Definition at line 189 of file RONetHandler.cpp.

References RONet::addNode(), RONet::getNode(), SUMOSAXAttributes::getSUMORealReporting(), myNet, SUMOSAXAttributes::setIDFromAttributes(), RONode::setPosition(), SUMO_ATTR_X, SUMO_ATTR_Y, and SUMOReal.

Referenced by myStartElement().

00189                                                           {
00190     // get the id, report an error if not given or empty...
00191     std::string id;
00192     if (!attrs.setIDFromAttributes("junction", id)) {
00193         return;
00194     }
00195     // get the position of the node
00196     bool ok = true;
00197     SUMOReal x = attrs.getSUMORealReporting(SUMO_ATTR_X, "junction", id.c_str(), ok);
00198     SUMOReal y = attrs.getSUMORealReporting(SUMO_ATTR_Y, "junction", id.c_str(), ok);
00199     if (ok) {
00200         RONode *n = myNet.getNode(id);
00201         if (n==0) {
00202             n = new RONode(id);
00203             myNet.addNode(n);
00204         }
00205         n->setPosition(Position2D(x, y));
00206     } else {
00207         throw ProcessError();
00208     }
00209 }

void RONetHandler::parseLane ( const SUMOSAXAttributes attrs  )  [protected, virtual]

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] attrs The attributes (of the "lane"-element) to parse
Todo:
No exception?

Definition at line 153 of file RONetHandler.cpp.

References ROEdge::addLane(), SUMOSAXAttributes::getOptStringReporting(), SUMOSAXAttributes::getSUMORealReporting(), myCurrentEdge, myHaveWarnedAboutDeprecatedVClass, myNet, parseVehicleClasses(), SUMOSAXAttributes::setIDFromAttributes(), RONet::setRestrictionFound(), SUMO_ATTR_ALLOW, SUMO_ATTR_DISALLOW, SUMO_ATTR_LENGTH, SUMO_ATTR_MAXSPEED, SUMO_ATTR_VCLASSES, and SUMOReal.

Referenced by myStartElement().

00153                                                       {
00154     if (myCurrentEdge==0) {
00155         // was an internal edge to skip or an error occured
00156         return;
00157     }
00158     std::vector<SUMOVehicleClass> allowed, disallowed;
00159     // get the id, report an error if not given or empty...
00160     std::string id;
00161     if (!attrs.setIDFromAttributes("lane", id)) {
00162         return;
00163     }
00164     // get the speed
00165     bool ok = true;
00166     SUMOReal maxSpeed = attrs.getSUMORealReporting(SUMO_ATTR_MAXSPEED, "lane", id.c_str(), ok);
00167     SUMOReal length = attrs.getSUMORealReporting(SUMO_ATTR_LENGTH, "lane", id.c_str(), ok);
00168     std::string vclasses = attrs.getOptStringReporting(SUMO_ATTR_VCLASSES, "lane", id.c_str(), ok, "");
00169     std::string allow = attrs.getOptStringReporting(SUMO_ATTR_ALLOW, "lane", id.c_str(), ok, "");
00170     std::string disallow = attrs.getOptStringReporting(SUMO_ATTR_DISALLOW, "lane", id.c_str(), ok, "");
00171     if (!ok) {
00172         return;
00173     }
00174     // get the length
00175     // get the vehicle classes
00176     parseVehicleClasses(vclasses, allow, disallow,
00177                         allowed, disallowed, myHaveWarnedAboutDeprecatedVClass);
00178     if (allowed.size()!=0 || disallowed.size() != 0) {
00179         myNet.setRestrictionFound();
00180     }
00181     // add when both values are valid
00182     if (maxSpeed>0&&length>0&&id.length()>0) {
00183         myCurrentEdge->addLane(new ROLane(id, length, maxSpeed, allowed, disallowed));
00184     }
00185 }

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.

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

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.

Todo:
recheck/describe encoding of the string-representation
Todo:
do not generate and report the string-representation

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.

Parameters:
[in] exception The occured exception to process

Definition at line 68 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage(), MsgHandler::getWarningInstance(), and MsgHandler::inform().


Field Documentation

The currently built edge.

Definition at line 188 of file RONetHandler.h.

Referenced by parseConnectedEdge(), parseConnectingEdge(), parseDistrict(), parseDistrictEdge(), parseEdge(), and parseLane().

std::string RONetHandler::myCurrentName [protected]

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

Definition at line 185 of file RONetHandler.h.

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

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

Definition at line 194 of file RONetHandler.h.

Referenced by parseDistrict(), and parseEdge().

Whether deprecated usage of the "vclass" attribute was reported already.

Definition at line 197 of file RONetHandler.h.

Referenced by parseLane().

RONet& RONetHandler::myNet [protected]

The net to store the information into.

Definition at line 182 of file RONetHandler.h.

Referenced by parseConnectedEdge(), parseConnectingEdge(), parseDistrict(), parseDistrictEdge(), parseEdge(), parseJunction(), and parseLane().

An indicator whether the next edge shall be read (internal edges are not read by now).

Definition at line 191 of file RONetHandler.h.

Referenced by myStartElement(), and parseEdge().


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

Generated on Wed May 5 00:06:59 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6