@Override public void handleEvent(PersonArrivalEvent event) { try { if (isTransitScenario) { if (transitDriverIds.contains(event.getPersonId())) return; } TravellerChain chain = chains.get(event.getPersonId()); switch (event.getLegMode()) { case "walk": case "transit_walk": { Journey journey = chain.getJourneys().getLast(); Walk walk = journey.getWalks().getLast(); walk.setDest(network.getLinks().get(event.getLinkId()).getCoord()); walk.setEndTime(event.getTime()); walk.setDistance(walk.getDuration() * walkSpeed); break; } case TransportMode.car: { Journey journey = chain.getJourneys().getLast(); journey.setDest(network.getLinks().get(event.getLinkId()).getCoord()); journey.setEndTime(event.getTime()); Trip trip = journey.getTrips().getLast(); trip.setDistance(journey.getDistance()); trip.setEndTime(event.getTime()); chain.inCar = false; break; } case "pt": if (isTransitScenario) { Journey journey = chain.getJourneys().getLast(); Trip trip = journey.getTrips().getLast(); trip.setDest(network.getLinks().get(event.getLinkId()).getCoord()); trip.setEndTime(event.getTime()); journey.setPossibleTransfer(new Transfer()); journey.getPossibleTransfer().setStartTime(event.getTime()); journey.getPossibleTransfer().setFromTrip(trip); } else { Journey journey = chain.getJourneys().getLast(); journey.setEndTime(event.getTime()); journey.setDest(network.getLinks().get(event.getLinkId()).getCoord()); journey.setEndTime(event.getTime()); } break; default: Journey journey = chain.getJourneys().getLast(); journey.setEndTime(event.getTime()); journey.setDest(network.getLinks().get(event.getLinkId()).getCoord()); journey.setEndTime(event.getTime()); break; } } catch (Exception e) { System.err.println(e.getStackTrace()); System.err.println(event.toString()); } }
@Override public void handleEvent(ActivityStartEvent event) { try { if (isTransitScenario) { if (transitDriverIds.contains(event.getPersonId())) return; } TravellerChain chain = chains.get(event.getPersonId()); boolean beforeInPT = chain.isInPT(); if (event.getActType().equals(PtConstants.TRANSIT_ACTIVITY_TYPE)) { chain.setInPT(true); } else { chain.setInPT(false); chain.traveling = false; Activity act = chain.addActivity(); act.setCoord(network.getLinks().get(event.getLinkId()).getCoord()); act.setFacility(event.getFacilityId()); act.setStartTime(event.getTime()); act.setType(event.getActType()); // end the preceding journey Journey journey = chain.getJourneys().getLast(); journey.setDest(act.getCoord()); journey.setEndTime(event.getTime()); journey.setToAct(act); if (beforeInPT) journey.getWalks().getLast().setEgressWalk(true); } } catch (Exception e) { System.err.println(e.getStackTrace()); System.err.println(event.toString()); ; } }