SUMOVTypeParameter.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <algorithm>
00031 #include <utils/common/SUMOVTypeParameter.h>
00032 #include <utils/common/ToString.h>
00033 #include <utils/common/TplConvert.h>
00034 #include <utils/common/MsgHandler.h>
00035 #include <utils/iodevices/OutputDevice.h>
00036 #include <utils/options/OptionsCont.h>
00037 #include <utils/xml/SUMOXMLDefinitions.h>
00038
00039 #ifdef CHECK_MEMORY_LEAKS
00040 #include <foreign/nvwa/debug_new.h>
00041 #endif // CHECK_MEMORY_LEAKS
00042
00043
00044
00045
00046
00047 SUMOVTypeParameter::SUMOVTypeParameter() throw()
00048 : id(DEFAULT_VTYPE_ID), length(DEFAULT_VEH_LENGTH), maxSpeed(DEFAULT_VEH_MAXSPEED),
00049 defaultProbability(DEFAULT_VEH_PROB),
00050 speedFactor(DEFAULT_VEH_SPEEDFACTOR), speedDev(DEFAULT_VEH_SPEEDDEV),
00051 emissionClass(SVE_UNKNOWN), color(RGBColor::DEFAULT_COLOR),
00052 vehicleClass(SVC_UNKNOWN), width(DEFAULT_VEH_GUIWIDTH),
00053 offset(DEFAULT_VEH_GUIOFFSET), shape(DEFAULT_VEH_SHAPE),
00054 cfModel(-1),
00055
00056 setParameter(0), saved(false), onlyReferenced(false) {
00057 }
00058
00059
00060 void
00061 SUMOVTypeParameter::write(OutputDevice &dev) const throw(IOError) {
00062 if (onlyReferenced) {
00063 return;
00064 }
00065 dev << " <vtype id=\"" << id << '"';
00066 if (wasSet(VTYPEPARS_LENGTH_SET)) {
00067 dev << " length=\"" << length << '"';
00068 }
00069 if (wasSet(VTYPEPARS_MAXSPEED_SET)) {
00070 dev << " maxspeed=\"" << maxSpeed << '"';
00071 }
00072 if (wasSet(VTYPEPARS_PROBABILITY_SET)) {
00073 dev << " probability=\"" << defaultProbability << '"';
00074 }
00075 if (wasSet(VTYPEPARS_SPEEDFACTOR_SET)) {
00076 dev << " speedFactor=\"" << speedFactor << '"';
00077 }
00078 if (wasSet(VTYPEPARS_SPEEDDEVIATION_SET)) {
00079 dev << " speedDev=\"" << speedDev << '"';
00080 }
00081 if (wasSet(VTYPEPARS_VEHICLECLASS_SET)) {
00082 dev << " vclass=\"" << getVehicleClassName(vehicleClass) << '"';
00083 }
00084 if (wasSet(VTYPEPARS_EMISSIONCLASS_SET)) {
00085 dev << " emissionClass=\"" << getVehicleEmissionTypeName(emissionClass) << '"';
00086 }
00087 if (wasSet(VTYPEPARS_SHAPE_SET)) {
00088 dev << " guiShape=\"" << getVehicleShapeName(shape) << '"';
00089 }
00090 if (wasSet(VTYPEPARS_OFFSET_SET)) {
00091 dev << " guiOffset=\"" << offset << '"';
00092 }
00093 if (wasSet(VTYPEPARS_WIDTH_SET)) {
00094 dev << " guiWidth=\"" << width << '"';
00095 }
00096 if (wasSet(VTYPEPARS_COLOR_SET)) {
00097 dev << " color=\"" << color << '"';
00098 }
00099
00100 if (cfParameter.size()!=0) {
00101 dev << ">\n";
00102 dev << " <";
00103 switch (cfModel) {
00104 case SUMO_TAG_CF_IDM:
00105 dev << CF_MODEL_IDM;
00106 break;
00107 case SUMO_TAG_CF_KRAUSS_ORIG1:
00108 dev << CF_MODEL_KRAUSS_ORIG1;
00109 break;
00110 case SUMO_TAG_CF_PWAGNER2009:
00111 dev << CF_MODEL_PWAGNER2009;
00112 break;
00113 case SUMO_TAG_CF_BKERNER:
00114 dev << CF_MODEL_BKERNER;
00115 break;
00116 case SUMO_TAG_CF_KRAUSS:
00117 default:
00118 dev << CF_MODEL_KRAUSS;
00119 break;
00120 }
00121 std::vector<std::string> names;
00122 for (std::map<std::string, SUMOReal>::const_iterator i=cfParameter.begin(); i!=cfParameter.end(); ++i) {
00123 names.push_back((*i).first);
00124 }
00125 std::sort(names.begin(), names.end());
00126 for (std::vector<std::string>::const_iterator i=names.begin(); i!=names.end(); ++i) {
00127 dev << ' ' << (*i) << "=\"" << cfParameter.find(*i)->second << '"';
00128 }
00129 dev << "/>\n";
00130 dev << " </vtype>\n";
00131 } else {
00132 dev << "/>\n";
00133 }
00134 }
00135
00136
00137
00138