Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NBDistrict.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// A class representing a single district
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <vector>
26#include <string>
27#include <utility>
28#include "NBCont.h"
29#include <utils/common/Named.h>
31#include <utils/geom/Position.h>
33
34
35// ===========================================================================
36// class declarations
37// ===========================================================================
38class NBEdge;
39class OutputDevice;
40
41
42// ===========================================================================
43// class definitions
44// ===========================================================================
62class NBDistrict : public Named {
63public:
69 NBDistrict(const std::string& id, const Position& pos);
70
71
78 NBDistrict(const std::string& id);
79
80
83
84
97 bool addSource(NBEdge* const source, double weight);
98
99
112 bool addSink(NBEdge* const sink, double weight);
113
114
120 const Position& getPosition() const {
121 return myPosition;
122 }
123
124
130 void setCenter(const Position& pos);
131
132
144 void replaceIncoming(const EdgeVector& which, NBEdge* const by);
145
146
158 void replaceOutgoing(const EdgeVector& which, NBEdge* const by);
159
160
167 void removeFromSinksAndSources(NBEdge* const e);
168
169
174 void addShape(const PositionVector& p);
175
176
180 const std::vector<double>& getSourceWeights() const {
181 return mySourceWeights;
182 }
183
184
188 const std::vector<NBEdge*>& getSourceEdges() const {
189 return mySources;
190 }
191
192
196 const std::vector<double>& getSinkWeights() const {
197 return mySinkWeights;
198 }
199
200
204 const std::vector<NBEdge*>& getSinkEdges() const {
205 return mySinks;
206 }
207
208
212 const PositionVector& getShape() const {
213 return myShape;
214 }
215
216
217
220
225 void reshiftPosition(double xoff, double yoff);
226
228 void mirrorX();
230
231
232
233
234
235private:
237 typedef std::vector<double> WeightsCont;
238
241
244
247
250
253
256
257
258private:
261
264
265
266};
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition NBCont.h:42
A class representing a single district.
Definition NBDistrict.h:62
bool addSink(NBEdge *const sink, double weight)
Adds a sink.
Position myPosition
The position of the district.
Definition NBDistrict.h:252
const std::vector< double > & getSourceWeights() const
Returns the weights of the sources.
Definition NBDistrict.h:180
std::vector< double > WeightsCont
Definition of a vector of connection weights.
Definition NBDistrict.h:237
void mirrorX()
mirror coordinates along the x-axis
void replaceIncoming(const EdgeVector &which, NBEdge *const by)
Replaces incoming edges from the vector (sinks) by the given edge.
EdgeVector mySources
The sources (connection from district to network)
Definition NBDistrict.h:240
void addShape(const PositionVector &p)
Sets the shape of this district.
bool addSource(NBEdge *const source, double weight)
Adds a source.
EdgeVector mySinks
The sinks (connection from network to district)
Definition NBDistrict.h:246
NBDistrict & operator=(const NBDistrict &s)
void replaceOutgoing(const EdgeVector &which, NBEdge *const by)
Replaces outgoing edges from the vector (source) by the given edge.
void reshiftPosition(double xoff, double yoff)
Applies an offset to the district.
~NBDistrict()
Destructor.
const std::vector< double > & getSinkWeights() const
Returns the weights of the sinks.
Definition NBDistrict.h:196
WeightsCont mySourceWeights
The weights of the sources.
Definition NBDistrict.h:243
void setCenter(const Position &pos)
Sets the center coordinates.
const PositionVector & getShape() const
Returns the shape.
Definition NBDistrict.h:212
const std::vector< NBEdge * > & getSinkEdges() const
Returns the sinks.
Definition NBDistrict.h:204
PositionVector myShape
The shape of the dsitrict.
Definition NBDistrict.h:255
WeightsCont mySinkWeights
The weights of the sinks.
Definition NBDistrict.h:249
void removeFromSinksAndSources(NBEdge *const e)
Removes the given edge from the lists of sources and sinks.
const Position & getPosition() const
Returns the position of this district's center.
Definition NBDistrict.h:120
const std::vector< NBEdge * > & getSourceEdges() const
Returns the sources.
Definition NBDistrict.h:188
NBDistrict(const NBDistrict &s)
The representation of a single edge during network building.
Definition NBEdge.h:92
Base class for objects which have an id.
Definition Named.h:54
Static storage of an output device and its base (abstract) implementation.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.