NINavTeqHelper Class Reference

#include <NINavTeqHelper.h>


Detailed Description

Some parser methods shared around several formats containing NavTeq-Nets.

Networks from NavTeq ofte use categories for speed limits and the number of lanes. This class parses such categories and converts them into proper values.

Definition at line 54 of file NINavTeqHelper.h.


Static Public Member Functions

static void addVehicleClasses (NBEdge &e, const std::string &classS) throw ()
 Adds vehicle classes parsing the given list of allowed vehicles.
static unsigned int getLaneNumber (const std::string &id, const std::string &laneNoS, SUMOReal speed) throw (ProcessError)
 Returns the lane number evaluating the given Navteq-description.
static SUMOReal getSpeed (const std::string &id, const std::string &speedClassS) throw (ProcessError)
 Returns the speed evaluating the given Navteq-description.

Static Protected Member Functions

static void addVehicleClass (NBEdge &e, SUMOVehicleClass c) throw ()
 Adds a single vehicle class to all lanes of the given edge.

Member Function Documentation

void NINavTeqHelper::addVehicleClass ( NBEdge e,
SUMOVehicleClass  c 
) throw () [static, protected]

Adds a single vehicle class to all lanes of the given edge.

Parameters:
[in] e The edge to set the vehicle class into
[in] c The class to set (allow)

Definition at line 157 of file NINavTeqHelper.cpp.

00157                                                                      {
00158     for (unsigned int i=0; i<e.getNoLanes(); i++) {
00159         e.allowVehicleClass(i, c);
00160     }
00161 }

void NINavTeqHelper::addVehicleClasses ( NBEdge e,
const std::string &  classS 
) throw () [static]

Adds vehicle classes parsing the given list of allowed vehicles.

Parses the given class-string and sets all set (allowed) vehicle types into the given edge using "addVehicleClass".

Parameters:
[in] e The edge to set the parsed vehicle classes into
[in] classS The string that contains the information whether a vehicle class is allowed
See also:
addVehicleClass

Definition at line 107 of file NINavTeqHelper.cpp.

References SVC_BICYCLE, SVC_BUS, SVC_DELIVERY, SVC_HOV, SVC_PASSENGER, SVC_PEDESTRIAN, SVC_PUBLIC_EMERGENCY, SVC_PUBLIC_TRANSPORT, SVC_TAXI, and SVC_TRANSPORT.

Referenced by NIImporter_DlrNavteq::EdgesHandler::report().

00107                                                                              {
00108     std::string classS = "0000000000" + oclassS;
00109     classS = classS.substr(classS.length() - 10);
00110     // 0: allow all vehicle types
00111     if (classS[0]=='1') {
00112         return;
00113     }
00114     // Passenger cars -- becomes SVC_PASSENGER
00115     if (classS[1]=='1') {
00116         addVehicleClass(e, SVC_PASSENGER);
00117     }
00118     // High Occupancy Vehicle -- becomes SVC_PASSENGER|SVC_HOV
00119     if (classS[2]=='1') {
00120         addVehicleClass(e, SVC_HOV);
00121         addVehicleClass(e, SVC_PASSENGER);
00122     }
00123     // Emergency Vehicle -- becomes SVC_PUBLIC_EMERGENCY
00124     if (classS[3]=='1') {
00125         addVehicleClass(e, SVC_PUBLIC_EMERGENCY);
00126     }
00127     // Taxi -- becomes SVC_PASSENGER|SVC_TAXI
00128     if (classS[4]=='1') {
00129         addVehicleClass(e, SVC_TAXI);
00130         addVehicleClass(e, SVC_PASSENGER);
00131     }
00132     // Public Bus -- becomes SVC_BUS|SVC_PUBLIC_TRANSPORT
00133     if (classS[5]=='1') {
00134         addVehicleClass(e, SVC_PUBLIC_TRANSPORT);
00135         addVehicleClass(e, SVC_BUS);
00136     }
00137     // Delivery Truck -- becomes SVC_DELIVERY
00138     if (classS[6]=='1') {
00139         addVehicleClass(e, SVC_DELIVERY);
00140     }
00141     // Transport Truck -- becomes SVC_TRANSPORT
00142     if (classS[7]=='1') {
00143         addVehicleClass(e, SVC_TRANSPORT);
00144     }
00145     // Bicycle -- becomes SVC_BICYCLE
00146     if (classS[8]=='1') {
00147         addVehicleClass(e, SVC_BICYCLE);
00148     }
00149     // Pedestrian -- becomes SVC_PEDESTRIAN
00150     if (classS[9]=='1') {
00151         addVehicleClass(e, SVC_PEDESTRIAN);
00152     }
00153 }

