SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00008 // 00009 /****************************************************************************/ 00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00012 /****************************************************************************/ 00013 // 00014 // This file is part of SUMO. 00015 // SUMO is free software: you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation, either version 3 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <iostream> 00033 #include <utils/common/TplConvert.h> 00034 #include <utils/common/ToString.h> 00035 #include "../NIImporter_Vissim.h" 00036 #include "../tempstructs/NIVissimVehicleType.h" 00037 #include "NIVissimSingleTypeParser_Fahrzeugtypdefinition.h" 00038 00039 #ifdef CHECK_MEMORY_LEAKS 00040 #include <foreign/nvwa/debug_new.h> 00041 #endif // CHECK_MEMORY_LEAKS 00042 00043 00044 // =========================================================================== 00045 // method definitions 00046 // =========================================================================== 00047 NIVissimSingleTypeParser_Fahrzeugtypdefinition::NIVissimSingleTypeParser_Fahrzeugtypdefinition( 00048 NIImporter_Vissim& parent, NIImporter_Vissim::ColorMap& colorMap) 00049 : NIImporter_Vissim::VissimSingleTypeParser(parent), 00050 myColorMap(colorMap) {} 00051 00052 00053 NIVissimSingleTypeParser_Fahrzeugtypdefinition::~NIVissimSingleTypeParser_Fahrzeugtypdefinition() {} 00054 00055 00056 bool 00057 NIVissimSingleTypeParser_Fahrzeugtypdefinition::parse(std::istream& from) { 00058 // id 00059 int id; 00060 from >> id; // type-checking is missing! 00061 // name 00062 std::string tag; 00063 from >> tag; 00064 std::string name = readName(from); 00065 // category 00066 std::string category; 00067 from >> tag; 00068 from >> category; 00069 // color (optional) and length 00070 RGBColor color; 00071 tag = myRead(from); 00072 while (tag != "laenge") { 00073 if (tag == "farbe") { 00074 std::string colorName = myRead(from); 00075 NIImporter_Vissim::ColorMap::iterator i = myColorMap.find(colorName); 00076 if (i != myColorMap.end()) { 00077 color = (*i).second; 00078 } else { 00079 int r, g, b; 00080 r = TplConvert<char>::_2int(colorName.c_str()); 00081 from >> g; // type-checking is missing! 00082 from >> b; // type-checking is missing! 00083 color = RGBColor( 00084 (SUMOReal) r / (SUMOReal) 255.0, 00085 (SUMOReal) g / (SUMOReal) 255.0, 00086 (SUMOReal) b / (SUMOReal) 255.0); 00087 } 00088 } 00089 tag = myRead(from); 00090 } 00091 SUMOReal length; 00092 from >> length; 00093 // overread until "Maxbeschleunigung" 00094 while (tag != "maxbeschleunigung") { 00095 tag = myRead(from); 00096 } 00097 SUMOReal amax; 00098 from >> amax; // type-checking is missing! 00099 // overread until "Maxverzoegerung" 00100 while (tag != "maxverzoegerung") { 00101 tag = myRead(from); 00102 } 00103 SUMOReal dmax; 00104 from >> dmax; // type-checking is missing! 00105 while (tag != "besetzungsgrad") { 00106 tag = myRead(from); 00107 } 00108 while (tag != "DATAEND") { 00109 tag = readEndSecure(from, "verlustzeit"); 00110 } 00111 return NIVissimVehicleType::dictionary(id, name, 00112 category, length, color, amax, dmax); 00113 } 00114 00115 00116 00117 /****************************************************************************/ 00118