SUMOVehicleParserHelper.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Helper methods for parsing vehicle attributes
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #include <utils/common/UtilExceptions.h>
00031 #include <utils/common/MsgHandler.h>
00032 #include <utils/common/TplConvert.h>
00033 #include <utils/options/OptionsCont.h>
00034 #include "SUMOVehicleParserHelper.h"
00035 
00036 #ifdef CHECK_MEMORY_LEAKS
00037 #include <foreign/nvwa/debug_new.h>
00038 #endif // CHECK_MEMORY_LEAKS
00039 
00040 
00041 // ===========================================================================
00042 // method definitions
00043 // ===========================================================================
00044 SUMOVehicleParameter *
00045 SUMOVehicleParserHelper::parseFlowAttributes(const SUMOSAXAttributes &attrs) throw(ProcessError) {
00046     std::string id;
00047     if (!attrs.setIDFromAttributes("flow", id)) {
00048         throw ProcessError();
00049     }
00050     if (attrs.hasAttribute(SUMO_ATTR_PERIOD) && attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR)) {
00051         throw ProcessError("At most one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
00052                            "' and '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
00053                            "' has to be given in the definition of flow '" + id + "'.");
00054     }
00055     if (attrs.hasAttribute(SUMO_ATTR_PERIOD) || attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR)) {
00056         if (attrs.hasAttribute(SUMO_ATTR_END) && attrs.hasAttribute(SUMO_ATTR_NO)) {
00057             throw ProcessError("If '" + attrs.getName(SUMO_ATTR_PERIOD) +
00058                                "' or '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
00059                                "' are given at most one of '" + attrs.getName(SUMO_ATTR_END) +
00060                                "' and '" + attrs.getName(SUMO_ATTR_NO) +
00061                                "' are allowed in flow '" + id + "'.");
00062         }
00063     } else {
00064         if (!attrs.hasAttribute(SUMO_ATTR_NO)) {
00065             throw ProcessError("At least one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
00066                                "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
00067                                "', and '" + attrs.getName(SUMO_ATTR_NO) +
00068                                "' is needed in flow '" + id + "'.");
00069         }
00070     }
00071     bool ok = true;
00072     SUMOVehicleParameter *ret = new SUMOVehicleParameter();
00073     ret->id = id;
00074     parseCommonAttributes(attrs, ret, "flow");
00075 
00076     // parse repetition information
00077     if (attrs.hasAttribute(SUMO_ATTR_PERIOD)) {
00078         ret->setParameter |= VEHPARS_PERIODFREQ_SET;
00079         ret->repetitionOffset = attrs.getSUMOTimeReporting(SUMO_ATTR_PERIOD, "flow", id.c_str(), ok);
00080     }
00081     if (attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR)) {
00082         ret->setParameter |= VEHPARS_PERIODFREQ_SET;
00083         const SUMOReal vph = attrs.getSUMORealReporting(SUMO_ATTR_VEHSPERHOUR, "flow", id.c_str(), ok);
00084         if (ok && vph <= 0) {
00085             delete ret;
00086             throw ProcessError("Invalid repetition rate in the definition of flow '" + id + "'.");
00087         }
00088         if (ok && vph != 0) {
00089             ret->repetitionOffset = 3600./vph*1000.;
00090         }
00091     }
00092 
00093     ret->depart = string2time(OptionsCont::getOptions().getString("begin"));
00094     if (attrs.hasAttribute(SUMO_ATTR_BEGIN)) {
00095         ret->depart = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, "flow", id.c_str(), ok);
00096     }
00097     if (ok && ret->depart < 0) {
00098         delete ret;
00099         throw ProcessError("Negative begin time in the definition of flow '" + id + "'.");
00100     }
00101     SUMOTime end = string2time(OptionsCont::getOptions().getString("end"));
00102     if (end<0) {
00103         end=SUMOTime_MAX;
00104     }
00105     if (attrs.hasAttribute(SUMO_ATTR_END)) {
00106         end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, "flow", id.c_str(), ok);
00107     }
00108     if (ok && end <= ret->depart) {
00109         delete ret;
00110         throw ProcessError("Flow '" + id + "' ends before or at its begin time.");
00111     }
00112     if (attrs.hasAttribute(SUMO_ATTR_NO)) {
00113         ret->repetitionNumber = attrs.getIntReporting(SUMO_ATTR_NO, "flow", id.c_str(), ok);
00114         ret->setParameter |= VEHPARS_PERIODFREQ_SET;
00115         if (ok && ret->repetitionNumber < 0) {
00116             delete ret;
00117             throw ProcessError("Negative repetition number in the definition of flow '" + id + "'.");
00118         }
00119         if (ok && ret->repetitionOffset < 0) {
00120             ret->repetitionOffset = (end - ret->depart) / (SUMOReal)ret->repetitionNumber;
00121         }
00122     } else {
00123         if (ok && ret->repetitionOffset <= 0) {
00124             delete ret;
00125             throw ProcessError("Invalid repetition rate in the definition of flow '" + id + "'.");
00126         }
00127         if (end == SUMOTime_MAX) {
00128             ret->repetitionNumber = INT_MAX;
00129         } else {
00130             ret->repetitionNumber = (int)((end - ret->depart) / ret->repetitionOffset + 0.5);
00131         }
00132     }
00133     if (!ok) {
00134         delete ret;
00135         throw ProcessError();
00136     }
00137     return ret;
00138 }
00139 
00140 
00141 SUMOVehicleParameter *
00142 SUMOVehicleParserHelper::parseVehicleAttributes(const SUMOSAXAttributes &attrs,
00143         bool skipID, bool skipDepart) throw(ProcessError) {
00144     std::string id;
00145     if (!skipID && !attrs.setIDFromAttributes("vehicle", id)) {
00146         throw ProcessError();
00147     }
00148     if (attrs.hasAttribute(SUMO_ATTR_PERIOD) ^ attrs.hasAttribute(SUMO_ATTR_REPNUMBER)) {
00149         throw ProcessError("The attributes '" + attrs.getName(SUMO_ATTR_PERIOD) + "' and '" + attrs.getName(SUMO_ATTR_REPNUMBER) + "' have to be given both in the definition of '" + id + "'.");
00150     }
00151     bool ok = true;
00152     SUMOVehicleParameter *ret = new SUMOVehicleParameter();
00153     ret->id = id;
00154     parseCommonAttributes(attrs, ret, "vehicle");
00155     if (!skipDepart) {
00156         const std::string helper = attrs.getStringReporting(SUMO_ATTR_DEPART, "vehicle", 0, ok);
00157         if (helper=="triggered") {
00158             ret->departProcedure = DEPART_TRIGGERED;
00159         } else {
00160             ret->departProcedure = DEPART_GIVEN;
00161             ret->depart = attrs.getSUMOTimeReporting(SUMO_ATTR_DEPART, "vehicle", id.c_str(), ok);
00162             if (ok && ret->depart < 0) {
00163                 throw ProcessError("Negative departure time in the definition of '" + id + "'.");
00164             }
00165         }
00166     }
00167     // parse repetition information
00168     if (attrs.hasAttribute(SUMO_ATTR_PERIOD)) {
00169         WRITE_WARNING("period and repno are deprecated in vehicle '" + id + "', use flows instead.");
00170         ret->setParameter |= VEHPARS_PERIODFREQ_SET;
00171         ret->repetitionOffset = attrs.getSUMORealReporting(SUMO_ATTR_PERIOD, "vehicle", id.c_str(), ok);
00172     }
00173     if (attrs.hasAttribute(SUMO_ATTR_REPNUMBER)) {
00174         ret->setParameter |= VEHPARS_PERIODNUM_SET;
00175         ret->repetitionNumber = attrs.getIntReporting(SUMO_ATTR_REPNUMBER, "vehicle", id.c_str(), ok);
00176     }
00177 
00178     if (!ok) {
00179         delete ret;
00180         throw ProcessError();
00181     }
00182     return ret;
00183 }
00184 
00185 
00186 void
00187 SUMOVehicleParserHelper::parseCommonAttributes(const SUMOSAXAttributes &attrs,
00188         SUMOVehicleParameter *ret, std::string element) throw(ProcessError) {
00189     //ret->refid = attrs.getStringSecure(SUMO_ATTR_REFID, "");
00190     bool ok = true;
00191     // parse route information
00192     if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
00193         ret->setParameter |= VEHPARS_ROUTE_SET; // !!! needed?
00194         ret->routeid = attrs.getStringReporting(SUMO_ATTR_ROUTE, "vehicle", 0, ok);
00195     }
00196     // parse type information
00197     if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
00198         ret->setParameter |= VEHPARS_VTYPE_SET; // !!! needed?
00199         ret->vtypeid = attrs.getStringReporting(SUMO_ATTR_TYPE, "vehicle", 0, ok);
00200     }
00201     // parse line information
00202     if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
00203         ret->setParameter |= VEHPARS_LINE_SET; // !!! needed?
00204         ret->line = attrs.getStringReporting(SUMO_ATTR_LINE, "vehicle", 0, ok);
00205     }
00206     // parse zone information
00207     if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
00208         ret->setParameter |= VEHPARS_TAZ_SET;
00209         ret->fromTaz = attrs.getStringReporting(SUMO_ATTR_FROM_TAZ, "vehicle", 0, ok);
00210         ret->toTaz = attrs.getStringReporting(SUMO_ATTR_TO_TAZ, "vehicle", 0, ok);
00211     }
00212 
00213     // parse depart lane information
00214     if (attrs.hasAttribute(SUMO_ATTR_DEPARTLANE)) {
00215         ret->setParameter |= VEHPARS_DEPARTLANE_SET;
00216         const std::string helper = attrs.getStringReporting(SUMO_ATTR_DEPARTLANE, "vehicle", 0, ok);
00217         if (helper=="departlane") {
00218             ret->departLaneProcedure = DEPART_LANE_DEPARTLANE;
00219         } else if (helper=="random") {
00220             ret->departLaneProcedure = DEPART_LANE_RANDOM;
00221         } else if (helper=="free") {
00222             ret->departLaneProcedure = DEPART_LANE_FREE;
00223         } else {
00224             try {
00225                 ret->departLane = TplConvert<char>::_2int(helper.c_str());;
00226                 ret->departLaneProcedure = DEPART_LANE_GIVEN;
00227                 if (ret->departLane < 0) {
00228                     throw ProcessError("Invalid departlane definition for " + element + " '" + ret->id + "'");
00229                 }
00230             } catch (NumberFormatException &) {
00231                 throw ProcessError("Invalid departlane definition for " + element + " '" + ret->id + "'");
00232             } catch (EmptyData &) {
00233                 throw ProcessError("Invalid departlane definition for " + element + " '" + ret->id + "'");
00234             }
00235         }
00236     }
00237     // parse depart position information
00238     if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
00239         ret->setParameter |= VEHPARS_DEPARTPOS_SET;
00240         const std::string helper = attrs.getStringReporting(SUMO_ATTR_DEPARTPOS, "vehicle", 0, ok);
00241         if (helper=="random") {
00242             ret->departPosProcedure = DEPART_POS_RANDOM;
00243         } else if (helper=="random_free") {
00244             ret->departPosProcedure = DEPART_POS_RANDOM_FREE;
00245         } else if (helper=="free") {
00246             ret->departPosProcedure = DEPART_POS_FREE;
00247         } else {
00248             try {
00249                 ret->departPos = TplConvert<char>::_2SUMOReal(helper.c_str());
00250                 ret->departPosProcedure = DEPART_POS_GIVEN;
00251             } catch (NumberFormatException &) {
00252                 throw ProcessError("Invalid departpos definition for " + element + " '" + ret->id + "'");
00253             } catch (EmptyData &) {
00254                 throw ProcessError("Invalid departpos definition for " + element + " '" + ret->id + "'");
00255             }
00256         }
00257     }
00258     // parse depart position information
00259     if (attrs.hasAttribute(SUMO_ATTR_DEPARTSPEED)) {
00260         ret->setParameter |= VEHPARS_DEPARTSPEED_SET;
00261         std::string helper = attrs.getStringReporting(SUMO_ATTR_DEPARTSPEED, "vehicle", 0, ok);
00262         if (helper=="random") {
00263             ret->departSpeedProcedure = DEPART_SPEED_RANDOM;
00264         } else if (helper=="max") {
00265             ret->departSpeedProcedure = DEPART_SPEED_MAX;
00266         } else {
00267             try {
00268                 ret->departSpeed = TplConvert<char>::_2SUMOReal(helper.c_str());
00269                 ret->departSpeedProcedure = DEPART_SPEED_GIVEN;
00270             } catch (NumberFormatException &) {
00271                 throw ProcessError("Invalid departspeed definition for " + element + " '" + ret->id + "'");
00272             } catch (EmptyData &) {
00273                 throw ProcessError("Invalid departspeed definition for " + element + " '" + ret->id + "'");
00274             }
00275         }
00276     }
00277 
00278     // parse arrival lane information
00279     if (attrs.hasAttribute(SUMO_ATTR_ARRIVALLANE)) {
00280         ret->setParameter |= VEHPARS_ARRIVALLANE_SET;
00281         std::string helper = attrs.getStringReporting(SUMO_ATTR_ARRIVALLANE, "vehicle", 0, ok);
00282         if (helper=="current") {
00283             ret->arrivalLaneProcedure = ARRIVAL_LANE_CURRENT;
00284         } else {
00285             try {
00286                 ret->arrivalLane = TplConvert<char>::_2int(helper.c_str());;
00287                 ret->arrivalLaneProcedure = ARRIVAL_LANE_GIVEN;
00288             } catch (NumberFormatException &) {
00289                 throw ProcessError("Invalid arrivallane definition for " + element + " '" + ret->id + "'");
00290             } catch (EmptyData &) {
00291                 throw ProcessError("Invalid arrivallane definition for " + element + " '" + ret->id + "'");
00292             }
00293         }
00294     }
00295     // parse arrival position information
00296     if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
00297         ret->setParameter |= VEHPARS_ARRIVALPOS_SET;
00298         std::string helper = attrs.getStringReporting(SUMO_ATTR_ARRIVALPOS, "vehicle", 0, ok);
00299         if (helper=="random") {
00300             ret->arrivalPosProcedure = ARRIVAL_POS_RANDOM;
00301         } else if (helper=="max") {
00302             ret->arrivalPosProcedure = ARRIVAL_POS_MAX;
00303         } else {
00304             try {
00305                 ret->arrivalPos = TplConvert<char>::_2SUMOReal(helper.c_str());
00306                 ret->arrivalPosProcedure = ARRIVAL_POS_GIVEN;
00307             } catch (NumberFormatException &) {
00308                 throw ProcessError("Invalid arrivalpos definition for " + element + " '" + ret->id + "'");
00309             } catch (EmptyData &) {
00310                 throw ProcessError("Invalid arrivalpos definition for " + element + " '" + ret->id + "'");
00311             }
00312         }
00313     }
00314     // parse arrival position information
00315     if (attrs.hasAttribute(SUMO_ATTR_ARRIVALSPEED)) {
00316         ret->setParameter |= VEHPARS_ARRIVALSPEED_SET;
00317         std::string helper = attrs.getStringReporting(SUMO_ATTR_ARRIVALSPEED, "vehicle", 0, ok);
00318         if (helper=="current") {
00319             ret->arrivalSpeedProcedure = ARRIVAL_SPEED_CURRENT;
00320         } else {
00321             try {
00322                 ret->arrivalSpeed = TplConvert<char>::_2SUMOReal(helper.c_str());
00323                 ret->arrivalSpeedProcedure = ARRIVAL_SPEED_GIVEN;
00324             } catch (NumberFormatException &) {
00325                 throw ProcessError("Invalid arrivalspeed definition for " + element + " '" + ret->id + "'");
00326             } catch (EmptyData &) {
00327                 throw ProcessError("Invalid arrivalspeed definition for " + element + " '" + ret->id + "'");
00328             }
00329         }
00330     }
00331 
00332     // parse color
00333     if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
00334         ret->setParameter |= VEHPARS_COLOR_SET;
00335         try {
00336             ret->color = RGBColor::parseColor(attrs.getStringReporting(SUMO_ATTR_COLOR, "vehicle", 0, ok));
00337         } catch (NumberFormatException &) {
00338             throw ProcessError("Invalid color definition for " + element + " '" + ret->id + "'");
00339         } catch (EmptyData &) {
00340             throw ProcessError("Invalid color definition for " + element + " '" + ret->id + "'");
00341         }
00342     } else {
00343         ret->color = RGBColor::DEFAULT_COLOR;
00344     }
00345 }
00346 
00347 
00348 SUMOVTypeParameter *
00349 SUMOVehicleParserHelper::beginVTypeParsing(const SUMOSAXAttributes &attrs) throw(ProcessError) {
00350     SUMOVTypeParameter *vtype = new SUMOVTypeParameter();
00351     if (!attrs.setIDFromAttributes("vtype", vtype->id)) {
00352         throw ProcessError();
00353     }
00354     bool ok = true;
00355     if (attrs.hasAttribute(SUMO_ATTR_LENGTH)) {
00356         vtype->length = attrs.getSUMORealReporting(SUMO_ATTR_LENGTH, "vtype", vtype->id.c_str(), ok);
00357         vtype->setParameter |= VTYPEPARS_LENGTH_SET;
00358     }
00359     if (attrs.hasAttribute(SUMO_ATTR_MAXSPEED)) {
00360         vtype->maxSpeed = attrs.getSUMORealReporting(SUMO_ATTR_MAXSPEED, "vtype", vtype->id.c_str(), ok);
00361         vtype->setParameter |= VTYPEPARS_MAXSPEED_SET;
00362     }
00363     if (attrs.hasAttribute(SUMO_ATTR_SPEEDFACTOR)) {
00364         vtype->speedFactor = attrs.getSUMORealReporting(SUMO_ATTR_SPEEDFACTOR, "vtype", vtype->id.c_str(), ok);
00365         vtype->setParameter |= VTYPEPARS_SPEEDFACTOR_SET;
00366     }
00367     if (attrs.hasAttribute(SUMO_ATTR_SPEEDDEV)) {
00368         vtype->speedDev = attrs.getSUMORealReporting(SUMO_ATTR_SPEEDDEV, "vtype", vtype->id.c_str(), ok);
00369         vtype->setParameter |= VTYPEPARS_SPEEDDEVIATION_SET;
00370     }
00371     if (attrs.hasAttribute(SUMO_ATTR_EMISSIONCLASS)) {
00372         vtype->emissionClass = parseEmissionClass(attrs, "vtype", vtype->id);
00373         vtype->setParameter |= VTYPEPARS_EMISSIONCLASS_SET;
00374     }
00375     if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
00376         vtype->vehicleClass = parseVehicleClass(attrs, "vtype", vtype->id);
00377         vtype->setParameter |= VTYPEPARS_VEHICLECLASS_SET;
00378     }
00379     if (attrs.hasAttribute(SUMO_ATTR_GUIWIDTH)) {
00380         vtype->width = attrs.getSUMORealReporting(SUMO_ATTR_GUIWIDTH, "vtype", vtype->id.c_str(), ok);
00381         vtype->setParameter |= VTYPEPARS_WIDTH_SET;
00382     }
00383     if (attrs.hasAttribute(SUMO_ATTR_GUIOFFSET)) {
00384         vtype->offset = attrs.getSUMORealReporting(SUMO_ATTR_GUIOFFSET, "vtype", vtype->id.c_str(), ok);
00385         vtype->setParameter |= VTYPEPARS_OFFSET_SET;
00386     }
00387     if (attrs.hasAttribute(SUMO_ATTR_GUISHAPE)) {
00388         vtype->shape = parseGuiShape(attrs, "vtype", vtype->id);
00389         vtype->setParameter |= VTYPEPARS_SHAPE_SET;
00390     }
00391     if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
00392         vtype->color = RGBColor::parseColorReporting(attrs.getString(SUMO_ATTR_COLOR), "vtype", vtype->id.c_str(), true, ok);
00393         vtype->setParameter |= VTYPEPARS_COLOR_SET;
00394     } else {
00395         vtype->color = RGBColor(1,1,0);
00396     }
00397     if (attrs.hasAttribute(SUMO_ATTR_PROB)) {
00398         vtype->defaultProbability = attrs.getSUMORealReporting(SUMO_ATTR_PROB, "vtype", vtype->id.c_str(), ok);
00399         vtype->setParameter |= VTYPEPARS_PROBABILITY_SET;
00400     }
00401     try {
00402         parseVTypeEmbedded(*vtype, SUMO_TAG_CF_KRAUSS, attrs, true);
00403     } catch (ProcessError &) {
00404         throw;
00405     }
00406     if (!ok) {
00407         throw ProcessError();
00408     }
00409     return vtype;
00410 }
00411 
00412 
00413 void
00414 SUMOVehicleParserHelper::parseVTypeEmbedded(SUMOVTypeParameter &into,
00415         int element, const SUMOSAXAttributes &attrs,
00416         bool fromVType) throw(ProcessError) {
00417     switch (element) {
00418     case SUMO_TAG_CF_KRAUSS:
00419         parseVTypeEmbedded_Krauss(into, attrs, fromVType);
00420         break;
00421     case SUMO_TAG_CF_IDM:
00422         parseVTypeEmbedded_IDM(into, attrs);
00423         break;
00424     case SUMO_TAG_CF_KRAUSS_ORIG1:
00425         parseVTypeEmbedded_Krauss(into, attrs);
00426         break;
00427     case SUMO_TAG_CF_PWAGNER2009:
00428         parseVTypeEmbedded_Krauss(into, attrs);
00429         break;
00430     case SUMO_TAG_CF_BKERNER:
00431         parseVTypeEmbedded_BKerner(into, attrs);
00432         break;
00433     }
00434     if (!fromVType) {
00435         into.cfModel = element;
00436     }
00437 }
00438 
00439 
00440 void
00441 SUMOVehicleParserHelper::parseVTypeEmbedded_Krauss(SUMOVTypeParameter &into,
00442         const SUMOSAXAttributes &attrs,
00443         bool fromVType) throw(ProcessError) {
00444     bool ok = true;
00445     if (attrs.hasAttribute(SUMO_ATTR_ACCEL)) {
00446         into.cfParameter["accel"] = attrs.getSUMORealReporting(SUMO_ATTR_ACCEL, "krauss", into.id.c_str(), ok);
00447     }
00448     if (attrs.hasAttribute(SUMO_ATTR_DECEL)) {
00449         into.cfParameter["decel"] = attrs.getSUMORealReporting(SUMO_ATTR_DECEL, "krauss", into.id.c_str(), ok);
00450     }
00451     if (attrs.hasAttribute(SUMO_ATTR_SIGMA)) {
00452         into.cfParameter["sigma"] = attrs.getSUMORealReporting(SUMO_ATTR_SIGMA, "krauss", into.id.c_str(), ok);
00453     }
00454     if (attrs.hasAttribute(SUMO_ATTR_TAU)) {
00455         into.cfParameter["tau"] = attrs.getSUMORealReporting(SUMO_ATTR_TAU, "krauss", into.id.c_str(), ok);
00456     }
00457     if (!ok) {
00458         throw ProcessError();
00459     }
00460 }
00461 
00462 
00463 void
00464 SUMOVehicleParserHelper::parseVTypeEmbedded_IDM(SUMOVTypeParameter &into,
00465         const SUMOSAXAttributes &attrs) throw(ProcessError) {
00466     bool ok = true;
00467     if (attrs.hasAttribute(SUMO_ATTR_ACCEL)) {
00468         into.cfParameter["accel"] = attrs.getSUMORealReporting(SUMO_ATTR_ACCEL, "IDM", into.id.c_str(), ok);
00469     }
00470     if (attrs.hasAttribute(SUMO_ATTR_DECEL)) {
00471         into.cfParameter["decel"] = attrs.getSUMORealReporting(SUMO_ATTR_DECEL, "IDM", into.id.c_str(), ok);
00472     }
00473     if (attrs.hasAttribute(SUMO_ATTR_TAU)) {
00474         into.cfParameter["tau"] = attrs.getSUMORealReporting(SUMO_ATTR_TAU, "IDM", into.id.c_str(), ok);
00475     }
00476     if (attrs.hasAttribute(SUMO_ATTR_CF_IDM_TIMEHEADWAY)) {
00477         into.cfParameter["timeHeadWay"] = attrs.getSUMORealReporting(SUMO_ATTR_CF_IDM_TIMEHEADWAY, "IDM", into.id.c_str(), ok);
00478     }
00479     if (attrs.hasAttribute(SUMO_ATTR_CF_IDM_MINGAP)) {
00480         into.cfParameter["minGap"] = attrs.getSUMORealReporting(SUMO_ATTR_CF_IDM_MINGAP, "IDM", into.id.c_str(), ok);
00481     }
00482     if (!ok) {
00483         throw ProcessError();
00484     }
00485 }
00486 
00487 
00488 void
00489 SUMOVehicleParserHelper::parseVTypeEmbedded_BKerner(SUMOVTypeParameter &into,
00490         const SUMOSAXAttributes &attrs) throw(ProcessError) {
00491     bool ok = true;
00492     if (attrs.hasAttribute(SUMO_ATTR_ACCEL)) {
00493         into.cfParameter["accel"] = attrs.getSUMORealReporting(SUMO_ATTR_ACCEL, "BKerner", into.id.c_str(), ok);
00494     }
00495     if (attrs.hasAttribute(SUMO_ATTR_DECEL)) {
00496         into.cfParameter["decel"] = attrs.getSUMORealReporting(SUMO_ATTR_DECEL, "BKerner", into.id.c_str(), ok);
00497     }
00498     if (attrs.hasAttribute(SUMO_ATTR_TAU)) {
00499         into.cfParameter["tau"] = attrs.getSUMORealReporting(SUMO_ATTR_TAU, "BKerner", into.id.c_str(), ok);
00500     }
00501     if (attrs.hasAttribute(SUMO_ATTR_K)) {
00502         into.cfParameter["k"] = attrs.getSUMORealReporting(SUMO_ATTR_K, "BKerner", into.id.c_str(), ok);
00503     }
00504     if (attrs.hasAttribute(SUMO_ATTR_CF_KERNER_PHI)) {
00505         into.cfParameter["phi"] = attrs.getSUMORealReporting(SUMO_ATTR_CF_KERNER_PHI, "BKerner", into.id.c_str(), ok);
00506     }
00507     if (!ok) {
00508         throw ProcessError();
00509     }
00510 }
00511 
00512 
00513 SUMOVehicleClass
00514 SUMOVehicleParserHelper::parseVehicleClass(const SUMOSAXAttributes &attrs,
00515         const std::string &type,
00516         const std::string &id) throw() {
00517     SUMOVehicleClass vclass = SVC_UNKNOWN;
00518     try {
00519         bool ok = true;
00520         std::string vclassS = attrs.getOptStringReporting(SUMO_ATTR_VCLASS, type.c_str(), id.c_str(), ok, "");
00521         if (vclassS=="") {
00522             return vclass;
00523         }
00524         return getVehicleClassID(vclassS);
00525     } catch (...) {
00526         MsgHandler::getErrorInstance()->inform("The class for " + type + " '" + id + "' is not known.");
00527     }
00528     return vclass;
00529 }
00530 
00531 
00532 SUMOEmissionClass
00533 SUMOVehicleParserHelper::parseEmissionClass(const SUMOSAXAttributes &attrs,
00534         const std::string &type,
00535         const std::string &id) throw() {
00536     SUMOEmissionClass vclass = SVE_UNKNOWN;
00537     try {
00538         bool ok = true;
00539         std::string vclassS = attrs.getOptStringReporting(SUMO_ATTR_EMISSIONCLASS, type.c_str(), id.c_str(), ok, "");
00540         if (vclassS=="") {
00541             return vclass;
00542         }
00543         return getVehicleEmissionTypeID(vclassS);
00544     } catch (...) {
00545         MsgHandler::getErrorInstance()->inform("The emission class for " + type + " '" + id + "' is not known.");
00546     }
00547     return vclass;
00548 }
00549 
00550 
00551 SUMOVehicleShape
00552 SUMOVehicleParserHelper::parseGuiShape(const SUMOSAXAttributes &attrs,
00553                                        const std::string &type,
00554                                        const std::string &id) throw() {
00555     SUMOVehicleShape vclass = SVS_UNKNOWN;
00556     try {
00557         bool ok = true;
00558         std::string vclassS = attrs.getOptStringReporting(SUMO_ATTR_GUISHAPE, type.c_str(), id.c_str(), ok, "");
00559         if (vclassS=="") {
00560             return vclass;
00561         }
00562         return getVehicleShapeID(vclassS);
00563     } catch (...) {
00564         MsgHandler::getErrorInstance()->inform("The shape for " + type + " '" + id + "' is not known.");
00565     }
00566     return vclass;
00567 }
00568 
00569 
00570 /****************************************************************************/
00571 

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