public static void setArrivalTime(Leg leg, double arrivalTime) { if (leg instanceof Leg) { final double arrTime = arrivalTime; Leg r = ((Leg) leg); r.setTravelTime( arrTime - r.getDepartureTime() ); } else if (leg instanceof LCLeg) { ((LCLeg) leg).setArrivalTime(arrivalTime); } else throw new RuntimeException("Unexpected type of leg was found: " + leg.getClass().toString() + ". Aborting!"); }
private void startLeg(final Attributes atts) { String mode = atts.getValue("mode").toLowerCase(Locale.ROOT); if (mode.equals("undef")) { mode = "undefined"; } this.currleg = PopulationUtils.createAndAddLeg( this.currplan, mode.intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue("dep_time"))); this.currleg.setTravelTime(Time.parseTime(atts.getValue("trav_time"))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue("arr_time")) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
private void startLeg(final Attributes atts) { this.currleg = PopulationUtils.createAndAddLeg( this.currplan, atts.getValue("mode").toLowerCase(Locale.ROOT).intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue("dep_time"))); this.currleg.setTravelTime(Time.parseTime(atts.getValue("trav_time"))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue("arr_time")) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
private void startLeg(final Attributes atts) { this.currleg = PopulationUtils.createAndAddLeg( this.currplan, atts.getValue("mode").toLowerCase(Locale.ROOT).intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue("dep_time"))); this.currleg.setTravelTime(Time.parseTime(atts.getValue("trav_time"))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue("arr_time")) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
private Leg createTransitWalkLeg(Coord fromCoord, Coord toCoord) { Leg leg = PopulationUtils.createLeg(TransportMode.transit_walk); double walkTime = getWalkTime(null, fromCoord, toCoord); leg.setTravelTime(walkTime); return leg; }
private void startLeg(final Attributes atts) { if (this.routeDescription != null) { finishLastRoute(); } String mode = atts.getValue(ATTR_LEG_MODE); if (VALUE_UNDEF.equals(mode)) { mode = "undefined"; } this.currleg = PopulationUtils.createAndAddLeg( this.currplan, mode.intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue(ATTR_LEG_DEPTIME))); this.currleg.setTravelTime(Time.parseTime(atts.getValue(ATTR_LEG_TRAVTIME))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue(ATTR_LEG_ARRTIME)) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
private void startLeg(final Attributes atts) { if (this.routeDescription != null) { finishLastRoute(); } String mode = atts.getValue(ATTR_LEG_MODE); if (VALUE_UNDEF.equals(mode)) { mode = "undefined"; } this.currleg = PopulationUtils.createAndAddLeg( this.currplan, mode.intern() ); this.currleg.setDepartureTime(Time.parseTime(atts.getValue(ATTR_LEG_DEPTIME))); this.currleg.setTravelTime(Time.parseTime(atts.getValue(ATTR_LEG_TRAVTIME))); // LegImpl r = this.currleg; // r.setTravelTime( Time.parseTime(atts.getValue(ATTR_LEG_ARRTIME)) - r.getDepartureTime() ); // arrival time is in dtd, but no longer evaluated in code (according to not being in API). kai, jun'16 }
/** * Removes the specified leg <b>and</b> the following act, too! If the following act is not the last one, * the following leg will be emptied to keep consistency (i.e. for the route) * * @param index */ public final void removeLeg(final int index) { if ((index % 2 == 0) || (index < 1) || (index >= getPlanElements().size() - 1)) { log.warn(this + "[index=" + index + " is wrong. nothing removed]"); } else { if (index != getPlanElements().size() - 2) { // not the last leg Leg next_leg = (Leg) getPlanElements().get(index + 2); next_leg.setDepartureTime(Time.UNDEFINED_TIME); next_leg.setTravelTime(Time.UNDEFINED_TIME); next_leg.setTravelTime( Time.UNDEFINED_TIME - next_leg.getDepartureTime() ); next_leg.setRoute(null); } getPlanElements().remove(index + 1); // following act getPlanElements().remove(index); // leg } }
protected final List<Leg> createDirectWalkLegList(Person person, Coord fromCoord, Coord toCoord) { List<Leg> legs = new ArrayList<>(); Leg leg = PopulationUtils.createLeg(TransportMode.transit_walk); double walkTime = getWalkTime(person, fromCoord, toCoord); leg.setTravelTime(walkTime); Route walkRoute = RouteUtils.createGenericRouteImpl(null, null); walkRoute.setTravelTime(walkTime); leg.setRoute(walkRoute); legs.add(leg); return legs; }
protected double computeTravelTime(Person person, Activity fromAct, Activity toAct) { Leg leg = PopulationUtils.createLeg(TransportMode.car); leg.setDepartureTime(0.0); leg.setTravelTime(0.0); leg.setTravelTime( 0.0 - leg.getDepartureTime() ); PlanRouterAdapter.handleLeg(router, person, leg, fromAct, toAct, fromAct.getEndTime()); return leg.getTravelTime(); }
/** * Removes the specified leg <b>and</b> the following act, too! If the following act is not the last one, * the following leg will be emptied to keep consistency (i.e. for the route) * @param index */ public static void removeLeg( Plan plan, int index) { if ((index % 2 == 0) || (index < 1) || (index >= plan.getPlanElements().size()-1)) { log.warn(plan + "[index=" + index +" is wrong. nothing removed]"); } else { if (index != plan.getPlanElements().size()-2) { // not the last leg Leg next_leg = (Leg)plan.getPlanElements().get(index+2); next_leg.setDepartureTime(Time.UNDEFINED_TIME); next_leg.setTravelTime(Time.UNDEFINED_TIME); next_leg.setRoute(null); } plan.getPlanElements().remove(index+1); // following act plan.getPlanElements().remove(index); // leg } } public static void removeActivity( Plan plan, int index ) {
public Leg getLeg() { Leg leg = PopulationUtils.createLeg(mode); leg.setDepartureTime(departureTime); leg.setTravelTime(travelTime); leg.setRoute(route == null ? null : route.getRoute(mode)); return leg; } }
@Override public List<? extends PlanElement> calcRoute( final Facility fromFacility, final Facility toFacility, final double departureTime, final Person person) { Leg newLeg = this.populationFactory.createLeg( this.mode ); newLeg.setDepartureTime( departureTime ); double travTime = routeLeg( person, newLeg, new FacilityWrapperActivity( fromFacility ), new FacilityWrapperActivity( toFacility ), departureTime); // otherwise, information may be lost newLeg.setTravelTime( travTime ); return Arrays.asList(newLeg); }
@Override public List<? extends PlanElement> calcRoute( final Facility fromFacility, final Facility toFacility, final double departureTime, final Person person) { Leg newLeg = this.populationFactory.createLeg( this.mode ); newLeg.setDepartureTime( departureTime ); double travTime = routeLeg( person, newLeg, new FacilityWrapperActivity( fromFacility ), new FacilityWrapperActivity( toFacility ), departureTime); // otherwise, information may be lost newLeg.setTravelTime( travTime ); return Arrays.asList( newLeg ); }
private static void fillInLegTravelTimes( final double departureTime, final List<? extends PlanElement> trip ) { double time = departureTime; for ( PlanElement pe : trip ) { if ( !(pe instanceof Leg) ) continue; final Leg leg = (Leg) pe; if ( leg.getDepartureTime() == Time.UNDEFINED_TIME ) { leg.setDepartureTime( time ); } if ( leg.getTravelTime() == Time.UNDEFINED_TIME ) { leg.setTravelTime( leg.getRoute().getTravelTime() ); } time += leg.getTravelTime(); } }
private Leg createTransitLeg(RouteSegment routeSegment) { Leg leg = PopulationUtils.createLeg(TransportMode.pt); TransitStopFacility accessStop = routeSegment.getFromStop(); TransitStopFacility egressStop = routeSegment.getToStop(); ExperimentalTransitRoute ptRoute = new ExperimentalTransitRoute(accessStop, egressStop, routeSegment.getLineTaken(), routeSegment.getRouteTaken()); ptRoute.setTravelTime(routeSegment.travelTime); leg.setRoute(ptRoute); leg.setTravelTime(routeSegment.getTravelTime()); return leg; }
/* package */ double routeLeg(Person person, Leg leg, Activity fromAct, Activity toAct, double depTime) { // make simple assumption about distance and walking speed final Coord fromActCoord = fromAct.getCoord(); Gbl.assertNotNull( fromActCoord ); final Coord toActCoord = toAct.getCoord(); Gbl.assertNotNull( toActCoord ); double dist = CoordUtils.calcEuclideanDistance( fromActCoord, toActCoord ); // create an empty route, but with realistic travel time Route route = this.populationFactory.getRouteFactories().createRoute(Route.class, fromAct.getLinkId(), toAct.getLinkId()); double estimatedNetworkDistance = dist * this.beelineDistanceFactor; int travTime = (int) (estimatedNetworkDistance / this.networkTravelSpeed); route.setTravelTime(travTime); route.setDistance(estimatedNetworkDistance); leg.setRoute(route); leg.setDepartureTime(depTime); leg.setTravelTime(travTime); Leg r = (leg); r.setTravelTime( depTime + travTime - r.getDepartureTime() ); // yy something needs to be done once there are alternative implementations of the interface. kai, apr'10 return travTime; }
public static void copyFromTo(Leg in, Leg out) { out.setMode( in.getMode() ); out.setDepartureTime(in.getDepartureTime()); out.setTravelTime(in.getTravelTime()); if (in.getRoute() != null) { out.setRoute(in.getRoute().clone()); } AttributesUtils.copyAttributesFromTo( in , out ); }
@Override public List<? extends PlanElement> calcRoute(Facility fromFacility, Facility toFacility, double departureTime, Person person) { Leg newLeg = scenario.getPopulation().getFactory().createLeg( TransportMode.pt ); Id<Link> startLinkId = fromFacility.getLinkId(); Id<Link> endLinkId = toFacility.getLinkId(); newLeg.setDepartureTime( departureTime ); double travelTime = this.ptMatrix.getTotalTravelTime_seconds(fromFacility.getCoord(), toFacility.getCoord()); newLeg.setTravelTime( travelTime ); final Route route = genericRouteFactory.createRoute(startLinkId, endLinkId); double distance = this.ptMatrix.getTotalTravelDistance_meter(fromFacility.getCoord(), toFacility.getCoord()) ; route.setDistance(distance) ; newLeg.setRoute(route); return Arrays.asList( newLeg ); }
private Leg createTransferTransitWalkLeg(RouteSegment routeSegement) { Leg leg = this.createTransitWalkLeg(routeSegement.getFromStop().getCoord(), routeSegement.getToStop().getCoord()); Route walkRoute = RouteUtils.createGenericRouteImpl(routeSegement.getFromStop().getLinkId(), routeSegement.getToStop().getLinkId()); // walkRoute.setTravelTime(leg.getTravelTime() ); // transit walk leg should include additional transfer time; Amit, Aug'17 leg.setTravelTime( getTransferTime(null, routeSegement.getFromStop().getCoord(), routeSegement.getToStop().getCoord()) ); walkRoute.setTravelTime(getTransferTime(null, routeSegement.getFromStop().getCoord(), routeSegement.getToStop().getCoord()) ); walkRoute.setDistance(trConfig.getBeelineDistanceFactor() * NetworkUtils.getEuclideanDistance(routeSegement.fromStop.getCoord(), routeSegement.toStop.getCoord())); leg.setRoute(walkRoute); return leg; }