use of org.opentripplanner.routing.vertextype.BikeRentalStationVertex in project OpenTripPlanner by opentripplanner.
the class RentABikeAbstractEdge method traverseRent.
protected State traverseRent(State s0) {
RoutingRequest options = s0.getOptions();
/*
* If we already have a bike (rented or own) we won't go any faster by having a second one.
*/
if (!s0.getNonTransitMode().equals(TraverseMode.WALK))
return null;
/*
* To rent a bike, we need to have BICYCLE in allowed modes.
*/
if (!options.modes.contains(TraverseMode.BICYCLE))
return null;
BikeRentalStationVertex dropoff = (BikeRentalStationVertex) tov;
if (options.useBikeRentalAvailabilityInformation && dropoff.getBikesAvailable() == 0) {
return null;
}
StateEditor s1 = s0.edit(this);
s1.incrementWeight(options.arriveBy ? options.bikeRentalDropoffCost : options.bikeRentalPickupCost);
s1.incrementTimeInSeconds(options.arriveBy ? options.bikeRentalDropoffTime : options.bikeRentalPickupTime);
s1.setBikeRenting(true);
s1.setBikeRentalNetwork(networks);
s1.setBackMode(s0.getNonTransitMode());
State s1b = s1.makeState();
return s1b;
}
Aggregations