MATSIM
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.matsim.pt.analysis.RouteOccupancy Class Reference
Inheritance diagram for org.matsim.pt.analysis.RouteOccupancy:
Inheritance graph
[legend]

Public Member Functions

 RouteOccupancy (final TransitRoute transitRoute, final VehicleTracker tracker)
 
void handleEvent (final PersonEntersVehicleEvent event)
 
void handleEvent (final PersonLeavesVehicleEvent event)
 
void reset (final int iteration)
 
int getNumberOfEnteringPassengers (final Id stopFacilityId)
 
int getNumberOfLeavingPassengers (final Id stopFacilityId)
 

Private Member Functions

void collectVehiclesInfo ()
 

Private Attributes

final TransitRoute transitRoute
 
final VehicleTracker tracker
 
Set< IdrouteVehicles = null
 
final Map< Id, Integer > enteringPassengers = new HashMap<Id, Integer>()
 
final Map< Id, Integer > leavingPassengers = new HashMap<Id, Integer>()
 

Static Private Attributes

static final Integer Int1 = Integer.valueOf(1)
 

Detailed Description

Keeps track of the total number of passengers entering and leaving a transit vehicle along a given route, on all Departures.

Author
mrieser

Definition at line 42 of file RouteOccupancy.java.

Constructor & Destructor Documentation

◆ RouteOccupancy()

org.matsim.pt.analysis.RouteOccupancy.RouteOccupancy ( final TransitRoute  transitRoute,
final VehicleTracker  tracker 
)

Member Function Documentation

◆ handleEvent() [1/2]

void org.matsim.pt.analysis.RouteOccupancy.handleEvent ( final PersonEntersVehicleEvent  event)

Implements org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler.

Definition at line 57 of file RouteOccupancy.java.

References org.matsim.pt.analysis.RouteOccupancy.collectVehiclesInfo(), org.matsim.api.core.v01.Id< T >.get(), org.matsim.pt.analysis.VehicleTracker.getFacilityIdForVehicle(), and org.matsim.api.core.v01.events.PersonEntersVehicleEvent.getVehicleId().

57  {
58  if (this.routeVehicles == null) {
60  }
61  if (this.routeVehicles.contains(event.getVehicleId())) {
62  Id facilityId = this.tracker.getFacilityIdForVehicle(event.getVehicleId());
63  Integer count = this.enteringPassengers.get(facilityId);
64  if (count == null) {
65  this.enteringPassengers.put(facilityId, Int1);
66  } else {
67  this.enteringPassengers.put(facilityId, Integer.valueOf(1 + count.intValue()));
68  }
69  }
70  }
final Map< Id, Integer > enteringPassengers
Id getFacilityIdForVehicle(final Id vehicleId)
Here is the call graph for this function:

◆ handleEvent() [2/2]

void org.matsim.pt.analysis.RouteOccupancy.handleEvent ( final PersonLeavesVehicleEvent  event)

Implements org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler.

Definition at line 72 of file RouteOccupancy.java.

References org.matsim.pt.analysis.RouteOccupancy.collectVehiclesInfo(), org.matsim.api.core.v01.Id< T >.get(), org.matsim.pt.analysis.VehicleTracker.getFacilityIdForVehicle(), and org.matsim.api.core.v01.events.PersonLeavesVehicleEvent.getVehicleId().

72  {
73  if (this.routeVehicles == null) {
75  }
76  if (this.routeVehicles.contains(event.getVehicleId())) {
77  Id facilityId = this.tracker.getFacilityIdForVehicle(event.getVehicleId());
78  Integer count = this.leavingPassengers.get(facilityId);
79  if (count == null) {
80  this.leavingPassengers.put(facilityId, Int1);
81  } else {
82  this.leavingPassengers.put(facilityId, Integer.valueOf(1 + count.intValue()));
83  }
84  }
85  }
final Map< Id, Integer > leavingPassengers
Id getFacilityIdForVehicle(final Id vehicleId)
Here is the call graph for this function:

◆ reset()

void org.matsim.pt.analysis.RouteOccupancy.reset ( final int  iteration)

Gives the event handler the possibility to clean up its internal state. Within a Controler-Simulation, this is called before the mobsim starts.

Parameters
iterationthe up-coming iteration from which up-coming events will be from.

Implements org.matsim.core.events.handler.EventHandler.

Definition at line 87 of file RouteOccupancy.java.

87  {
88  this.routeVehicles = null;
89  this.enteringPassengers.clear();
90  this.leavingPassengers.clear();
91  }
final Map< Id, Integer > enteringPassengers
final Map< Id, Integer > leavingPassengers

◆ getNumberOfEnteringPassengers()

int org.matsim.pt.analysis.RouteOccupancy.getNumberOfEnteringPassengers ( final Id  stopFacilityId)

Definition at line 93 of file RouteOccupancy.java.

93  {
94  Integer count = this.enteringPassengers.get(stopFacilityId);
95  if (count == null) {
96  return 0;
97  }
98  return count.intValue();
99  }
final Map< Id, Integer > enteringPassengers

◆ getNumberOfLeavingPassengers()

int org.matsim.pt.analysis.RouteOccupancy.getNumberOfLeavingPassengers ( final Id  stopFacilityId)

Definition at line 101 of file RouteOccupancy.java.

101  {
102  Integer count = this.leavingPassengers.get(stopFacilityId);
103  if (count == null) {
104  return 0;
105  }
106  return count.intValue();
107  }
final Map< Id, Integer > leavingPassengers

◆ collectVehiclesInfo()

void org.matsim.pt.analysis.RouteOccupancy.collectVehiclesInfo ( )
private

Lazy initialization, as the vehicle info may not be available from the beginning.

Definition at line 112 of file RouteOccupancy.java.

References org.matsim.pt.transitSchedule.api.TransitRoute.getDepartures().

Referenced by org.matsim.pt.analysis.RouteOccupancy.handleEvent().

112  {
113  Set<Id> set = new HashSet<Id>(this.transitRoute.getDepartures().size()*2);
114 
115  for (Departure departure : this.transitRoute.getDepartures().values()) {
116  if (departure.getVehicleId() != null) {
117  set.add(departure.getVehicleId());
118  }
119  }
120 
121  /* try to make it thread-safe by assigning class-member at the end.
122  * if two threads enter this method, nothing bad should happen,
123  * as both threads should generated the same initialization.
124  */
125  this.routeVehicles = set;
126  }
Map< Id< Departure >, Departure > getDepartures()
Here is the call graph for this function:

Member Data Documentation

◆ Int1

final Integer org.matsim.pt.analysis.RouteOccupancy.Int1 = Integer.valueOf(1)
staticprivate

Definition at line 44 of file RouteOccupancy.java.

◆ transitRoute

final TransitRoute org.matsim.pt.analysis.RouteOccupancy.transitRoute
private

◆ tracker

final VehicleTracker org.matsim.pt.analysis.RouteOccupancy.tracker
private

◆ routeVehicles

Set<Id> org.matsim.pt.analysis.RouteOccupancy.routeVehicles = null
private

Definition at line 48 of file RouteOccupancy.java.

◆ enteringPassengers

final Map<Id, Integer> org.matsim.pt.analysis.RouteOccupancy.enteringPassengers = new HashMap<Id, Integer>()
private

Definition at line 49 of file RouteOccupancy.java.

◆ leavingPassengers

final Map<Id, Integer> org.matsim.pt.analysis.RouteOccupancy.leavingPassengers = new HashMap<Id, Integer>()
private

Definition at line 50 of file RouteOccupancy.java.


The documentation for this class was generated from the following file: