SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBNodeCont.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // Container for nodes during the netbuilding process
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
14 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef NBNodeCont_h
25 #define NBNodeCont_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <string>
38 #include <map>
39 #include <vector>
40 #include <set>
41 #include <utils/geom/Position.h>
42 #include "NBEdgeCont.h"
43 #include "NBNode.h"
45 
46 
47 // ===========================================================================
48 // class declarations
49 // ===========================================================================
50 class NBDistrict;
51 class OptionsCont;
52 class OutputDevice;
53 class NBJoinedEdgesMap;
54 
55 
56 // ===========================================================================
57 // class definitions
58 // ===========================================================================
63 class NBNodeCont {
64 public:
66  NBNodeCont();
67 
68 
70  ~NBNodeCont();
71 
72 
73 
76 
83  bool insert(const std::string& id, const Position& position,
84  NBDistrict* district);
85 
86 
92  bool insert(const std::string& id, const Position& position);
93 
94 
99  Position insert(const std::string& id);
100 
101 
106  bool insert(NBNode* node);
107 
108 
113  bool erase(NBNode* node);
114 
115 
121  bool extract(NBNode* node, bool remember = false);
122 
127  NBNode* retrieve(const std::string& id) const;
128 
129 
135  NBNode* retrieve(const Position& position, SUMOReal offset = 0.) const;
136 
137 
141  std::map<std::string, NBNode*>::const_iterator begin() const {
142  return myNodes.begin();
143  }
144 
145 
149  std::map<std::string, NBNode*>::const_iterator end() const {
150  return myNodes.end();
151  }
153 
154 
155 
158 
159  /* @brief add ids of nodes wich shall not be joined
160  * @param[in] ids A list of ids to exclude from joining
161  * @param[in] check Whether to check if these nodes are known
162  * @note checking is off by default because all nodes may not have been loaded yet
163  */
164  void addJoinExclusion(const std::vector<std::string>& ids, bool check = false);
165 
166 
170  void addCluster2Join(std::set<std::string> cluster);
171 
172 
176 
177 
180  unsigned int joinJunctions(SUMOReal maxdist, NBDistrictCont& dc, NBEdgeCont& ec, NBTrafficLightLogicCont& tlc);
182 
183 
184 
187 
195 
196 
204 
205 
215 
216 
233  NBTrafficLightLogicCont& tlc, bool removeGeometryNodes);
235 
236 
237 
240 
247 
248 
254  void joinTLS(NBTrafficLightLogicCont& tlc, SUMOReal maxdist);
255 
256 
263  void setAsTLControlled(NBNode* node, NBTrafficLightLogicCont& tlc, std::string id = "");
265 
266 
269  void rename(NBNode* node, const std::string& newID);
270 
271 
273  void computeLanes2Lanes();
274 
276  void computeLogics(const NBEdgeCont& ec, OptionsCont& oc);
277 
281  unsigned int size() const {
282  return (unsigned int) myNodes.size();
283  }
284 
286  void clear();
287 
288 
289 
290  std::string getFreeID();
291 
292  void computeNodeShapes(bool leftHand);
293 
294 
295 
296 
302  void printBuiltNodesStatistics() const;
303 
304 
306  std::vector<std::string> getAllNames() const;
307 
308 
309  /* @brief analyzes a cluster of nodes which shall be joined
310  * @param[in] cluster The nodes to be joined
311  * @param[out] id The name for the new node
312  * @param[out] pos The position of the new node
313  * @param[out] hasTLS Whether the new node has a traffic light
314  */
315  void analyzeCluster(std::set<NBNode*> cluster, std::string& id, Position& pos, bool& hasTLS);
316 
318  void registerJoinedCluster(const std::set<NBNode*>& cluster);
319 
321  const std::vector<std::set<std::string> >& getJoinedClusters() const {
322  return myJoinedClusters;
323  }
324 
325 
326 private:
329 
331  typedef std::vector<std::set<NBNode*> > NodeClusters;
332 
333 
341  void generateNodeClusters(SUMOReal maxDist, NodeClusters& into) const;
342 
343 
344  // @brief joins the given node clusters
345  void joinNodeClusters(NodeClusters clusters,
347 
349 
350 
351 
354 
359  bool shouldBeTLSControlled(const std::set<NBNode*>& c) const;
361 
362 
363 private:
366 
368  typedef std::map<std::string, NBNode*> NodeCont;
369 
372 
374  std::set<NBNode*> myExtractedNodes;
375 
376  // @brief set of node ids which should not be joined
377  std::set<std::string> myJoinExclusions;
378 
379  // @brief loaded sets of node ids to join (cleared after use)
380  std::vector<std::set<std::string> > myClusters2Join;
381  // @brief sets of node ids which were joined
382  std::vector<std::set<std::string> > myJoinedClusters;
383 
385  std::set<std::string> myJoined;
386 
387 private:
389  NBNodeCont(const NBNodeCont& s);
390 
392  NBNodeCont& operator=(const NBNodeCont& s);
393 
394 };
395 
396 
397 #endif
398 
399 /****************************************************************************/
400