MATSIM
VisUtils.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.* *
3  * *
4  * *********************************************************************** *
5  * *
6  * copyright : (C) 2008 by the members listed in the COPYING, *
7  * LICENSE and WARRANTY file. *
8  * email : info at matsim dot org *
9  * *
10  * *********************************************************************** *
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * See also COPYING, LICENSE and WARRANTY file *
17  * *
18  * *********************************************************************** */
19 package org.matsim.core.mobsim.qsim.qnetsimengine;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 
26 
31 final class VisUtils {
32  private VisUtils() {} // only for static methods; do not instantiate
33 
39  static List<Identifiable<Person>> getPeopleInVehicle(QVehicle vehicle) {
40 
41  List<Identifiable<Person>> result = new ArrayList<>();
42  result.add(vehicle.getDriver());
43  result.addAll(vehicle.getPassengers());
44  return result;
45  }
46 
47  public static int guessLane(QVehicle veh, int numberOfLanes){
48  int tmpLane;
49  try {
50  tmpLane = Integer.parseInt(veh.getId().toString()) ;
51  } catch ( NumberFormatException ee ) {
52  tmpLane = veh.getId().hashCode() ;
53  if (tmpLane < 0 ){
54  tmpLane = -tmpLane;
55  }
56  }
57  return 1 + (tmpLane % numberOfLanes);
58  }
59 
60  public static double calcSpeedValueBetweenZeroAndOne(QVehicle veh, double inverseSimulatedFlowCapacity, double now, double freespeed){
61  int cmp = (int) (veh.getEarliestLinkExitTime() + inverseSimulatedFlowCapacity + 2.0);
62  // "inverseSimulatedFlowCapacity" is there to keep vehicles green that only wait for capacity (i.e. have no vehicle
63  // ahead). Especially important with small samples sizes. This is debatable :-). kai, jan'11
64 
65  return (now > cmp ? 0.0 : 1.0);
66  }
67 
68 }