NIImporter_DlrNavteq::EdgesHandler Class Reference

#include <NIImporter_DlrNavteq.h>

Inheritance diagram for NIImporter_DlrNavteq::EdgesHandler:

LineHandler

Detailed Description

Importer of edges stored in unsplit elmar format.

Being a LineHandler, this class retrieves each line from a LineReader and parses these information assuming they contain edge definitions in DLRNavteq's unsplit format.

Definition at line 138 of file NIImporter_DlrNavteq.h.


Public Member Functions

 EdgesHandler (NBNodeCont &nc, NBEdgeCont &ec, const std::string &file, std::map< std::string, Position2DVector > &geoms) throw ()
 Constructor.
bool report (const std::string &result) throw (ProcessError)
 Parsing method.
 ~EdgesHandler () throw ()
 Destructor.

Protected Attributes

NBEdgeContmyEdgeCont
 The edge container to store loaded edges into.
std::map< std::string,
Position2DVector > & 
myGeoms
 Previously read edge geometries.
NBNodeContmyNodeCont
 The node container to get the referenced nodes from.
bool myTryIgnoreNodePositions
 Whether node positions shall not be added to the edge's geometry.

Private Member Functions

 EdgesHandler (const EdgesHandler &)
 Invalidated copy constructor.
EdgesHandleroperator= (const EdgesHandler &)
 Invalidated assignment operator.

Constructor & Destructor Documentation

NIImporter_DlrNavteq::EdgesHandler::EdgesHandler ( NBNodeCont nc,
NBEdgeCont ec,
const std::string &  file,
std::map< std::string, Position2DVector > &  geoms 
) throw ()

Constructor.

Parameters:
[in] nc The node control to retrieve nodes from
in,filled] ec The edge control to insert loaded edges into
[in] file The name of the parsed file
[in] geoms The previously read edge geometries

Definition at line 175 of file NIImporter_DlrNavteq.cpp.

00179         : myNodeCont(nc), myEdgeCont(ec), myGeoms(geoms) {}

NIImporter_DlrNavteq::EdgesHandler::~EdgesHandler (  )  throw ()

Destructor.

Definition at line 182 of file NIImporter_DlrNavteq.cpp.

00182 {}

NIImporter_DlrNavteq::EdgesHandler::EdgesHandler ( const EdgesHandler  )  [private]

Invalidated copy constructor.


Member Function Documentation

EdgesHandler& NIImporter_DlrNavteq::EdgesHandler::operator= ( const EdgesHandler  )  [private]

Invalidated assignment operator.

bool NIImporter_DlrNavteq::EdgesHandler::report ( const std::string &  result  )  throw (ProcessError) [virtual]

Parsing method.

Implementation of the LineHandler-interface called by a LineReader; interprets the retrieved information and stores it into "myEdgeCont".

Parameters:
[in] result The read line
Returns:
Whether the parsing shall continue
Exceptions:
ProcessError if something fails
See also:
LineHandler::report

Implements LineHandler.

Definition at line 186 of file NIImporter_DlrNavteq.cpp.

References TplConvert< E >::_2int(), TplConvert< E >::_2SUMOReal(), NINavTeqHelper::addVehicleClasses(), NINavTeqHelper::getLaneNumber(), NBNode::getPosition(), NINavTeqHelper::getSpeed(), StringTokenizer::getVector(), NBEdgeCont::insert(), NBEdge::LANESPREAD_CENTER, myEdgeCont, myGeoms, myNodeCont, StringTokenizer::next(), Position2DVector::push_back(), Position2DVector::push_front(), NBNodeCont::retrieve(), Position2DVector::reverse(), SUMOReal, and StringTokenizer::WHITECHARS.