unsigned int NINavTeqHelper::getLaneNumber ( const std::string &  id,
const std::string &  laneNoS,
SUMOReal  speed 
) throw (ProcessError) [static]

Returns the lane number evaluating the given Navteq-description.

Parameters:
[in] id The id of the edge (for debug-output)
[in] laneNoS The string that describes the number of lanes
[in] speed An additional hint for guessing the proper lane number
Returns:
The converted lane number
Exceptions:
ProcessError If the given lane number definition is not a number or if it is not known

Definition at line 77 of file NINavTeqHelper.cpp.

References TplConvert< E >::_2int().

Referenced by NIImporter_DlrNavteq::EdgesHandler::report().

00077                                                                                                                {
00078     try {
00079         int nolanes = TplConvert<char>::_2int(laneNoS.c_str());
00080         if (nolanes<0) {
00081             return 1;
00082         } else if (nolanes/10 > 0) {
00083             return nolanes / 10;
00084         } else {
00085             switch (nolanes%10) {
00086             case 1:
00087                 return 1;
00088             case 2:
00089                 nolanes = 2;
00090                 if (speed>78.0/3.6) {
00091                     nolanes = 3;
00092                 }
00093                 return nolanes;
00094             case 3:
00095                 return 4;
00096             default:
00097                 throw ProcessError("Invalid lane number (edge '" + id + "').");
00098             }
00099         }
00100     } catch (NumberFormatException &) {
00101         throw ProcessError("Non-numerical value for an edge's lane number occured (edge '" + id + "'.");
00102     }
00103 }

SUMOReal NINavTeqHelper::getSpeed ( const std::string &  id,
const std::string &  speedClassS 
) throw (ProcessError) [static]

Returns the speed evaluating the given Navteq-description.

This method tries to parse the speed category into its int-representation and to determine the speed that is assigned to the category. If either of both steps can not be perfored, a ProcessError is thrown.

Parameters:
[in] id The id of the edge (for debug-output)
[in] speedClassS The string that describes the speed class
Returns:
The converted speed (in m/s)
Exceptions:
ProcessError If the given speed class definition is not a number or if it is not known

Definition at line 45 of file NINavTeqHelper.cpp.

References TplConvert< E >::_2int(), and SUMOReal.

Referenced by NIImporter_DlrNavteq::EdgesHandler::report().

00045                                                                                               {
00046     try {
00047         int speedClass = TplConvert<char>::_2int(speedClassS.c_str());
00048         switch (speedClass) {
00049         case -1:
00050             return (SUMOReal) 1.0 / (SUMOReal) 3.6;
00051         case 1:
00052             return (SUMOReal) 200 / (SUMOReal) 3.6; //> 130 KPH / > 80 MPH
00053         case 2:
00054             return (SUMOReal) 120 / (SUMOReal) 3.6; //101-130 KPH / 65-80 MPH
00055         case 3:
00056             return (SUMOReal) 100 / (SUMOReal) 3.6; // 91-100 KPH / 55-64 MPH
00057         case 4:
00058             return (SUMOReal) 80 / (SUMOReal) 3.6; // 71-90 KPH / 41-54 MPH
00059         case 5:
00060             return (SUMOReal) 70 / (SUMOReal) 3.6; // 51-70 KPH / 31-40 MPH
00061         case 6:
00062             return (SUMOReal) 50 / (SUMOReal) 3.6; // 31-50 KPH / 21-30 MPH
00063         case 7:
00064             return (SUMOReal) 30 / (SUMOReal) 3.6; // 11-30 KPH / 6-20 MPH
00065         case 8:
00066             return (SUMOReal) 5 / (SUMOReal) 3.6; //< 11 KPH / < 6 MPH
00067         default:
00068             throw ProcessError("Invalid speed code (edge '" + id + "').");
00069         }
00070     } catch (NumberFormatException &) {
00071         throw ProcessError("Non-numerical value for an edge's speed type occured (edge '" + id + "').");
00072     }
00073 }


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

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