Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flex transit as a sandbox feature #3121

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create template for ContinuousPickupDropOffTrip
  • Loading branch information
Hannes Junnila committed Oct 6, 2020
commit 68afe5e171b201825b322b4869ffd125d38342d9
Original file line number Diff line number Diff line change
@@ -13,8 +13,6 @@
import java.util.ArrayList;
import java.util.List;

import static org.opentripplanner.model.StopPattern.PICKDROP_NONE;

public class FlexTripsMapper {

private static final Logger LOG = LoggerFactory.getLogger(FlexTripsMapper.class);
@@ -37,7 +35,7 @@ static public void createFlexTrips(OtpTransitServiceBuilder builder) {
builder.getFlexTripsById().add(new UnscheduledTrip(trip, stopTimes));
} else if (ScheduledDeviatedTrip.isScheduledFlexTrip(stopTimes)) {
builder.getFlexTripsById().add(new ScheduledDeviatedTrip(trip, stopTimes));
} else if (hasContinuousStops(stopTimes)) {
} else if (ContinuousPickupDropOffTrip.hasContinuousStops(stopTimes)) {
builder.getFlexTripsById().add(new ContinuousPickupDropOffTrip(trip, stopTimes));
}

@@ -48,10 +46,4 @@ static public void createFlexTrips(OtpTransitServiceBuilder builder) {
LOG.info("Done creating flex trips. Created a total of {} trips.", builder.getFlexTripsById().size());
}

private static boolean hasContinuousStops(List<StopTime> stopTimes) {
return stopTimes
.stream()
.anyMatch(st -> st.getFlexContinuousPickup() != PICKDROP_NONE || st.getFlexContinuousDropOff() != PICKDROP_NONE);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.opentripplanner.ext.flex.trip;

import org.opentripplanner.ext.flex.FlexServiceDate;
import org.opentripplanner.ext.flex.flexpathcalculator.FlexPathCalculator;
import org.opentripplanner.ext.flex.template.FlexAccessTemplate;
import org.opentripplanner.ext.flex.template.FlexEgressTemplate;
import org.opentripplanner.model.StopLocation;
import org.opentripplanner.model.StopTime;
import org.opentripplanner.model.Trip;
import org.opentripplanner.routing.graphfinder.NearbyStop;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;

import static org.opentripplanner.model.StopPattern.PICKDROP_NONE;

public class ContinuousPickupDropOffTrip extends FlexTrip<Double> {

public ContinuousPickupDropOffTrip(Trip trip, List<StopTime> stopTimes) {super(trip);}

public static boolean hasContinuousStops(List<StopTime> stopTimes) {
return stopTimes
.stream()
.anyMatch(st -> st.getFlexContinuousPickup() != PICKDROP_NONE || st.getFlexContinuousDropOff() != PICKDROP_NONE);
}

@Override
public Stream<FlexAccessTemplate<Double>> getFlexAccessTemplates(
NearbyStop access, FlexServiceDate date, FlexPathCalculator<Integer> calculator
) {
return Stream.empty();
}

@Override
public Stream<FlexEgressTemplate<Double>> getFlexEgressTemplates(
NearbyStop egress, FlexServiceDate date, FlexPathCalculator<Integer> calculator
) {
return Stream.empty();
}

@Override
public int earliestDepartureTime(
int departureTime, Double fromStopIndex, Double toStopIndex, int flexTime
) {
return departureTime;
}

@Override
public int latestArrivalTime(
int arrivalTime, Double fromStopIndex, Double toStopIndex, int flexTime
) {
return arrivalTime;
}

@Override
public Collection<StopLocation> getStops() {
return Collections.EMPTY_LIST;
}
}