NIVissimSingleTypeParser_Fahrzeugtypdefinition.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 <iostream>
00031 #include <utils/common/TplConvert.h>
00032 #include <utils/common/ToString.h>
00033 #include "../NIImporter_Vissim.h"
00034 #include "../tempstructs/NIVissimVehicleType.h"
00035 #include "NIVissimSingleTypeParser_Fahrzeugtypdefinition.h"
00036
00037 #ifdef CHECK_MEMORY_LEAKS
00038 #include <foreign/nvwa/debug_new.h>
00039 #endif // CHECK_MEMORY_LEAKS
00040
00041
00042
00043
00044
00045 NIVissimSingleTypeParser_Fahrzeugtypdefinition::NIVissimSingleTypeParser_Fahrzeugtypdefinition(
00046 NIImporter_Vissim &parent, NIImporter_Vissim::ColorMap &colorMap)
00047 : NIImporter_Vissim::VissimSingleTypeParser(parent),
00048 myColorMap(colorMap) {}
00049
00050
00051 NIVissimSingleTypeParser_Fahrzeugtypdefinition::~NIVissimSingleTypeParser_Fahrzeugtypdefinition() {}
00052
00053
00054 bool
00055 NIVissimSingleTypeParser_Fahrzeugtypdefinition::parse(std::istream &from) {
00056
00057 int id;
00058 from >> id;
00059
00060 std::string tag;
00061 from >> tag;
00062 std::string name = readName(from);
00063
00064 std::string category;
00065 from >> tag;
00066 from >> category;
00067
00068 RGBColor color;
00069 tag = myRead(from);
00070 while (tag!="laenge") {
00071 if (tag=="farbe") {
00072 std::string colorName = myRead(from);
00073 NIImporter_Vissim::ColorMap::iterator i=myColorMap.find(colorName);
00074 if (i!=myColorMap.end()) {
00075 color = (*i).second;
00076 } else {
00077 int r, g, b;
00078 r = TplConvert<char>::_2int(colorName.c_str());
00079 from >> g;
00080 from >> b;
00081 color = RGBColor(
00082 (SUMOReal) r / (SUMOReal) 255.0,
00083 (SUMOReal) g / (SUMOReal) 255.0,
00084 (SUMOReal) b / (SUMOReal) 255.0);
00085 }
00086 }
00087 tag = myRead(from);
00088 }
00089 SUMOReal length;
00090 from >> length;
00091
00092 while (tag!="maxbeschleunigung") {
00093 tag = myRead(from);
00094 }
00095 SUMOReal amax;
00096 from >> amax;
00097
00098 while (tag!="maxverzoegerung") {
00099 tag = myRead(from);
00100 }
00101 SUMOReal dmax;
00102 from >> dmax;
00103 while (tag!="besetzungsgrad") {
00104 tag = myRead(from);
00105 }
00106 while (tag!="DATAEND") {
00107 tag = readEndSecure(from, "verlustzeit");
00108 }
00109 return NIVissimVehicleType::dictionary(id, name,
00110 category, length, color, amax, dmax);
00111 }
00112
00113
00114
00115
00116