Java Code Examples for org.matsim.api.core.v01.Id#createVehicleId()

The following examples show how to use org.matsim.api.core.v01.Id#createVehicleId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VehicleAnalysisListener.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void handleEvent(PersonDepartureEvent event) {
    if (AmodeusIdentifiers.isValid(event.getPersonId())) {
        String mode = AmodeusIdentifiers.getMode(event.getPersonId());
        Id<Vehicle> vehicleId = Id.createVehicleId(event.getPersonId());

        VehicleMovementItem movement = new VehicleMovementItem();
        movements.add(movement);

        movement.mode = mode;
        movement.vehicleId = vehicleId;

        movement.originLink = linkFinder.getLink(event.getLinkId());
        movement.departureTime = event.getTime();

        currentMovements.put(vehicleId, movement);
    }
}
 
Example 2
Source File: VehicleAnalysisListener.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void handleEvent(PersonArrivalEvent event) {
    if (AmodeusIdentifiers.isValid(event.getPersonId())) {
        Id<Vehicle> vehicleId = Id.createVehicleId(event.getPersonId());

        VehicleMovementItem movement = currentMovements.remove(vehicleId);

        if (movement == null) {
            throw new IllegalStateException("Found arrival without departure");
        }

        movement.destinationLink = linkFinder.getLink(event.getLinkId());
        movement.arrivalTime = event.getTime();

        movement.numberOfPassengers = passengers.getNumberOfPassengers(vehicleId);
    }
}
 
Example 3
Source File: VehicleAnalysisListener.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void handleEvent(ActivityStartEvent event) {
    if (AmodeusIdentifiers.isValid(event.getPersonId())) {
        String mode = AmodeusIdentifiers.getMode(event.getPersonId());
        Id<Vehicle> vehicleId = Id.createVehicleId(event.getPersonId());

        VehicleActivityItem activity = new VehicleActivityItem();
        activities.add(activity);

        activity.mode = mode;
        activity.vehicleId = vehicleId;

        activity.link = linkFinder.getLink(event.getLinkId());
        activity.type = event.getActType();

        activity.startTime = event.getTime();

        currentActivities.put(vehicleId, activity);
    }
}
 
Example 4
Source File: VehicleAnalysisListener.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void handleEvent(ActivityEndEvent event) {
    if (AmodeusIdentifiers.isValid(event.getPersonId())) {
        String mode = AmodeusIdentifiers.getMode(event.getPersonId());
        Id<Vehicle> vehicleId = Id.createVehicleId(event.getPersonId());

        VehicleActivityItem activity = currentActivities.remove(vehicleId);
        boolean isStarted = activity != null;

        if (!isStarted) {
            activity = new VehicleActivityItem();
            activities.add(activity);
        }

        activity.mode = mode;
        activity.vehicleId = vehicleId;

        activity.link = linkFinder.getLink(event.getLinkId());
        activity.type = event.getActType();

        activity.endTime = event.getTime();
    }
}