Search in sources :

Example 11 with TraverseMode

use of org.opentripplanner.routing.core.TraverseMode in project OpenTripPlanner by opentripplanner.

the class TravelOptionsMaker method makeOptions.

public static List<TravelOption> makeOptions(HashSet<TraverseMode> transitModes, boolean hasBikeSharing, boolean hasBikeRide, boolean hasParkRide) {
    List<TravelOption> travelOptions = new ArrayList<>(16);
    // Adds Transit, and all the transit modes
    if (!transitModes.isEmpty()) {
        travelOptions.add(new TravelOption(String.join(",", TraverseMode.TRANSIT.toString(), TraverseMode.WALK.toString()), TraverseMode.TRANSIT.toString()));
        for (TraverseMode transitMode : transitModes) {
            travelOptions.add(new TravelOption(String.join(",", transitMode.toString(), TraverseMode.WALK.toString()), transitMode.toString()));
        }
    }
    travelOptions.addAll(staticTravelOptions);
    if (hasBikeSharing) {
        travelOptions.add(new TravelOption(String.join(",", TraverseMode.WALK.toString(), "BICYCLE_RENT"), "BICYCLERENT"));
    }
    // If transit modes exists.
    if (!transitModes.isEmpty()) {
        // Adds bicycle transit mode
        travelOptions.add(new TravelOption(String.join(",", TraverseMode.TRANSIT.toString(), TraverseMode.BICYCLE.toString()), String.join("_", TraverseMode.TRANSIT.toString(), TraverseMode.BICYCLE.toString())));
        if (hasBikeSharing) {
            travelOptions.add(new TravelOption(String.join(",", TraverseMode.TRANSIT.toString(), TraverseMode.WALK.toString(), "BICYCLE_RENT"), "TRANSIT_BICYCLERENT"));
        }
        if (hasParkRide) {
            travelOptions.add(new TravelOption(String.join(",", "CAR_PARK", TraverseMode.WALK.toString(), TraverseMode.TRANSIT.toString()), "PARKRIDE"));
        }
        if (hasBikeRide) {
            travelOptions.add(new TravelOption(String.join(",", "BICYCLE_PARK", TraverseMode.WALK.toString(), TraverseMode.TRANSIT.toString()), "BIKERIDE"));
        }
        travelOptions.add(new TravelOption(String.join(",", TraverseMode.CAR.toString(), TraverseMode.WALK.toString(), TraverseMode.TRANSIT.toString()), "KISSRIDE"));
    }
    return travelOptions;
}
Also used : ArrayList(java.util.ArrayList) TraverseMode(org.opentripplanner.routing.core.TraverseMode)

Example 12 with TraverseMode

use of org.opentripplanner.routing.core.TraverseMode in project OpenTripPlanner by opentripplanner.

the class TemporaryConcreteEdge method traverse.

@Override
public State traverse(State s0) {
    double d = getDistance();
    TraverseMode mode = s0.getNonTransitMode();
    int t = (int) (d / s0.getOptions().getSpeed(mode));
    StateEditor s1 = s0.edit(this);
    s1.incrementTimeInSeconds(t);
    s1.incrementWeight(d);
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor) TraverseMode(org.opentripplanner.routing.core.TraverseMode)

Example 13 with TraverseMode

use of org.opentripplanner.routing.core.TraverseMode in project OpenTripPlanner by opentripplanner.

the class ParkAndRideLinkEdge method traverse.

@Override
public State traverse(State s0) {
    // Do not enter park and ride mechanism if it's not activated in the routing request.
    if (!s0.getOptions().parkAndRide) {
        return null;
    }
    Edge backEdge = s0.getBackEdge();
    boolean back = s0.getOptions().arriveBy;
    // shortcut.
    if ((back != exit) && !(backEdge instanceof ParkAndRideEdge))
        return null;
    StateEditor s1 = s0.edit(this);
    TraverseMode mode = s0.getNonTransitMode();
    if (mode == TraverseMode.WALK) {
        // Walking
        double walkTime = linkDistance * WALK_OBSTRUCTION_FACTOR / s0.getOptions().walkSpeed;
        s1.incrementTimeInSeconds((int) Math.round(walkTime));
        s1.incrementWeight(walkTime);
        s1.incrementWalkDistance(linkDistance);
        s1.setBackMode(TraverseMode.WALK);
    } else if (mode == TraverseMode.CAR) {
        // Driving
        double driveTime = linkDistance * DRIVE_OBSTRUCTION_FACTOR / DRIVE_SPEED_MS;
        s1.incrementTimeInSeconds((int) Math.round(driveTime));
        s1.incrementWeight(driveTime);
        s1.setBackMode(TraverseMode.CAR);
    } else {
        // Can't cycle in/out a P+R.
        return null;
    }
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor) TraverseMode(org.opentripplanner.routing.core.TraverseMode) Edge(org.opentripplanner.routing.graph.Edge)

Aggregations

TraverseMode (org.opentripplanner.routing.core.TraverseMode)13 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)5 Edge (org.opentripplanner.routing.graph.Edge)5 LineString (com.vividsolutions.jts.geom.LineString)4 StateEditor (org.opentripplanner.routing.core.StateEditor)4 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)3 ArrayList (java.util.ArrayList)3 State (org.opentripplanner.routing.core.State)3 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)3 Vertex (org.opentripplanner.routing.graph.Vertex)3 HashSet (java.util.HashSet)2 List (java.util.List)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 GenericLocation (org.opentripplanner.common.model.GenericLocation)2 TemporaryStreetLocation (org.opentripplanner.routing.location.TemporaryStreetLocation)2 NonLocalizedString (org.opentripplanner.util.NonLocalizedString)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Iterables (com.google.common.collect.Iterables)1 Envelope (com.vividsolutions.jts.geom.Envelope)1