SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NBDistrict.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A class representing a single district
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NBDistrict_h
23 #define NBDistrict_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <string>
37 #include <utility>
38 #include "NBCont.h"
39 #include <utils/common/Named.h>
41 #include <utils/geom/Position.h>
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class NBEdge;
49 class OutputDevice;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
72 class NBDistrict : public Named {
73 public:
79  NBDistrict(const std::string& id, const Position& pos);
80 
81 
88  NBDistrict(const std::string& id);
89 
90 
92  ~NBDistrict();
93 
94 
107  bool addSource(NBEdge* const source, SUMOReal weight);
108 
109 
122  bool addSink(NBEdge* const sink, SUMOReal weight);
123 
124 
130  const Position& getPosition() const {
131  return myPosition;
132  }
133 
134 
140  void setCenter(const Position& pos);
141 
142 
154  void replaceIncoming(const EdgeVector& which, NBEdge* const by);
155 
156 
168  void replaceOutgoing(const EdgeVector& which, NBEdge* const by);
169 
170 
177  void removeFromSinksAndSources(NBEdge* const e);
178 
179 
184  void addShape(const PositionVector& p);
185 
186 
190  const std::vector<SUMOReal>& getSourceWeights() const {
191  return mySourceWeights;
192  }
193 
194 
198  const std::vector<NBEdge*>& getSourceEdges() const {
199  return mySources;
200  }
201 
202 
206  const std::vector<SUMOReal>& getSinkWeights() const {
207  return mySinkWeights;
208  }
209 
210 
214  const std::vector<NBEdge*>& getSinkEdges() const {
215  return mySinks;
216  }
217 
218 
222  const PositionVector& getShape() const {
223  return myShape;
224  }
225 
226 
227 
230 
235  void reshiftPosition(SUMOReal xoff, SUMOReal yoff);
237 
238 
239 
240 
241 
242 private:
244  typedef std::vector<SUMOReal> WeightsCont;
245 
248 
250  WeightsCont mySourceWeights;
251 
254 
256  WeightsCont mySinkWeights;
257 
260 
263 
264 
265 private:
267  NBDistrict(const NBDistrict& s);
268 
270  NBDistrict& operator=(const NBDistrict& s);
271 
272 
273 };
274 
275 
276 #endif
277 
278 /****************************************************************************/
279 
void replaceOutgoing(const EdgeVector &which, NBEdge *const by)
Replaces outgoing edges from the vector (source) by the given edge.
Definition: NBDistrict.cpp:138
WeightsCont mySinkWeights
The weights of the sinks.
Definition: NBDistrict.h:256
const Position & getPosition() const
Returns the position of this district's center.
Definition: NBDistrict.h:130
bool addSource(NBEdge *const source, SUMOReal weight)
Adds a source.
Definition: NBDistrict.cpp:74
The representation of a single edge during network building.
Definition: NBEdge.h:71
const std::vector< NBEdge * > & getSinkEdges() const
Returns the sinks.
Definition: NBDistrict.h:214
void addShape(const PositionVector &p)
Sets the shape of this district.
Definition: NBDistrict.cpp:188
NBDistrict(const std::string &id, const Position &pos)
Constructor with id, and position.
Definition: NBDistrict.cpp:53
NBDistrict & operator=(const NBDistrict &s)
EdgeVector mySources
The sources (connection from district to network)
Definition: NBDistrict.h:247
void setCenter(const Position &pos)
Sets the center coordinates.
Definition: NBDistrict.cpp:100
A class representing a single district.
Definition: NBDistrict.h:72
const std::vector< NBEdge * > & getSourceEdges() const
Returns the sources.
Definition: NBDistrict.h:198
Position myPosition
The position of the district.
Definition: NBDistrict.h:259
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
void removeFromSinksAndSources(NBEdge *const e)
Removes the given edge from the lists of sources and sinks.
Definition: NBDistrict.cpp:170
const PositionVector & getShape() const
Returns the shape.
Definition: NBDistrict.h:222
~NBDistrict()
Destructor.
Definition: NBDistrict.cpp:62
Base class for objects which have an id.
Definition: Named.h:45
EdgeVector mySinks
The sinks (connection from network to district)
Definition: NBDistrict.h:253
WeightsCont mySourceWeights
The weights of the sources.
Definition: NBDistrict.h:250
std::vector< SUMOReal > WeightsCont
Definition of a vector of connection weights.
Definition: NBDistrict.h:244
bool addSink(NBEdge *const sink, SUMOReal weight)
Adds a sink.
Definition: NBDistrict.cpp:87
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:41
PositionVector myShape
The shape of the dsitrict.
Definition: NBDistrict.h:262
void reshiftPosition(SUMOReal xoff, SUMOReal yoff)
Applies an offset to the district.
Definition: NBDistrict.cpp:67
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:218
const std::vector< SUMOReal > & getSourceWeights() const
Returns the weights of the sources.
Definition: NBDistrict.h:190
const std::vector< SUMOReal > & getSinkWeights() const
Returns the weights of the sinks.
Definition: NBDistrict.h:206
void replaceIncoming(const EdgeVector &which, NBEdge *const by)
Replaces incoming edges from the vector (sinks) by the given edge.
Definition: NBDistrict.cpp:106