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-sim.org/
14 // Copyright (C) 2001-2014 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>
42 #include <utils/geom/Position.h>
43 #include "NBEdgeCont.h"
44 #include "NBNode.h"
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class NBDistrict;
52 class OptionsCont;
53 class OutputDevice;
54 class NBJoinedEdgesMap;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
64 class NBNodeCont {
65 public:
67  NBNodeCont();
68 
69 
71  ~NBNodeCont();
72 
73 
74 
77 
84  bool insert(const std::string& id, const Position& position,
85  NBDistrict* district = 0);
86 
87 
92  Position insert(const std::string& id);
93 
94 
99  bool insert(NBNode* node);
100 
101 
106  bool erase(NBNode* node);
107 
108 
114  bool extract(NBNode* node, bool remember = false);
115 
120  NBNode* retrieve(const std::string& id) const;
121 
122 
128  NBNode* retrieve(const Position& position, const SUMOReal offset = 0.) const;
129 
130 
134  std::map<std::string, NBNode*>::const_iterator begin() const {
135  return myNodes.begin();
136  }
137 
138 
142  std::map<std::string, NBNode*>::const_iterator end() const {
143  return myNodes.end();
144  }
146 
147 
148 
151 
152  /* @brief add ids of nodes wich shall not be joined
153  * @param[in] ids A list of ids to exclude from joining
154  * @param[in] check Whether to check if these nodes are known
155  * @note checking is off by default because all nodes may not have been loaded yet
156  */
157  void addJoinExclusion(const std::vector<std::string>& ids, bool check = false);
158 
159 
163  void addCluster2Join(std::set<std::string> cluster);
164 
165 
169 
170 
173  unsigned int joinJunctions(SUMOReal maxDist, NBDistrictCont& dc, NBEdgeCont& ec, NBTrafficLightLogicCont& tlc);
175 
176 
177 
180 
188 
189 
197 
198 
208 
209 
226  NBTrafficLightLogicCont& tlc, bool removeGeometryNodes);
228 
229 
230 
233 
240 
241 
247  void joinTLS(NBTrafficLightLogicCont& tlc, SUMOReal maxdist);
248 
249 
257  void setAsTLControlled(NBNode* node, NBTrafficLightLogicCont& tlc, TrafficLightType type, std::string id = "");
259 
260 
263  void rename(NBNode* node, const std::string& newID);
264 
265 
267  void computeLanes2Lanes(const bool buildCrossingsAndWalkingAreas);
268 
270  void computeLogics(const NBEdgeCont& ec, OptionsCont& oc);
271 
275  unsigned int size() const {
276  return (unsigned int) myNodes.size();
277  }
278 
280  void clear();
281 
282 
283 
284  std::string getFreeID();
285 
290  void computeNodeShapes(bool leftHand, SUMOReal mismatchThreshold = -1);
291 
297  void printBuiltNodesStatistics() const;
298 
299 
301  std::vector<std::string> getAllNames() const;
302 
303 
304  /* @brief analyzes a cluster of nodes which shall be joined
305  * @param[in] cluster The nodes to be joined
306  * @param[out] id The name for the new node
307  * @param[out] pos The position of the new node
308  * @param[out] hasTLS Whether the new node has a traffic light
309  * @param[out] tlType The type of traffic light (if any)
310  */
311  void analyzeCluster(std::set<NBNode*> cluster, std::string& id, Position& pos,
312  bool& hasTLS, TrafficLightType& type);
313 
315  void registerJoinedCluster(const std::set<NBNode*>& cluster);
316 
318  const std::vector<std::set<std::string> >& getJoinedClusters() const {
319  return myJoinedClusters;
320  }
321 
322 
323  /* @brief discards traffic lights
324  * @param[in] geometryLike Whether only tls at geometry-like nodes shall be discarded
325  */
326  void discardTrafficLights(NBTrafficLightLogicCont& tlc, bool geometryLike, bool guessSignals);
327 
328 private:
331 
333  typedef std::vector<std::set<NBNode*> > NodeClusters;
334 
335 
343  void generateNodeClusters(SUMOReal maxDist, NodeClusters& into) const;
344 
345 
346  // @brief joins the given node clusters
347  void joinNodeClusters(NodeClusters clusters,
349 
351 
352 
353 
356 
361  bool shouldBeTLSControlled(const std::set<NBNode*>& c) const;
363 
364 
365 private:
368 
370  typedef std::map<std::string, NBNode*> NodeCont;
371 
374 
376  std::set<NBNode*> myExtractedNodes;
377 
378  // @brief set of node ids which should not be joined
379  std::set<std::string> myJoinExclusions;
380 
381  // @brief loaded sets of node ids to join (cleared after use)
382  std::vector<std::set<std::string> > myClusters2Join;
383  // @brief sets of node ids which were joined
384  std::vector<std::set<std::string> > myJoinedClusters;
385 
387  std::set<std::string> myJoined;
388 
391 
392 private:
394  NBNodeCont(const NBNodeCont& s);
395 
397  NBNodeCont& operator=(const NBNodeCont& s);
398 
399 };
400 
401 
402 #endif
403 
404 /****************************************************************************/
405