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;
}
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();
}
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();
}
Aggregations