MATSIM
EquiDistAgentSnapshotInfoBuilder.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * PositionInfoBuilder
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2010 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 package org.matsim.core.mobsim.qsim.qnetsimengine;
21 
22 import java.util.Collection;
23 
24 import org.matsim.api.core.v01.Scenario;
27 
32 final class EquiDistAgentSnapshotInfoBuilder extends AbstractAgentSnapshotInfoBuilder {
33 
34  EquiDistAgentSnapshotInfoBuilder( Scenario sc, SnapshotLinkWidthCalculator linkWidthCalculator ){
35  super(sc, linkWidthCalculator);
36  }
37 
38 
39  @Override
40  double calculateVehicleSpacing(double linkLength, double overallStorageCapacity,
41  Collection<? extends VisVehicle> vehs) {
42  double sum = 0. ;
43  for ( VisVehicle veh : vehs ) {
44  sum += veh.getSizeInEquivalents() ;
45  }
46  return linkLength / sum ;
47  }
48 
49  @Override
50  double calculateOdometerDistanceFromFromNode(
51  double time, double linkLength, double freespeed, double spacing, double prevVehicleDistance, double remainingTravelTime
52  ) {
53  return Double.isNaN(prevVehicleDistance) ? linkLength - (spacing / 2.0) : prevVehicleDistance - spacing;
54  }
55 }