SUMO - Simulation of Urban MObility
|
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 00388 00389 00391 void parse_VSysTypes(); 00392 00394 void parse_Types(); 00395 00397 void parse_Nodes(); 00398 00400 void parse_Districts(); 00401 00403 void parse_Point(); 00404 00405 00407 void parse_Edges(); 00408 00410 void parse_PartOfArea(); 00411 00413 void parse_Kante(); 00414 00415 00417 void parse_Connectors(); 00418 00420 void parse_Turns(); 00421 00423 void parse_EdgePolys(); 00424 00426 void parse_Lanes(); 00427 00429 void parse_TrafficLights(); 00430 00432 void parse_NodesToTrafficLights(); 00433 00435 void parse_SignalGroups(); 00436 00438 void parse_TurnsToSignalGroups(); 00439 00441 void parse_AreaSubPartElement(); 00442 00444 void parse_Phases(); 00445 00447 void parse_SignalGroupsToPhases(); 00448 00450 void parse_LanesConnections(); 00451 00452 00458 void addParser(const std::string& name, ParsingFunction function) ; 00459 00460 00461 private: 00463 NBNetBuilder& myNetBuilder; 00464 00466 std::string myFileName; 00467 00469 LineReader myLineReader; 00470 00474 NamedColumnsParser myLineParser; 00475 00477 NBCapacity2Lanes myCapacity2Lanes; 00478 00480 typedef std::map<std::string, std::string> VSysTypeNames; 00482 VSysTypeNames myVSysTypes; 00483 00485 typedef std::vector<TypeParser> ParserVector; 00487 ParserVector mySingleDataParsers; 00488 00490 typedef std::map<std::string, NIVisumTL*> NIVisumTL_Map; 00492 NIVisumTL_Map myTLS; 00493 00495 std::vector<std::string > myTouchedEdges; 00496 00498 bool myUseVisumPrio; 00499 00501 std::string myCurrentID; 00502 00503 00505 std::map<long, Position> myPoints; 00506 00508 std::map<long, std::pair<long, long> > myEdges; 00509 00511 std::map<long, NBDistrict*> myShapeDistrictMap; 00512 00514 std::map<long, std::vector<long> > mySubPartsAreas; 00515 00517 std::map<NBDistrict*, PositionVector> myDistrictShapes; 00518 00519 00520 }; 00521 00522 00523 #endif 00524 00525 /****************************************************************************/ 00526