Search in sources :

Example 6 with BikeRentalStationVertex

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;
}
Also used : BikeRentalStationVertex(org.opentripplanner.routing.vertextype.BikeRentalStationVertex) StateEditor(org.opentripplanner.routing.core.StateEditor) State(org.opentripplanner.routing.core.State) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest)

Aggregations

BikeRentalStationVertex (org.opentripplanner.routing.vertextype.BikeRentalStationVertex)6 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)4 State (org.opentripplanner.routing.core.State)4 BikeRentalStation (org.opentripplanner.routing.bike_rental.BikeRentalStation)3 StateEditor (org.opentripplanner.routing.core.StateEditor)2 TripDescriptor (com.google.transit.realtime.GtfsRealtime.TripDescriptor)1 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)1 StopTimeEvent (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeEvent)1 StopTimeUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate)1 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 LineString (com.vividsolutions.jts.geom.LineString)1 HashSet (java.util.HashSet)1 CalendarServiceImpl (org.onebusaway.gtfs.impl.calendar.CalendarServiceImpl)1 Agency (org.onebusaway.gtfs.model.Agency)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 Route (org.onebusaway.gtfs.model.Route)1 Stop (org.onebusaway.gtfs.model.Stop)1 StopTime (org.onebusaway.gtfs.model.StopTime)1 Trip (org.onebusaway.gtfs.model.Trip)1