@Override public Id<Link> getLinkId() { return wrapped.getLinkId(); }
@Override public List<? extends PlanElement> calcRoute( final Facility fromFacility, final Facility toFacility, final double departureTime, final Person person) { Leg l = popFactory.createLeg( modeName ); l.setDepartureTime( departureTime ); Route r = new PassengerRoute( fromFacility.getLinkId() , toFacility.getLinkId() ); l.setRoute( r ); return Collections.singletonList( l ); }
private Route createWalkRoute(final Facility fromFacility, double departureTime, Person person, double travelTime, Facility firstToFacility) { // yyyy I extracted this method to make a bit more transparent that it is used twice. But I don't know why it is done in this way // (take distance from newly computed walk leg, but take travelTime from elsewhere). Possibly, the problem is that the TransitRouter // historically just does not compute the distances. kai, may'17 Route route = RouteUtils.createGenericRouteImpl(fromFacility.getLinkId(), firstToFacility.getLinkId()); final List<? extends PlanElement> walkRoute = walkRouter.calcRoute(fromFacility, firstToFacility, departureTime, person); route.setDistance(((Leg) walkRoute.get(0)).getRoute().getDistance()); route.setTravelTime(travelTime); return route; }
@Override public void run(final GroupPlans plans) { final List<Facility> groupChoiceSet = choiceSet.getGroupChoiceSet( plans ); for ( Plan plan : plans.getAllIndividualPlans() ) { for ( Activity act : TripStructureUtils.getActivities( plan , choiceSet.filter ) ) { assert act.getType().equals( choiceSet.type ); final Facility choice = groupChoiceSet.get( random.nextInt( groupChoiceSet.size() ) ); ((Activity) act).setCoord( choice.getCoord() ); ((Activity) act).setLinkId( choice.getLinkId() ); if ( choice instanceof Identifiable ) { ( (Activity) act ).setFacilityId( ((Identifiable)choice).getId() ); } else { throw new RuntimeException( Facility.FACILITY_NO_LONGER_IDENTIFIABLE ) ; } } } }
Gbl.assertNotNull(toFacility); if (!toFacility.getLinkId().equals(fromFacility.getLinkId())) { .get(Id.create(fromFacility.getLinkId(), Node.class)); Node toInvNode = this.invertedNetwork.getNodes().get(Id.create(toFacility.getLinkId(), Node.class)); + fromFacility.getLinkId() + " to link " + toFacility.getLinkId() + "."); NetworkRoute route = this.populationFactory.getRouteFactories().createRoute(NetworkRoute.class, fromFacility.getLinkId(), toFacility.getLinkId()); route.setLinkIds(fromFacility.getLinkId(), NetworkUtils.getLinkIds(path.links), toFacility.getLinkId()); route.setTravelTime(path.travelTime); route.setTravelCost(path.travelCost); NetworkRoute route = this.populationFactory.getRouteFactories().createRoute(NetworkRoute.class, fromFacility.getLinkId(), toFacility.getLinkId()); route.setTravelTime(0); route.setDistance(0.0);
Route route = RouteUtils.createGenericRouteImpl(fromFacility.getLinkId(), toFacility.getLinkId()); route.setDistance(Double.NaN); route.setTravelTime(Double.NaN); leg.setTravelTime(Double.NaN); leg.setRoute(route); if (fromFacility.getLinkId().equals(toFacility.getLinkId())) { leg.setMode(TransportMode.walk);
@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 ); }
@Test public void testWrapper() { for (Activity activity : activities) { Facility wrapper = new ActivityWrapperFacility( activity ); Assert.assertEquals( "wrapped activity returns incorrect coordinate!", activity.getCoord(), wrapper.getCoord()); Assert.assertEquals( "wrapped activity returns incorrect link id!", activity.getLinkId(), wrapper.getLinkId()); } } }
Gbl.assertNotNull(toFacility); Link fromLink = this.network.getLinks().get(fromFacility.getLinkId()); if ( fromLink==null ) { Gbl.assertNotNull( fromFacility.getCoord() ) ; fromLink = NetworkUtils.getNearestLink( network, fromFacility.getCoord()) ; Link toLink = this.network.getLinks().get(toFacility.getLinkId()); if ( toLink==null ) { Gbl.assertNotNull( toFacility.getCoord() ) ;