MATSIM
LanesBasedWidthCalculator.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * LanesBasedWidthCalculator.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2007 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.utils.gis.matsim2esri.network;
22 
23 import org.apache.logging.log4j.LogManager;
24 import org.apache.logging.log4j.Logger;
27 
28 public class LanesBasedWidthCalculator implements WidthCalculator {
29 
30  private static final Logger log = LogManager.getLogger(LanesBasedWidthCalculator.class);
31 
32  private final double effectiveLaneWidth;
33  private final double widthCoefficient;
34 
38  public LanesBasedWidthCalculator(final Network network, final Double coef) {
39  double w = network.getEffectiveLaneWidth();
40  if (Double.isNaN(w)) {
41  log.warn("Effective lane width in network is set to Double.NaN. Set a real value in your network.xml to make this tool work with this value. Using 3.75 as effective lane width...");
42  this.effectiveLaneWidth = 3.75;
43  }
44  else {
45  this.effectiveLaneWidth = w;
46  }
47  this.widthCoefficient = coef;
48  }
49 
50  @Override
51  public double getWidth(final Link link) {
52  return link.getNumberOfLanes() * this.effectiveLaneWidth * this.widthCoefficient;
53  }
54 
55 }