NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 //
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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/MsgHandler.h>
00033 #include "../NIImporter_Vissim.h"
00034 #include "../tempstructs/NIVissimExtendedEdgePoint.h"
00035 #include "../tempstructs/NIVissimDisturbance.h"
00036 #include "NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.h"
00037 
00038 #ifdef CHECK_MEMORY_LEAKS
00039 #include <foreign/nvwa/debug_new.h>
00040 #endif // CHECK_MEMORY_LEAKS
00041 
00042 
00043 // ===========================================================================
00044 // method definitions
00045 // ===========================================================================
00046 NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition(NIImporter_Vissim &parent)
00047         : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
00048 
00049 
00050 NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::~NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition() {}
00051 
00052 
00053 bool
00054 NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parse(std::istream &from) {
00055     std::string tag;
00056     tag = myRead(from);
00057     if (tag=="nureigenestrecke") {
00058         return parseOnlyMe(from);
00059     } else if (tag=="ort") {
00060         return parsePositionDescribed(from);
00061     } else if (tag=="nummer") {
00062         return parseNumbered(from);
00063     }
00064     MsgHandler::getErrorInstance()->inform(
00065         "NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition: format problem");
00066     throw 1;
00067 }
00068 
00069 bool
00070 NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseOnlyMe(std::istream &from) {
00071     std::string tag;
00072     from >> tag;
00073     return true;
00074 }
00075 
00076 
00077 bool
00078 NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePositionDescribed(std::istream &from) {
00079     std::string tag = myRead(from);
00080     NIVissimExtendedEdgePoint edge = parsePos(from);
00081 //    from >> tag; // "Durch"
00082     bool ok = true;
00083     do {
00084         from >> tag; // "Strecke"
00085         NIVissimExtendedEdgePoint by = parsePos(from);
00086         //
00087         SUMOReal timegap;
00088         from >> timegap;
00089 
00090         from >> tag;
00091         SUMOReal waygap;
00092         from >> waygap;
00093 
00094         SUMOReal vmax = -1;
00095         tag = readEndSecure(from);
00096         if (tag=="vmax") {
00097             from >> vmax;
00098         }
00099         ok = NIVissimDisturbance::dictionary(-1, "", edge, by,
00100                                              timegap, waygap, vmax);
00101         if (tag!="DATAEND") {
00102             tag = readEndSecure(from);
00103         }
00104     } while (tag!="DATAEND"&&ok);
00105     return ok;
00106 }
00107 
00108 
00109 
00110 bool
00111 NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseNumbered(std::istream &from) {
00112     //
00113     int id;
00114     from >> id;
00115     //
00116     std::string tag;
00117     from >> tag;
00118     std::string name = readName(from);
00119     // skip optional "Beschriftung"
00120     while (tag!="ort") {
00121         tag = myRead(from);
00122     }
00123     //
00124     from >> tag; // "Strecke"
00125     NIVissimExtendedEdgePoint edge = parsePos(from);
00126     bool ok = true;
00127     do {
00128         from >> tag; // "Ort"
00129         from >> tag; // "Strecke"
00130         NIVissimExtendedEdgePoint by = parsePos(from);
00131         //
00132         SUMOReal timegap;
00133         from >> timegap;
00134 
00135         SUMOReal waygap;
00136         from >> tag;
00137         from >> waygap;
00138 
00139         SUMOReal vmax = -1;
00140         tag = readEndSecure(from);
00141         if (tag=="vmax") {
00142             from >> vmax;
00143         }
00144 
00145         ok = NIVissimDisturbance::dictionary(id, name, edge, by,
00146                                              timegap, waygap, vmax);
00147         if (tag!="DATAEND") {
00148             tag = readEndSecure(from);
00149         }
00150     } while (tag!="DATAEND"&&ok);
00151     return ok;
00152 }
00153 
00154 
00155 
00156 NIVissimExtendedEdgePoint
00157 NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePos(std::istream &from) {
00158     int edgeid;
00159     from >> edgeid; // type-checking is missing!
00160     //
00161     std::string tag;
00162     from >> tag;
00163     from >> tag;
00164     IntVector lanes;
00165     if (tag=="ALLE") {
00166         //lanes.push_back(1); // !!!
00167     } else {
00168         lanes.push_back(TplConvert<char>::_2int(tag.c_str()));
00169     }
00170     //
00171     SUMOReal position;
00172     from >> tag;
00173     from >> position;
00174     // assigned vehicle types
00175     IntVector types;
00176     from >> tag;
00177     while (tag!="zeitluecke"&&tag!="durch"&&tag!="DATAEND"&&tag!="alle") {
00178         tag = readEndSecure(from);
00179         if (tag!="DATAEND") {
00180             if (tag=="alle") {
00181                 types.push_back(-1);
00182                 from >> tag;
00183                 tag = "alle";
00184             } else if (tag!="zeitluecke"&&tag!="durch"&&tag!="DATAEND") {
00185                 int tmp = TplConvert<char>::_2int(tag.c_str());
00186                 types.push_back(tmp);
00187             }
00188         }
00189     }
00190     return NIVissimExtendedEdgePoint(edgeid, lanes, position, types);
00191 }
00192 
00193 
00194 
00195 /****************************************************************************/
00196 

Generated on Wed May 5 00:06:34 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6