|
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/geom/PositionVector.h> 00032 #include <utils/common/TplConvert.h> 00033 #include "../NIImporter_Vissim.h" 00034 #include "../tempstructs/NIVissimConnection.h" 00035 #include "NIVissimSingleTypeParser_Verbindungsdefinition.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_Verbindungsdefinition::NIVissimSingleTypeParser_Verbindungsdefinition(NIImporter_Vissim& parent) 00046 : NIImporter_Vissim::VissimSingleTypeParser(parent) {} 00047 00048 00049 NIVissimSingleTypeParser_Verbindungsdefinition::~NIVissimSingleTypeParser_Verbindungsdefinition() {} 00050 00051 00052 bool 00053 NIVissimSingleTypeParser_Verbindungsdefinition::parse(std::istream& from) { 00054 int id; 00055 from >> id; // type-checking is missing! 00056 std::string tag; 00057 // Read optional value "Name", skip optional value "Beschriftung" 00058 std::string name; 00059 while (tag!="von") { 00060 tag = overrideOptionalLabel(from); 00061 if (tag=="name") { 00062 name = readName(from); 00063 } 00064 } 00065 // Read the geometry information 00066 NIVissimExtendedEdgePoint from_def = readExtEdgePointDef(from); 00067 PositionVector geom; 00068 tag = myRead(from); // "ueber" 00069 while (tag!="nach") { 00070 std::string x = myRead(from); 00071 std::string y = myRead(from); 00072 if (y!="nach") { 00073 geom.push_back_noDoublePos( 00074 Position( 00075 TplConvert<char>::_2SUMOReal(x.c_str()), 00076 TplConvert<char>::_2SUMOReal(y.c_str()) 00077 )); 00078 tag = myRead(from); 00079 try { 00080 TplConvert<char>::_2SUMOReal(tag.c_str()); 00081 tag = myRead(from); 00082 } catch (NumberFormatException&) {} 00083 } else { 00084 tag = y; 00085 } 00086 } 00087 NIVissimExtendedEdgePoint to_def = readExtEdgePointDef(from); 00088 // read some optional values until mandatory "Fahrzeugklassen" occurs 00089 SUMOReal dxnothalt = 0; 00090 SUMOReal dxeinordnen = 0; 00091 SUMOReal zuschlag1, zuschlag2; 00092 zuschlag1 = zuschlag2 = 0; 00093 SUMOReal seglength = 0; 00094 tag = myRead(from); 00095 NIVissimConnection::Direction direction = NIVissimConnection::NIVC_DIR_ALL; 00096 while (tag!="fahrzeugklassen"&&tag!="sperrung"&&tag!="auswertung"&&tag!="DATAEND") { 00097 if (tag=="rechts") { 00098 direction = NIVissimConnection::NIVC_DIR_RIGHT; 00099 } else if (tag=="links") { 00100 direction = NIVissimConnection::NIVC_DIR_LEFT; 00101 } else if (tag=="alle") { 00102 direction = NIVissimConnection::NIVC_DIR_ALL; 00103 } else if (tag=="dxnothalt") { 00104 from >> dxnothalt; // type-checking is missing! 00105 } else if (tag=="dxeinordnen") { 00106 from >> dxeinordnen; // type-checking is missing! 00107 } else if (tag=="segment") { 00108 from >> tag; 00109 from >> seglength; 00110 } 00111 if (tag=="zuschlag") { 00112 from >> zuschlag1; // type-checking is missing! 00113 tag = readEndSecure(from); 00114 if (tag=="zuschlag") { 00115 from >> zuschlag2; // type-checking is missing! 00116 tag = readEndSecure(from, "auswertung"); 00117 } 00118 } else { 00119 tag = readEndSecure(from, "auswertung"); 00120 } 00121 } 00122 // read in allowed vehicle classes 00123 IntVector assignedVehicles; 00124 if (tag=="fahrzeugklassen") { 00125 tag = readEndSecure(from); 00126 while (tag!="DATAEND"&&tag!="sperrung"&&tag!="auswertung") { 00127 int classes = TplConvert<char>::_2int(tag.c_str()); 00128 assignedVehicles.push_back(classes); 00129 tag = readEndSecure(from, "auswertung"); 00130 } 00131 } 00132 // Read definitions of closed lanes 00133 NIVissimClosedLanesVector clv; 00134 if (tag!="DATAEND") { 00135 do { 00136 // check whether a next close lane definition can be found 00137 tag = readEndSecure(from); 00138 if (tag=="keinspurwechsel") { 00139 while (tag!="DATAEND") { 00140 tag = readEndSecure(from); 00141 } 00142 } else if (tag=="spur") { 00143 // get the lane number 00144 // from >> tag; 00145 int laneNo; 00146 from >> laneNo; // type-checking is missing! 00147 // get the list of assigned car classes 00148 IntVector assignedVehicles; 00149 tag = myRead(from); 00150 if (tag=="fahrzeugklassen") { 00151 tag = myRead(from); 00152 } 00153 while (tag!="DATAEND"&&tag!="spur"&&tag!="keinspurwechsel") { 00154 int classes = TplConvert<char>::_2int(tag.c_str()); 00155 assignedVehicles.push_back(classes); 00156 tag = readEndSecure(from); 00157 } 00158 // build and add the definition 00159 NIVissimClosedLaneDef* cld = new NIVissimClosedLaneDef(laneNo, assignedVehicles); 00160 clv.push_back(cld); 00161 } 00162 } while (tag!="DATAEND"); 00163 } 00164 NIVissimConnection* c = new NIVissimConnection(id, name, from_def, to_def, geom, 00165 direction, dxnothalt, dxeinordnen, zuschlag1, zuschlag2, seglength, 00166 assignedVehicles, clv); 00167 00168 if (!NIVissimConnection::dictionary(id, c)) { 00169 return false; 00170 } 00171 return true; 00172 //return NIVissimAbstractEdge::dictionary(id, c); 00173 } 00174 00175 00176 00177 /****************************************************************************/ 00178