Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A class representing a single district
18 /****************************************************************************/
19 #ifndef NBDistrict_h
20 #define NBDistrict_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <vector>
29 #include <string>
30 #include <utility>
31 #include "NBCont.h"
32 #include <utils/common/Named.h>
34 #include <utils/geom/Position.h>
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class NBEdge;
42 class OutputDevice;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
65 class NBDistrict : public Named {
66 public:
72  NBDistrict(const std::string& id, const Position& pos);
73 
74 
81  NBDistrict(const std::string& id);
82 
83 
85  ~NBDistrict();
86 
87 
100  bool addSource(NBEdge* const source, double weight);
101 
102 
115  bool addSink(NBEdge* const sink, double weight);
116 
117 
123  const Position& getPosition() const {
124  return myPosition;
125  }
126 
127 
133  void setCenter(const Position& pos);
134 
135 
147  void replaceIncoming(const EdgeVector& which, NBEdge* const by);
148 
149 
161  void replaceOutgoing(const EdgeVector& which, NBEdge* const by);
162 
163 
170  void removeFromSinksAndSources(NBEdge* const e);
171 
172 
177  void addShape(const PositionVector& p);
178 
179 
183  const std::vector<double>& getSourceWeights() const {
184  return mySourceWeights;
185  }
186 
187 
191  const std::vector<NBEdge*>& getSourceEdges() const {
192  return mySources;
193  }
194 
195 
199  const std::vector<double>& getSinkWeights() const {
200  return mySinkWeights;
201  }
202 
203 
207  const std::vector<NBEdge*>& getSinkEdges() const {
208  return mySinks;
209  }
210 
211 
215  const PositionVector& getShape() const {
216  return myShape;
217  }
218 
219 
220 
223 
228  void reshiftPosition(double xoff, double yoff);
229 
231  void mirrorX();
233 
234 
235 
236 
237 
238 private:
240  typedef std::vector<double> WeightsCont;
241 
244 
246  WeightsCont mySourceWeights;
247 
250 
252  WeightsCont mySinkWeights;
253 
256 
259 
260 
261 private:
263  NBDistrict(const NBDistrict& s);
264 
266  NBDistrict& operator=(const NBDistrict& s);
267 
268 
269 };
270 
271 
272 #endif
273 
274 /****************************************************************************/
275 
void replaceOutgoing(const EdgeVector &which, NBEdge *const by)
Replaces outgoing edges from the vector (source) by the given edge.
Definition: NBDistrict.cpp:134
const std::vector< NBEdge * > & getSourceEdges() const
Returns the sources.
Definition: NBDistrict.h:191
WeightsCont mySinkWeights
The weights of the sinks.
Definition: NBDistrict.h:252
The representation of a single edge during network building.
Definition: NBEdge.h:86
std::vector< double > WeightsCont
Definition of a vector of connection weights.
Definition: NBDistrict.h:240
void mirrorX()
mirror coordinates along the x-axis
Definition: NBDistrict.cpp:63
void reshiftPosition(double xoff, double yoff)
Applies an offset to the district.
Definition: NBDistrict.cpp:56
void addShape(const PositionVector &p)
Sets the shape of this district.
Definition: NBDistrict.cpp:184
NBDistrict(const std::string &id, const Position &pos)
Constructor with id, and position.
Definition: NBDistrict.cpp:42
NBDistrict & operator=(const NBDistrict &s)
EdgeVector mySources
The sources (connection from district to network)
Definition: NBDistrict.h:243
void setCenter(const Position &pos)
Sets the center coordinates.
Definition: NBDistrict.cpp:96
A class representing a single district.
Definition: NBDistrict.h:65
Position myPosition
The position of the district.
Definition: NBDistrict.h:255
const PositionVector & getShape() const
Returns the shape.
Definition: NBDistrict.h:215
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A list of positions.
void removeFromSinksAndSources(NBEdge *const e)
Removes the given edge from the lists of sources and sinks.
Definition: NBDistrict.cpp:166
~NBDistrict()
Destructor.
Definition: NBDistrict.cpp:51
Base class for objects which have an id.
Definition: Named.h:57
bool addSink(NBEdge *const sink, double weight)
Adds a sink.
Definition: NBDistrict.cpp:83
const std::vector< double > & getSinkWeights() const
Returns the weights of the sinks.
Definition: NBDistrict.h:199
EdgeVector mySinks
The sinks (connection from network to district)
Definition: NBDistrict.h:249
WeightsCont mySourceWeights
The weights of the sources.
Definition: NBDistrict.h:246
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:35
const std::vector< NBEdge * > & getSinkEdges() const
Returns the sinks.
Definition: NBDistrict.h:207
PositionVector myShape
The shape of the dsitrict.
Definition: NBDistrict.h:258
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
const std::vector< double > & getSourceWeights() const
Returns the weights of the sources.
Definition: NBDistrict.h:183
const Position & getPosition() const
Returns the position of this district&#39;s center.
Definition: NBDistrict.h:123
bool addSource(NBEdge *const source, double weight)
Adds a source.
Definition: NBDistrict.cpp:70
void replaceIncoming(const EdgeVector &which, NBEdge *const by)
Replaces incoming edges from the vector (sinks) by the given edge.
Definition: NBDistrict.cpp:102