00186                                                                                     {
00187 //  0: LINK_ID  NODE_ID_FROM    NODE_ID_TO  BETWEEN_NODE_ID
00188 //  4: length   vehicle_type    form_of_way brunnel_type
00189 //  7: street_type  speed_category  number_of_lanes average_speed
00190 //  10: NAME_ID1    NAME_ID2    housenumbers_right  housenumbers_left
00191 //  ZIP_CODE    AREA_ID SUBAREA_ID  through_traffic special_restrictions
00192 //  extended_number_of_lanes  isRamp    (these two only exist in networks extracted since 05/2009)
00193 //  connection (this may be omitted)
00194 
00195     if (result[0]=='#') {
00196         return true;
00197     }
00198     std::string id, fromID, toID, interID;
00199     SUMOReal length;
00200     SUMOReal speed = (SUMOReal) 30.0 / (SUMOReal) 3.6;
00201     int nolanes = 1;
00202     int priority = -1;
00203     // parse
00204     StringTokenizer st(result, StringTokenizer::WHITECHARS);
00205     // id
00206     id = st.next();
00207     // from node id
00208     fromID = st.next();
00209     // to node id
00210     toID = st.next();
00211     // intermediate node id
00212     interID = st.next();
00213     // length
00214     try {
00215         length = TplConvert<char>::_2SUMOReal(st.next().c_str());
00216     } catch (NumberFormatException &) {
00217         throw ProcessError("Non-numerical value for an edge's length occured (edge '" + id + "'.");
00218     }
00219     // vehicle_type
00220     std::string veh_type = st.next();
00221     // form_of_way
00222     std::string form_of_way = st.next();
00223     // brunnel_type
00224     std::string brunnel_type = st.next();
00225     // street_type
00226     std::string street_type = st.next();
00227     speed = NINavTeqHelper::getSpeed(id, st.next());
00228     // number of lanes
00229     nolanes = NINavTeqHelper::getLaneNumber(id, st.next(), speed);
00230     std::vector<std::string> theRest = st.getVector();
00231     bool connection = (theRest.size() == 11) && (theRest[10] == "1");
00232     if (theRest.size() > 11) {
00233         // post 05/2009 network
00234         if (theRest[11] != "-1") {
00235             try {
00236                 nolanes = TplConvert<char>::_2int(theRest[11].c_str());
00237             } catch (NumberFormatException &) {
00238                 throw ProcessError("Non-numerical value for the extended number of lanes (edge '" + id + "'.");
00239             }
00240         }
00241         connection = (theRest.size() == 13) && (theRest[12] == "1");
00242     }
00243     // try to get the nodes
00244     NBNode *from = myNodeCont.retrieve(fromID);
00245     NBNode *to = myNodeCont.retrieve(toID);
00246     if (from==0) {
00247         throw ProcessError("The from-node '" + fromID + "' of edge '" + id + "' could not be found");
00248     }
00249     if (to==0) {
00250         throw ProcessError("The to-node '" + toID + "' of edge '" + id + "' could not be found");
00251     }
00252     // build the edge
00253     NBEdge *e = 0;
00254     if (interID=="-1") {
00255         e = new NBEdge(id, from, to, "DEFAULT", speed, nolanes, priority);
00256     } else {
00257         Position2DVector geoms = myGeoms[interID];
00258         if (connection) {
00259             geoms = geoms.reverse();
00260             geoms.push_front(from->getPosition());
00261             geoms.push_back(to->getPosition());
00262             e = new NBEdge(id, from, to, "DEFAULT", speed, nolanes, priority, geoms, NBEdge::LANESPREAD_CENTER);
00263         } else {
00264             geoms.push_front(from->getPosition());
00265             geoms.push_back(to->getPosition());
00266             e = new NBEdge(id, from, to, "DEFAULT", speed, nolanes, priority, geoms, NBEdge::LANESPREAD_CENTER);
00267         }
00268     }
00269     // add vehicle type information to the edge
00270     NINavTeqHelper::addVehicleClasses(*e, veh_type);
00271     // insert the edge to the network
00272     if (!myEdgeCont.insert(e)) {
00273         delete e;
00274         throw ProcessError("Could not add edge '" + id + "'.");
00275     }
00276     return true;
00277 }


Field Documentation

The edge container to store loaded edges into.

Definition at line 171 of file NIImporter_DlrNavteq.h.

Referenced by report().

Previously read edge geometries.

Definition at line 174 of file NIImporter_DlrNavteq.h.

Referenced by report().

The node container to get the referenced nodes from.

Definition at line 168 of file NIImporter_DlrNavteq.h.

Referenced by report().

Whether node positions shall not be added to the edge's geometry.

Definition at line 177 of file NIImporter_DlrNavteq.h.


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

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