@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()); ; } }
@Override public void handleEvent(PersonDepartureEvent event) { try { if (transitDriverIds.contains(event.getPersonId())) return; TravellerChain chain = chains.get(event.getPersonId()); Journey journey; Trip trip; switch (event.getLegMode()) { case TransportMode.walk: // fall through to the next case TransportMode.transit_walk: if (!chain.traveling) { chain.traveling = true; journey = chain.addJourney(); journey.setOrig(network.getLinks().get(event.getLinkId()).getCoord()); journey.setFromAct(chain.getActs().getLast()); journey.setStartTime(event.getTime()); Walk walk = journey.addWalk(); walk.setAccessWalk(true); walk.setStartTime(event.getTime()); walk.setOrig(journey.getOrig()); } else { journey = chain.getJourneys().getLast(); Walk walk = journey.addWalk(); walk.setStartTime(event.getTime()); walk.setOrig(network.getLinks().get(event.getLinkId()).getCoord()); journey.getPossibleTransfer().getWalks().add(walk); } break; case TransportMode.car: chain.inCar = true; journey = chain.addJourney(); journey.setCarJourney(true); journey.setOrig(network.getLinks().get(event.getLinkId()).getCoord()); journey.setFromAct(chain.getActs().getLast()); journey.setStartTime(event.getTime()); trip = journey.addTrip(); trip.setMode("car"); trip.setStartTime(event.getTime()); break; case TransportMode.pt: if (isTransitScenario) { // person waits till they enter the vehicle journey = chain.getJourneys().getLast(); Wait wait = journey.addWait(); if (journey.getWaits().size() == 1) wait.setAccessWait(true); wait.setStartTime(event.getTime()); wait.setCoord(network.getLinks().get(event.getLinkId()).getCoord()); if (!wait.isAccessWait()) { journey.getPossibleTransfer().getWaits().add(wait); } } else { journey = chain.addJourney(); journey.setTeleportJourney(true); journey.setOrig(network.getLinks().get(event.getLinkId()).getCoord()); journey.setFromAct(chain.getActs().getLast()); journey.setStartTime(event.getTime()); journey.setMainmode(event.getLegMode()); trip = journey.addTrip(); trip.setMode(event.getLegMode()); trip.setStartTime(event.getTime()); } break; default: journey = chain.addJourney(); journey.setTeleportJourney(true); journey.setOrig(network.getLinks().get(event.getLinkId()).getCoord()); journey.setFromAct(chain.getActs().getLast()); journey.setStartTime(event.getTime()); journey.setMainmode(event.getLegMode()); trip = journey.addTrip(); trip.setMode(event.getLegMode()); trip.setStartTime(event.getTime()); break; } } catch (Exception e) { System.err.println(e.getStackTrace()); System.err.println(event.toString()); } }