SUMO - Simulation of Urban MObility
NBDistrict.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A class representing a single district
20 /****************************************************************************/
21 #ifndef NBDistrict_h
22 #define NBDistrict_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include <string>
36 #include <utility>
37 #include "NBCont.h"
38 #include <utils/common/Named.h>
40 #include <utils/geom/Position.h>
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class NBEdge;
48 class OutputDevice;
49 
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
71 class NBDistrict : public Named {
72 public:
78  NBDistrict(const std::string& id, const Position& pos);
79 
80 
87  NBDistrict(const std::string& id);
88 
89 
91  ~NBDistrict();
92 
93 
106  bool addSource(NBEdge* const source, double weight);
107 
108 
121  bool addSink(NBEdge* const sink, double weight);
122 
123 
129  const Position& getPosition() const {
130  return myPosition;
131  }
132 
133 
139  void setCenter(const Position& pos);
140 
141 
153  void replaceIncoming(const EdgeVector& which, NBEdge* const by);
154 
155 
167  void replaceOutgoing(const EdgeVector& which, NBEdge* const by);
168 
169 
176  void removeFromSinksAndSources(NBEdge* const e);
177 
178 
183  void addShape(const PositionVector& p);
184 
185 
189  const std::vector<double>& getSourceWeights() const {
190  return mySourceWeights;
191  }
192 
193 
197  const std::vector<NBEdge*>& getSourceEdges() const {
198  return mySources;
199  }
200 
201 
205  const std::vector<double>& getSinkWeights() const {
206  return mySinkWeights;
207  }
208 
209 
213  const std::vector<NBEdge*>& getSinkEdges() const {
214  return mySinks;
215  }
216 
217 
221  const PositionVector& getShape() const {
222  return myShape;
223  }
224 
225 
226 
229 
234  void reshiftPosition(double xoff, double yoff);
235 
237  void mirrorX();
239 
240 
241 
242 
243 
244 private:
246  typedef std::vector<double> WeightsCont;
247 
250 
252  WeightsCont mySourceWeights;
253 
256 
258  WeightsCont mySinkWeights;
259 
262 
265 
266 
267 private:
269  NBDistrict(const NBDistrict& s);
270 
272  NBDistrict& operator=(const NBDistrict& s);
273 
274 
275 };
276 
277 
278 #endif
279 
280 /****************************************************************************/
281 
void replaceOutgoing(const EdgeVector &which, NBEdge *const by)
Replaces outgoing edges from the vector (source) by the given edge.
Definition: NBDistrict.cpp:140
const std::vector< NBEdge * > & getSourceEdges() const
Returns the sources.
Definition: NBDistrict.h:197
WeightsCont mySinkWeights
The weights of the sinks.
Definition: NBDistrict.h:258
The representation of a single edge during network building.
Definition: NBEdge.h:70
std::vector< double > WeightsCont
Definition of a vector of connection weights.
Definition: NBDistrict.h:246
void mirrorX()
mirror coordinates along the x-axis
Definition: NBDistrict.cpp:69
void reshiftPosition(double xoff, double yoff)
Applies an offset to the district.
Definition: NBDistrict.cpp:62
void addShape(const PositionVector &p)
Sets the shape of this district.
Definition: NBDistrict.cpp:190
NBDistrict(const std::string &id, const Position &pos)
Constructor with id, and position.
Definition: NBDistrict.cpp:48
NBDistrict & operator=(const NBDistrict &s)
EdgeVector mySources
The sources (connection from district to network)
Definition: NBDistrict.h:249
void setCenter(const Position &pos)
Sets the center coordinates.
Definition: NBDistrict.cpp:102
A class representing a single district.
Definition: NBDistrict.h:71
Position myPosition
The position of the district.
Definition: NBDistrict.h:261
const PositionVector & getShape() const
Returns the shape.
Definition: NBDistrict.h:221
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
void removeFromSinksAndSources(NBEdge *const e)
Removes the given edge from the lists of sources and sinks.
Definition: NBDistrict.cpp:172
~NBDistrict()
Destructor.
Definition: NBDistrict.cpp:57
Base class for objects which have an id.
Definition: Named.h:45
bool addSink(NBEdge *const sink, double weight)
Adds a sink.
Definition: NBDistrict.cpp:89
const std::vector< double > & getSinkWeights() const
Returns the weights of the sinks.
Definition: NBDistrict.h:205
EdgeVector mySinks
The sinks (connection from network to district)
Definition: NBDistrict.h:255
WeightsCont mySourceWeights
The weights of the sources.
Definition: NBDistrict.h:252
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:40
const std::vector< NBEdge * > & getSinkEdges() const
Returns the sinks.
Definition: NBDistrict.h:213
PositionVector myShape
The shape of the dsitrict.
Definition: NBDistrict.h:264
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
const std::vector< double > & getSourceWeights() const
Returns the weights of the sources.
Definition: NBDistrict.h:189
const Position & getPosition() const
Returns the position of this district&#39;s center.
Definition: NBDistrict.h:129
bool addSource(NBEdge *const source, double weight)
Adds a source.
Definition: NBDistrict.cpp:76
void replaceIncoming(const EdgeVector &which, NBEdge *const by)
Replaces incoming edges from the vector (sinks) by the given edge.
Definition: NBDistrict.cpp:108