NIVissimSingleTypeParser_Streckendefinition.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/VectorHelper.h>
00033 #include <utils/geom/Position2DVector.h>
00034 #include "../NIImporter_Vissim.h"
00035 #include "../tempstructs/NIVissimEdge.h"
00036 #include "../tempstructs/NIVissimClosedLaneDef.h"
00037 #include "../tempstructs/NIVissimClosedLanesVector.h"
00038 #include "NIVissimSingleTypeParser_Streckendefinition.h"
00039
00040 #ifdef CHECK_MEMORY_LEAKS
00041 #include <foreign/nvwa/debug_new.h>
00042 #endif // CHECK_MEMORY_LEAKS
00043
00044
00045
00046
00047
00048 NIVissimSingleTypeParser_Streckendefinition::NIVissimSingleTypeParser_Streckendefinition(NIImporter_Vissim &parent)
00049 : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
00050
00051
00052 NIVissimSingleTypeParser_Streckendefinition::~NIVissimSingleTypeParser_Streckendefinition() {}
00053
00054
00055 bool
00056 NIVissimSingleTypeParser_Streckendefinition::parse(std::istream &from) {
00057
00058 int id;
00059 from >> id;
00060
00061 std::string tag;
00062
00063
00064 std::string name, label, type;
00065 SUMOReal length = -1;
00066 while (length<0) {
00067 tag = overrideOptionalLabel(from);
00068 if (tag=="name") {
00069 name = readName(from);
00070 } else if (tag=="typ") {
00071 type = myRead(from);
00072 } else if (tag=="laenge") {
00073 from >> length;
00074 }
00075 }
00076
00077 int noLanes;
00078 tag = myRead(from);
00079 from >> noLanes;
00080
00081
00082 SUMOReal zuschlag1, zuschlag2;
00083 zuschlag1 = zuschlag2 = 0;
00084 while (tag!="von") {
00085 tag = myRead(from);
00086 if (tag=="zuschlag") {
00087 from >> zuschlag1;
00088 tag = myRead(from);
00089 if (tag=="zuschlag") {
00090 from >> zuschlag2;
00091 }
00092 }
00093 }
00094
00095 Position2DVector geom;
00096 while (tag!="nach") {
00097 geom.push_back_noDoublePos(getPosition2D(from));
00098 tag = myRead(from);
00099 try {
00100 TplConvert<char>::_2SUMOReal(tag.c_str());
00101 tag = myRead(from);
00102 } catch (NumberFormatException &) {}
00103 }
00104 geom.push_back_noDoublePos(getPosition2D(from));
00105
00106 NIVissimClosedLanesVector clv;
00107
00108 tag = readEndSecure(from);
00109 while (tag!="DATAEND") {
00110 if (tag=="spur") {
00111
00112 int laneNo;
00113 from >> laneNo;
00114
00115 IntVector assignedVehicles;
00116 tag = myRead(from);
00117 tag = myRead(from);
00118 while (tag!="DATAEND"&&tag!="spur") {
00119 int classes = TplConvert<char>::_2int(tag.c_str());
00120 assignedVehicles.push_back(classes);
00121 tag = readEndSecure(from);
00122 }
00123
00124 NIVissimClosedLaneDef *cld = new NIVissimClosedLaneDef(laneNo, assignedVehicles);
00125 clv.push_back(cld);
00126 } else {
00127 tag = readEndSecure(from);
00128 }
00129 }
00130 NIVissimEdge *e = new NIVissimEdge(id, name, type, noLanes,
00131 zuschlag1, zuschlag2, length, geom, clv);
00132 if (!NIVissimEdge::dictionary(id, e)) {
00133 return false;
00134 }
00135 return true;
00136
00137 }
00138
00139
00140
00141
00142