|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // Storage for edges, including some functionality operating on multiple edges 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 #ifndef NBEdgeCont_h 00023 #define NBEdgeCont_h 00024 00025 00026 // =========================================================================== 00027 // included modules 00028 // =========================================================================== 00029 #ifdef _MSC_VER 00030 #include <windows_config.h> 00031 #else 00032 #include <config.h> 00033 #endif 00034 00035 #include <map> 00036 #include <iostream> 00037 #include <string> 00038 #include <vector> 00039 #include <set> 00040 #include "NBCont.h" 00041 #include <utils/common/SUMOVehicleClass.h> 00042 #include <utils/common/UtilExceptions.h> 00043 #include <utils/geom/PositionVector.h> 00044 00045 00046 // =========================================================================== 00047 // class declarations 00048 // =========================================================================== 00049 class NBNodeCont; 00050 class NBTypeCont; 00051 class NBEdge; 00052 class NBNode; 00053 class OptionsCont; 00054 class NBDistrictCont; 00055 class NBTrafficLightLogicCont; 00056 class OutputDevice; 00057 00058 00059 // =========================================================================== 00060 // class definitions 00061 // =========================================================================== 00066 class NBEdgeCont { 00067 public: 00071 NBEdgeCont(NBTypeCont& tc) ; 00072 00073 00075 ~NBEdgeCont() ; 00076 00077 00086 void applyOptions(OptionsCont& oc); 00087 00088 00090 void clear() ; 00091 00092 00093 00094 00097 00111 bool insert(NBEdge* edge, bool ignorePrunning = false) ; 00112 00113 00122 NBEdge* retrieve(const std::string& id, bool retrieveExtracted = false) const ; 00123 00124 00137 NBEdge* retrievePossiblySplitted(const std::string& id, 00138 const std::string& hint, bool incoming) const ; 00139 00140 00151 NBEdge* retrievePossiblySplitted(const std::string& id, SUMOReal pos) const ; 00152 00153 00160 void erase(NBDistrictCont& dc, NBEdge* edge) ; 00161 00162 00171 void extract(NBDistrictCont& dc, NBEdge* edge, bool remember = false); 00172 00173 00177 std::map<std::string, NBEdge*>::const_iterator begin() const { 00178 return myEdges.begin(); 00179 } 00180 00181 00185 std::map<std::string, NBEdge*>::const_iterator end() const { 00186 return myEdges.end(); 00187 } 00189 00190 00191 00194 00208 bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node) ; 00209 00210 00231 bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node, 00232 const std::string& firstEdgeName, const std::string& secondEdgeName, 00233 unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge) ; 00234 00235 00248 bool splitAt(NBDistrictCont& dc, NBEdge* edge, SUMOReal edgepos, NBNode* node, 00249 const std::string& firstEdgeName, const std::string& secondEdgeName, 00250 unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge) ; 00252 00253 00254 00257 00261 unsigned int size() const { 00262 return (unsigned int) myEdges.size(); 00263 } 00264 00265 00270 std::vector<std::string> getAllNames() const ; 00271 00272 00276 unsigned int getNoEdgeSplits() const { 00277 return myEdgesSplit; 00278 } 00280 00281 00282 00285 00290 void removeUnwishedEdges(NBDistrictCont& dc); 00291 00292 00301 void splitGeometry(NBNodeCont& nc); 00303 00304 00305 00308 00316 void computeTurningDirections() ; 00317 00318 00326 void sortOutgoingLanesConnections() ; 00327 00328 00337 void computeEdge2Edges(bool noLeftMovers) ; 00338 00339 00347 void computeLanes2Edges() ; 00348 00349 00357 void recheckLanes() ; 00358 00359 00368 void appendTurnarounds(bool noTLSControlled) ; 00369 00370 00377 void appendTurnarounds(const std::set<std::string> &ids, bool noTLSControlled); 00378 00379 00388 void computeEdgeShapes() ; 00389 00390 00399 void recomputeLaneShapes() ; 00400 00401 00404 void clearControllingTLInformation() const; 00405 00406 00414 void joinSameNodeConnectingEdges(NBDistrictCont& dc, 00415 NBTrafficLightLogicCont& tlc, EdgeVector edges) ; 00416 00417 00422 void recheckLaneSpread() ; 00424 00425 00426 00430 void guessRoundabouts(std::vector<std::set<NBEdge*> > &marked) ; 00431 00432 00436 bool isLeftHanded() const { 00437 return myAmLeftHanded; 00438 } 00439 00440 00444 bool wasIgnored(std::string id) const { 00445 return myIgnoredEdges.count(id) != 0; 00446 } 00447 00448 00451 bool wasRemoved(std::string id) const { 00452 return myExtractedEdges.count(id) != 0; 00453 } 00454 00455 00456 private: 00463 EdgeVector getGeneratedFrom(const std::string& id) const ; 00464 00465 00467 bool ignoreFilterMatch(NBEdge *edge); 00468 00469 00470 private: 00472 typedef std::map<std::string, NBEdge*> EdgeCont; 00473 00475 EdgeCont myEdges; 00476 00478 EdgeCont myExtractedEdges; 00479 00481 std::set<std::string> myIgnoredEdges; 00482 00484 unsigned int myEdgesSplit; 00485 00487 bool myAmLeftHanded; 00488 00489 00492 00494 SUMOReal myEdgesMinSpeed; 00495 00497 bool myRemoveEdgesAfterJoining; 00498 00500 std::set<std::string> myEdges2Keep; 00501 00503 std::set<std::string> myEdges2Remove; 00504 00506 SUMOVehicleClasses myVehicleClasses2Keep; 00507 00509 SUMOVehicleClasses myVehicleClasses2Remove; 00510 00512 std::set<std::string> myTypes2Keep; 00513 00515 std::set<std::string> myTypes2Remove; 00516 00518 PositionVector myPrunningBoundary; 00519 00521 00522 00524 NBTypeCont& myTypeCont; 00525 00526 00527 private: 00529 NBEdgeCont(const NBEdgeCont& s); 00530 00532 NBEdgeCont& operator=(const NBEdgeCont& s); 00533 00534 00535 }; 00536 00537 00538 #endif 00539 00540 /****************************************************************************/ 00541