@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(ActivityEndEvent event) { try { if (isTransitScenario) { if (transitDriverIds.contains(event.getPersonId())) return; } TravellerChain chain = chains.get(event.getPersonId()); locations.put(event.getPersonId(), network.getLinks().get(event.getLinkId()).getCoord()); if (chain == null) { chain = new TravellerChain(); chains.put(event.getPersonId(), chain); Activity act = chain.addActivity(); act.setCoord(network.getLinks().get(event.getLinkId()).getCoord()); act.setEndTime(event.getTime()); act.setFacility(event.getFacilityId()); act.setStartTime(0.0); act.setType(event.getActType()); } else if (!event.getActType().equals(PtConstants.TRANSIT_ACTIVITY_TYPE)) { Activity act = chain.getActs().getLast(); act.setEndTime(event.getTime()); } } catch (Exception e) { System.err.println(e.getStackTrace()); System.err.println(event.toString()); } }