All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.routing.edgetype.RentABikeOnEdge Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
package org.opentripplanner.routing.edgetype;

import java.util.Set;

import org.opentripplanner.routing.api.request.RoutingRequest;
import org.opentripplanner.routing.core.State;
import org.opentripplanner.routing.vertextype.BikeRentalStationVertex;

/**
 * Renting a bike edge.
 * 
 * Cost is the time to pickup a bike plus "inconvenience of renting".
 * 
 * @author laurent
 * 
 */
public class RentABikeOnEdge extends RentABikeAbstractEdge {

    private static final long serialVersionUID = 1L;

    public RentABikeOnEdge(BikeRentalStationVertex from, BikeRentalStationVertex to, Set networks) {
        super(from, to, networks);
    }

    @Override
    public State traverse(State s0) {
        RoutingRequest options = s0.getOptions();
        if (options.arriveBy) {
            return super.traverseDropoff(s0);
        } else {
            return super.traverseRent(s0);
        }
    }

    public boolean equals(Object o) {
        if (o instanceof RentABikeOnEdge) {
            RentABikeOnEdge other = (RentABikeOnEdge) o;
            return other.getFromVertex().equals(fromv) && other.getToVertex().equals(tov);
        }
        return false;
    }

    public String toString() {
        return "RentABikeOnEdge(" + fromv + " -> " + tov + ")";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy