Eclipse SUMO - Simulation of Urban MObility
NBCapacity2Lanes.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 /****************************************************************************/
15 // A helper class which computes the lane number from given capacity
16 /****************************************************************************/
17 #ifndef NBCapacity2Lanes_h
18 #define NBCapacity2Lanes_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 
27 // ===========================================================================
28 // class definitions
29 // ===========================================================================
40 public:
45  NBCapacity2Lanes(double divider) : myDivider(divider) { }
46 
47 
50 
51 
60  int get(double capacity) const {
61  capacity /= myDivider;
62  if (capacity > (int) capacity) {
63  capacity += 1;
64  }
65  // just assure that the number of lanes is not zero
66  if (capacity == 0) {
67  capacity = 1;
68  }
69  return (int) capacity;
70  }
71 
72 private:
74  double myDivider;
75 
76 };
77 
78 
79 #endif
80 
81 /****************************************************************************/
82 
NBCapacity2Lanes::myDivider
double myDivider
The norming divider.
Definition: NBCapacity2Lanes.h:74
NBCapacity2Lanes::~NBCapacity2Lanes
~NBCapacity2Lanes()
Destructor.
Definition: NBCapacity2Lanes.h:49
NBCapacity2Lanes::get
int get(double capacity) const
Returns the number of lanes computed from the given capacity.
Definition: NBCapacity2Lanes.h:60
NBCapacity2Lanes::NBCapacity2Lanes
NBCapacity2Lanes(double divider)
Donstructor.
Definition: NBCapacity2Lanes.h:45
NBCapacity2Lanes
A helper class which computes the lane number from given capacity.
Definition: NBCapacity2Lanes.h:39
config.h