@Override public boolean getEnterTransitRoute( final TransitLine line, final TransitRoute transitRoute, final List<TransitRouteStop> stopsToCome, TransitVehicle transitVehicle) { ExperimentalTransitRoute route = (ExperimentalTransitRoute) getCurrentLeg().getRoute(); if (line.getId().equals(route.getLineId())) { return containsId(stopsToCome, route.getEgressStopId()); } else { return false; } }
@Override public void run(Person person) { try { Plan plan = person.getSelectedPlan(); this.transitLegsRemover.run(plan); // for (Plan plan : person.getPlans()) { Activity prevAct = null; for (PlanElement pe : plan.getPlanElements()) { if (pe instanceof Activity) { Activity act = (Activity) pe; if (prevAct != null) { List<Leg> legs = router.calcRoute( new FakeFacility(prevAct.getCoord()), new FakeFacility(act.getCoord()), act.getStartTime(), person); out.write( person.getId() + " " + prevAct.getCoord() + " -> " + act.getCoord() + " @ " + Time.writeTime(act.getStartTime()) + " :\n"); if (legs != null) { for (Leg l : legs) { out.write(" " + l.getMode()); if (l.getRoute() instanceof ExperimentalTransitRoute) { ExperimentalTransitRoute r = (ExperimentalTransitRoute) l.getRoute(); out.write(" " + r.getRouteDescription()); } out.write("\n"); } } } prevAct = act; } } // } } catch (IOException e) { throw new RuntimeException(e); } }
@Override public Id<TransitStopFacility> getDesiredAccessStopId() { Leg leg = getCurrentLeg(); if (!(leg.getRoute() instanceof ExperimentalTransitRoute)) { log.error( "pt-leg has no TransitRoute. Removing agent from simulation. Agent " + getId().toString()); log.info( "route: " + leg.getRoute().getClass().getCanonicalName() + " " + leg.getRoute().getRouteDescription()); return null; } else { ExperimentalTransitRoute route = (ExperimentalTransitRoute) leg.getRoute(); Id<TransitStopFacility> accessStopId = route.getAccessStopId(); return accessStopId; } }
/** Why? dg 09-2013 */ private void createExperimentalTransitRoutes(Scenario sc) { for (Person person : sc.getPopulation().getPersons().values()) { for (Plan plan : person.getPlans()) { for (PlanElement pe : plan.getPlanElements()) { if (pe instanceof Leg) { Leg leg = (Leg) pe; if (leg.getMode().equals("pt")) { GenericRoute route = (GenericRoute) leg.getRoute(); ExperimentalTransitRoute tr = (ExperimentalTransitRoute) new ExperimentalTransitRouteFactory().createRoute(null, null); leg.setRoute(tr); tr.setRouteDescription( route.getStartLinkId(), route.getRouteDescription(), route.getEndLinkId()); tr.setDistance(route.getDistance()); } } } } } }
private static boolean isRelatedWithLine(Person person, TransitLine line) { ExperimentalTransitRouteFactory factory = new ExperimentalTransitRouteFactory(); for (Plan plan : person.getPlans()) for (PlanElement planElement : plan.getPlanElements()) if (planElement instanceof Leg && ((Leg) planElement).getRoute() instanceof Route) { Route origRoute = ((Leg) planElement).getRoute(); ExperimentalTransitRoute route = (ExperimentalTransitRoute) factory.createRoute(origRoute.getStartLinkId(), origRoute.getEndLinkId()); route.setStartLinkId(origRoute.getStartLinkId()); route.setEndLinkId(origRoute.getEndLinkId()); route.setRouteDescription(origRoute.getRouteDescription()); for (TransitRoute transitRoute : line.getRoutes().values()) for (TransitRouteStop stop : transitRoute.getStops()) if (stop.getStopFacility().getId().equals(route.getAccessStopId()) || stop.getStopFacility().getId().equals(route.getEgressStopId())) return true; } return false; }
@Override public Id<TransitStopFacility> getDesiredDestinationStopId() { ExperimentalTransitRoute route = (ExperimentalTransitRoute) getCurrentLeg().getRoute(); return route.getEgressStopId(); }
@Override public boolean getExitAtStop(final TransitStopFacility stop) { ExperimentalTransitRoute route = (ExperimentalTransitRoute) getCurrentLeg().getRoute(); return route.getEgressStopId().equals(stop.getId()); }