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 /****************************************************************************/
16 // A class representing a single district
17 /****************************************************************************/
18 #ifndef NBDistrict_h
19 #define NBDistrict_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <vector>
28 #include <string>
29 #include <utility>
30 #include "NBCont.h"
31 #include <utils/common/Named.h>
33 #include <utils/geom/Position.h>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class NBEdge;
41 class OutputDevice;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
64 class NBDistrict : public Named {
65 public:
71  NBDistrict(const std::string& id, const Position& pos);
72 
73 
80  NBDistrict(const std::string& id);
81 
82 
84  ~NBDistrict();
85 
86 
99  bool addSource(NBEdge* const source, double weight);
100 
101 
114  bool addSink(NBEdge* const sink, double weight);
115 
116 
122  const Position& getPosition() const {
123  return myPosition;
124  }
125 
126 
132  void setCenter(const Position& pos);
133 
134 
146  void replaceIncoming(const EdgeVector& which, NBEdge* const by);
147 
148 
160  void replaceOutgoing(const EdgeVector& which, NBEdge* const by);
161 
162 
169  void removeFromSinksAndSources(NBEdge* const e);
170 
171 
176  void addShape(const PositionVector& p);
177 
178 
182  const std::vector<double>& getSourceWeights() const {
183  return mySourceWeights;
184  }
185 
186 
190  const std::vector<NBEdge*>& getSourceEdges() const {
191  return mySources;
192  }
193 
194 
198  const std::vector<double>& getSinkWeights() const {
199  return mySinkWeights;
200  }
201 
202 
206  const std::vector<NBEdge*>& getSinkEdges() const {
207  return mySinks;
208  }
209 
210 
214  const PositionVector& getShape() const {
215  return myShape;
216  }
217 
218 
219 
222 
227  void reshiftPosition(double xoff, double yoff);
228 
230  void mirrorX();
232 
233 
234 
235 
236 
237 private:
239  typedef std::vector<double> WeightsCont;
240 
243 
246 
249 
252 
255 
258 
259 
260 private:
263 
266 
267 
268 };
269 
270 
271 #endif
272 
273 /****************************************************************************/
274 
NBDistrict::NBDistrict
NBDistrict(const std::string &id, const Position &pos)
Constructor with id, and position.
Definition: NBDistrict.cpp:41
NBDistrict::mySinks
EdgeVector mySinks
The sinks (connection from network to district)
Definition: NBDistrict.h:248
NBDistrict::getSourceEdges
const std::vector< NBEdge * > & getSourceEdges() const
Returns the sources.
Definition: NBDistrict.h:190
Named
Base class for objects which have an id.
Definition: Named.h:56
NBDistrict::getSourceWeights
const std::vector< double > & getSourceWeights() const
Returns the weights of the sources.
Definition: NBDistrict.h:182
NBDistrict::getSinkEdges
const std::vector< NBEdge * > & getSinkEdges() const
Returns the sinks.
Definition: NBDistrict.h:206
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
NBDistrict::replaceOutgoing
void replaceOutgoing(const EdgeVector &which, NBEdge *const by)
Replaces outgoing edges from the vector (source) by the given edge.
Definition: NBDistrict.cpp:133
EdgeVector
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
NBDistrict::getPosition
const Position & getPosition() const
Returns the position of this district's center.
Definition: NBDistrict.h:122
NBDistrict::getSinkWeights
const std::vector< double > & getSinkWeights() const
Returns the weights of the sinks.
Definition: NBDistrict.h:198
PositionVector
A list of positions.
Definition: PositionVector.h:45
NBDistrict::operator=
NBDistrict & operator=(const NBDistrict &s)
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:91
NBDistrict::myShape
PositionVector myShape
The shape of the dsitrict.
Definition: NBDistrict.h:257
NBDistrict::removeFromSinksAndSources
void removeFromSinksAndSources(NBEdge *const e)
Removes the given edge from the lists of sources and sinks.
Definition: NBDistrict.cpp:165
VectorHelper.h
NBDistrict::reshiftPosition
void reshiftPosition(double xoff, double yoff)
Applies an offset to the district.
Definition: NBDistrict.cpp:55
NBDistrict::addShape
void addShape(const PositionVector &p)
Sets the shape of this district.
Definition: NBDistrict.cpp:183
Named.h
NBDistrict::WeightsCont
std::vector< double > WeightsCont
Definition of a vector of connection weights.
Definition: NBDistrict.h:239
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
NBDistrict::mySinkWeights
WeightsCont mySinkWeights
The weights of the sinks.
Definition: NBDistrict.h:251
Position.h
NBDistrict::myPosition
Position myPosition
The position of the district.
Definition: NBDistrict.h:254
NBDistrict::addSink
bool addSink(NBEdge *const sink, double weight)
Adds a sink.
Definition: NBDistrict.cpp:82
NBDistrict::mirrorX
void mirrorX()
mirror coordinates along the x-axis
Definition: NBDistrict.cpp:62
config.h
NBDistrict::setCenter
void setCenter(const Position &pos)
Sets the center coordinates.
Definition: NBDistrict.cpp:95
NBDistrict::mySourceWeights
WeightsCont mySourceWeights
The weights of the sources.
Definition: NBDistrict.h:245
NBDistrict::NBDistrict
NBDistrict(const NBDistrict &s)
NBDistrict::~NBDistrict
~NBDistrict()
Destructor.
Definition: NBDistrict.cpp:50
NBDistrict::addSource
bool addSource(NBEdge *const source, double weight)
Adds a source.
Definition: NBDistrict.cpp:69
NBDistrict::replaceIncoming
void replaceIncoming(const EdgeVector &which, NBEdge *const by)
Replaces incoming edges from the vector (sinks) by the given edge.
Definition: NBDistrict.cpp:101
PositionVector.h
NBDistrict
A class representing a single district.
Definition: NBDistrict.h:64
NBDistrict::mySources
EdgeVector mySources
The sources (connection from district to network)
Definition: NBDistrict.h:242
NBDistrict::getShape
const PositionVector & getShape() const
Returns the shape.
Definition: NBDistrict.h:214
NBCont.h