Skip to content

Commit

Permalink
Create template for ContinuousPickupDropOffTrip
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Junnila committed Oct 6, 2020
1 parent f28497b commit 68afe5e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
10 changes: 1 addition & 9 deletions src/ext/java/org/opentripplanner/ext/flex/FlexTripsMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}

Expand All @@ -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;
}
}

0 comments on commit 68afe5e

Please sign in to comment.