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/VectorHelper.h> 00035 #include <utils/geom/PositionVector.h> 00036 #include "../NIImporter_Vissim.h" 00037 #include "../tempstructs/NIVissimEdge.h" 00038 #include "../tempstructs/NIVissimClosedLaneDef.h" 00039 #include "../tempstructs/NIVissimClosedLanesVector.h" 00040 #include "NIVissimSingleTypeParser_Streckendefinition.h" 00041 00042 #ifdef CHECK_MEMORY_LEAKS 00043 #include <foreign/nvwa/debug_new.h> 00044 #endif // CHECK_MEMORY_LEAKS 00045 00046 00047 // =========================================================================== 00048 // method definitions 00049 // =========================================================================== 00050 NIVissimSingleTypeParser_Streckendefinition::NIVissimSingleTypeParser_Streckendefinition(NIImporter_Vissim& parent) 00051 : NIImporter_Vissim::VissimSingleTypeParser(parent) {} 00052 00053 00054 NIVissimSingleTypeParser_Streckendefinition::~NIVissimSingleTypeParser_Streckendefinition() {} 00055 00056 00057 bool 00058 NIVissimSingleTypeParser_Streckendefinition::parse(std::istream& from) { 00059 // read in the id 00060 int id; 00061 from >> id; 00062 // 00063 std::string tag; 00064 // the following elements may occure: "Name", "Beschriftung", "Typ", 00065 // followed by the mandatory "Laenge" 00066 std::string name, label, type; 00067 SUMOReal length = -1; 00068 while (length < 0) { 00069 tag = overrideOptionalLabel(from); 00070 if (tag == "name") { 00071 name = readName(from); 00072 } else if (tag == "typ") { 00073 type = myRead(from); 00074 } else if (tag == "laenge") { 00075 from >> length; // type-checking is missing! 00076 } 00077 } 00078 // read in the number of lanes 00079 int noLanes; 00080 tag = myRead(from); 00081 from >> noLanes; 00082 // skip some parameter, except optional "Zuschlag" until "Von" (mandatory) 00083 // occurs 00084 SUMOReal zuschlag1, zuschlag2; 00085 zuschlag1 = zuschlag2 = 0; 00086 while (tag != "von") { 00087 tag = myRead(from); 00088 if (tag == "zuschlag") { 00089 from >> zuschlag1; // type-checking is missing! 00090 tag = myRead(from); 00091 if (tag == "zuschlag") { 00092 from >> zuschlag2; // type-checking is missing! 00093 } 00094 } 00095 } 00096 // Read the geometry information 00097 PositionVector geom; 00098 while (tag != "nach") { 00099 geom.push_back_noDoublePos(getPosition(from)); 00100 tag = myRead(from); 00101 try { 00102 TplConvert<char>::_2SUMOReal(tag.c_str()); 00103 tag = myRead(from); 00104 } catch (NumberFormatException&) {} 00105 } 00106 geom.push_back_noDoublePos(getPosition(from)); 00107 // Read definitions of closed lanes 00108 NIVissimClosedLanesVector clv; 00109 // check whether a next close lane definition can be found 00110 tag = readEndSecure(from); 00111 while (tag != "DATAEND") { 00112 if (tag == "keinspurwechsel") { 00113 while (tag != "DATAEND") { 00114 tag = readEndSecure(from); 00115 } 00116 } else if (tag == "spur") { 00117 // get the lane number 00118 int laneNo; 00119 from >> laneNo; // type-checking is missing! 00120 // get the list of assigned car classes 00121 std::vector<int> assignedVehicles; 00122 tag = myRead(from); 00123 tag = myRead(from); 00124 while (tag != "DATAEND" && tag != "spur" && tag != "keinspurwechsel") { 00125 int classes = TplConvert<char>::_2int(tag.c_str()); 00126 assignedVehicles.push_back(classes); 00127 tag = readEndSecure(from); 00128 } 00129 // build and add the definition 00130 NIVissimClosedLaneDef* cld = new NIVissimClosedLaneDef(laneNo, assignedVehicles); 00131 clv.push_back(cld); 00132 } else { 00133 tag = readEndSecure(from); 00134 } 00135 } 00136 NIVissimEdge* e = new NIVissimEdge(id, name, type, noLanes, 00137 zuschlag1, zuschlag2, length, geom, clv); 00138 if (!NIVissimEdge::dictionary(id, e)) { 00139 return false; 00140 } 00141 return true; 00142 //return NIVissimAbstractEdge::dictionary(id, e); 00143 } 00144 00145 00146 00147 /****************************************************************************/ 00148