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