コード例 #1
0
 @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());
   }
 }
コード例 #2
0
 @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());
   }
 }