SUMO - Simulation of Urban MObility

NIImporter_VISUM.h

Go to the documentation of this file.
00001 /****************************************************************************/
00008 // A VISUM network importer
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 #ifndef NIImporter_VISUM_h
00022 #define NIImporter_VISUM_h
00023 
00024 
00025 // ===========================================================================
00026 // included modules
00027 // ===========================================================================
00028 #ifdef _MSC_VER
00029 #include <windows_config.h>
00030 #else
00031 #include <config.h>
00032 #endif
00033 
00034 #include <string>
00035 #include <map>
00036 #include <vector>
00037 #include <netbuild/NBCapacity2Lanes.h>
00038 #include <utils/importio/LineHandler.h>
00039 #include <utils/importio/LineReader.h>
00040 #include <utils/importio/NamedColumnsParser.h>
00041 #include "NIVisumTL.h"
00042 
00043 
00044 // ===========================================================================
00045 // class declaration
00046 // ===========================================================================
00047 class OptionsCont;
00048 class NBNetBuilder;
00049 class NBNodeCont;
00050 class NBEdgeCont;
00051 class NBNode;
00052 class NBEdge;
00053 
00054 
00055 // ===========================================================================
00056 // class declaration
00057 // ===========================================================================
00076 class NIImporter_VISUM {
00077 public:
00089     static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
00090 
00091 
00092 protected:
00103     NIImporter_VISUM(NBNetBuilder& nb, const std::string& file,
00104                      NBCapacity2Lanes capacity2Lanes, bool useVisumPrio) ;
00105 
00106 
00108     ~NIImporter_VISUM() ;
00109 
00110 
00121     void load() ;
00122 
00123 private:
00132     SUMOReal getNamedFloat(const std::string& fieldName) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00133 
00143     SUMOReal getNamedFloat(const std::string& fieldName1, const std::string& fieldName2) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00144 
00145 
00152     SUMOReal getNamedFloat(const std::string& fieldName, SUMOReal defaultValue) ;
00153 
00161     SUMOReal getNamedFloat(const std::string& fieldName1, const std::string& fieldName2,
00162                            SUMOReal defaultValue) ;
00163 
00164 
00175     std::string getNamedString(const std::string& fieldName) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00176 
00186     std::string getNamedString(const std::string& fieldName1, const std::string& fieldName2) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00187 
00188 
00198     SUMOReal getWeightedFloat(const std::string& name) ;
00199 
00200 
00210     bool getWeightedBool(const std::string& name) ;
00211 
00212 
00225     NBNode* getNamedNode(const std::string& fieldName) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00226 
00236     NBNode* getNamedNode(const std::string& fieldName1, const std::string& fieldName2) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00237 
00238 
00251     NBEdge* getNamedEdge(const std::string& fieldName) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00252 
00262     NBEdge* getNamedEdge(const std::string& fieldName1, const std::string& fieldName2) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00263 
00264 
00279     NBEdge* getNamedEdgeContinuating(const std::string& fieldName, NBNode* node) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00280 
00291     NBEdge* getNamedEdgeContinuating(const std::string& fieldName1, const std::string& fieldName2,
00292                                      NBNode* node) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00293 
00300     NBEdge* getNamedEdgeContinuating(NBEdge* begin, NBNode* node) ;
00301 
00302 
00309     NBEdge* getEdge(NBNode* FromNode, NBNode* ToNode) ;
00310 
00311 
00322     NBEdge* getReversedContinuating(NBEdge* edge, NBNode* node) ;
00323 
00324 
00337     NBNode* buildDistrictNode(const std::string& id, NBNode* dest, bool isSource) ;
00338 
00339 
00348     bool checkNodes(NBNode* from, NBNode* to) ;
00349 
00350 
00351 private:
00358     typedef void (NIImporter_VISUM::*ParsingFunction)();
00359 
00364     struct TypeParser {
00368         std::string name;
00369 
00373         ParsingFunction function;
00374 
00379         long position;
00380 
00384         std::string pattern;
00385 
00386     };
00387 
00389     void parse_VSysTypes();
00390 
00392     void parse_Types();
00393 
00395     void parse_Nodes();
00396 
00398     void parse_Districts();
00399 
00401     void parse_Point();
00402 
00403 
00405     void parse_Edges();
00406 
00408     void parse_PartOfArea();
00409 
00411     void parse_Kante();
00412 
00413 
00415     void parse_Connectors();
00416 
00418     void parse_Turns();
00419 
00421     void parse_EdgePolys();
00422 
00424     void parse_Lanes();
00425 
00427     void parse_TrafficLights();
00428 
00430     void parse_NodesToTrafficLights();
00431 
00433     void parse_SignalGroups();
00434 
00436     void parse_TurnsToSignalGroups();
00437 
00439     void parse_AreaSubPartElement();
00440 
00442     void parse_Phases();
00443 
00445     void parse_SignalGroupsToPhases();
00446 
00448     void parse_LanesConnections();
00449 
00450 
00457     void addParser(const std::string& name, ParsingFunction function) ;
00458 
00459 
00460 private:
00462     NBNetBuilder& myNetBuilder;
00463 
00465     std::string myFileName;
00466 
00468     LineReader myLineReader;
00469 
00473     NamedColumnsParser myLineParser;
00474 
00476     NBCapacity2Lanes myCapacity2Lanes;
00477 
00479     typedef std::map<std::string, std::string> VSysTypeNames;
00481     VSysTypeNames myVSysTypes;
00482 
00484     typedef std::vector<TypeParser> ParserVector;
00486     ParserVector mySingleDataParsers;
00487 
00489     typedef std::map<std::string, NIVisumTL*> NIVisumTL_Map;
00490     // list of visum traffic lights
00491     NIVisumTL_Map myNIVisumTLs;
00492 
00494     std::vector<std::string > myTouchedEdges;
00495 
00497     bool myUseVisumPrio;
00498 
00500     std::string myCurrentID;
00501 
00502 
00504     std::map<long, Position> myPoints;
00505 
00507     std::map<long, std::pair<long, long> > myEdges;
00508 
00510     std::map<long, NBDistrict*> myShapeDistrictMap;
00511 
00513     std::map<long, std::vector<long> > mySubPartsAreas;
00514 
00516     std::map<NBDistrict*, PositionVector> myDistrictShapes;
00517 
00518 
00519 };
00520 
00521 
00522 #endif
00523 
00524 /****************************************************************************/
00525 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines