SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Parkplatzdefinition.cpp
Go to the documentation of this file.
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 <vector>
00034 #include <utility>
00035 #include <utils/common/TplConvert.h>
00036 #include <utils/common/ToString.h>
00037 #include <utils/common/VectorHelper.h>
00038 #include <netbuild/NBDistrictCont.h>
00039 #include <netbuild/NBDistrict.h>
00040 #include <netbuild/NBNode.h>
00041 #include <netbuild/NBNodeCont.h>
00042 #include "../NIImporter_Vissim.h"
00043 #include "../tempstructs/NIVissimDistrictConnection.h"
00044 #include "NIVissimSingleTypeParser_Parkplatzdefinition.h"
00045 
00046 #ifdef CHECK_MEMORY_LEAKS
00047 #include <foreign/nvwa/debug_new.h>
00048 #endif // CHECK_MEMORY_LEAKS
00049 
00050 
00051 // ===========================================================================
00052 // method definitions
00053 // ===========================================================================
00054 NIVissimSingleTypeParser_Parkplatzdefinition::NIVissimSingleTypeParser_Parkplatzdefinition(NIImporter_Vissim& parent)
00055     : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
00056 
00057 
00058 NIVissimSingleTypeParser_Parkplatzdefinition::~NIVissimSingleTypeParser_Parkplatzdefinition() {}
00059 
00060 
00061 bool
00062 NIVissimSingleTypeParser_Parkplatzdefinition::parse(std::istream& from) {
00063     int id;
00064     from >> id;
00065 
00066     std::string tag;
00067     from >> tag;
00068     std::string name = readName(from);
00069 
00070     // parse the districts
00071     //  and allocate them if not done before
00072     //  A district may be already saved when another parking place with
00073     //  the same district was already build.
00074     std::vector<int> districts;
00075     std::vector<SUMOReal> percentages;
00076     readUntil(from, "bezirke"); // "Bezirke"
00077     while (tag != "ort") {
00078         SUMOReal perc = -1;
00079         int districtid;
00080         from >> districtid;
00081         tag = myRead(from);
00082         if (tag == "anteil") {
00083             from >> perc;
00084         }
00085         districts.push_back(districtid);
00086         percentages.push_back(perc);
00087         tag = myRead(from);
00088     }
00089 
00090     from >> tag; // "Strecke"
00091     int edgeid;
00092     from >> edgeid;
00093 
00094     SUMOReal position;
00095     from >> tag; // "bei"
00096     from >> position;
00097 
00098     SUMOReal length;
00099     from >> tag;
00100     from >> length;
00101 
00102     from >> tag; // "Kapazität"
00103     from >> tag; // "Kapazität"-value
00104 
00105     tag = myRead(from);
00106     if (tag == "belegung") {
00107         from >> tag;
00108         tag = myRead(from); // "fahrzeugklasse"
00109     }
00110 
00111     std::vector<std::pair<int, int> > assignedVehicles;
00112     while (tag != "default") {
00113         int vclass;
00114         from >> vclass;
00115         from >> tag; // "vwunsch"
00116         int vwunsch;
00117         from >> vwunsch; // "vwunsch"-value
00118         assignedVehicles.push_back(std::pair<int, int>(vclass, vwunsch));
00119         tag = myRead(from);
00120     }
00121 
00122     from >> tag;
00123     from >> tag;
00124 //    NIVissimEdge *e = NIVissimEdge::dictionary(edgeid);
00125 //    e->addReferencedDistrict(id);
00126 
00127     // build the district connection
00128     return NIVissimDistrictConnection::dictionary(id, name,
00129             districts, percentages, edgeid, position, assignedVehicles);
00130 }
00131 
00132 
00133 
00134 /****************************************************************************/
00135 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines