|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 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 <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 // method definitions 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 // id 00057 int id; 00058 from >> id; // type-checking is missing! 00059 // name 00060 std::string tag; 00061 from >> tag; 00062 std::string name = readName(from); 00063 // category 00064 std::string category; 00065 from >> tag; 00066 from >> category; 00067 // color (optional) and length 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; // type-checking is missing! 00080 from >> b; // type-checking is missing! 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 // overread until "Maxbeschleunigung" 00092 while (tag!="maxbeschleunigung") { 00093 tag = myRead(from); 00094 } 00095 SUMOReal amax; 00096 from >> amax; // type-checking is missing! 00097 // overread until "Maxverzoegerung" 00098 while (tag!="maxverzoegerung") { 00099 tag = myRead(from); 00100 } 00101 SUMOReal dmax; 00102 from >> dmax; // type-checking is missing! 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