@Override public void handleEvent(LinkLeaveEvent event) { if (event.getVehicleId().toString().startsWith("tr")) { PTVehicle vehicle = ptVehicles.get(event.getVehicleId()); if (vehicle.in) { vehicle.in = false; vehicle.incDistance(network.getLinks().get(event.getLinkId()).getLength()); } } else { TravellerChain chain = chains.get(event.getDriverId()); if (chain == null) { chain = new TravellerChain(); chains.put(event.getDriverId(), chain); chain.modes.add("car"); chain.distances.add(0.0); } else { if (chain.in) { chain.in = false; if (chain.modes.size() == chain.distances.size() && chain.modes.get(chain.modes.size() - 1).equals("car")) { double linkDistance = network.getLinks().get(event.getLinkId()).getLength(); chain.distances.set( chain.distances.size() - 1, chain.distances.get(chain.distances.size() - 1) + linkDistance); } else if (chain.modes.size() == chain.distances.size()) throw new RuntimeException("Person is leaving a link, but is not in a car mode"); else throw new RuntimeException("Modes list has not the same size of distances list (car)"); } else { chain.modes.add("car"); chain.distances.add(0.0); } } } }
@Override public void handleEvent(LinkLeaveEvent event) { // store information from event to variables // String eventType = event.getEventType(); Id<Link> linkId = event.getLinkId(); // String linkShortened = linkId.toString().substring(0, 10) + "..."; Id<Person> personId = event.getDriverId(); // double time = event.getTime(); // Id vehicleId = event.getVehicleId(); // add information concerning passed links to the object "Trip" Id<Trip> tripId = Id.create(personId + "_" + activityEndCount.get(personId), Trip.class); if (trips.get(tripId).getLinks().isEmpty()) { if (trips.get(tripId).getDepartureLinkId().equals(linkId)) { trips.get(tripId).getLinks().add(linkId); // System.out.println("Added first link to trip " + tripId); } else { // System.err.println("First route link different from departure link!"); throw new RuntimeException("First route link different from departure link!"); } } else { trips.get(tripId).getLinks().add(linkId); // System.out.println("Added another link to trip " + tripId); // System.out.println("List of trip " + tripId + " has now " + // trips.get(tripId).getLinks().size() + " elements"); } }
@Override public void handleEvent(final LinkLeaveEvent event) { if (ignoreLinkEvents) return; handleEvent(eventsPerPerson, event.getDriverId(), event); }
@Override public void handleEvent(LinkLeaveEvent event) { if (event.getDriverId().equals(filterEventsForAgentId)) { System.out.println(event.toString()); } }