Skip to content

Commit

Permalink
Remove flex stops when flex is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Dec 9, 2021
1 parent f76e446 commit 6a40134
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import gnu.trove.list.TIntList;
import gnu.trove.list.array.TIntArrayList;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.opentripplanner.common.geometry.SphericalDistanceLibrary;
import org.opentripplanner.ext.flex.trip.FlexTrip;
import org.opentripplanner.graph_builder.DataImportIssue;
Expand All @@ -12,20 +15,17 @@
import org.opentripplanner.graph_builder.issues.NegativeDwellTime;
import org.opentripplanner.graph_builder.issues.NegativeHopTime;
import org.opentripplanner.graph_builder.issues.RepeatedStops;
import org.opentripplanner.model.StopLocation;
import org.opentripplanner.model.Stop;
import org.opentripplanner.model.StopTime;
import org.opentripplanner.model.Trip;
import org.opentripplanner.model.TripStopTimes;
import org.opentripplanner.util.OTPFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
* This class is responsible for cleaning stop times, removing duplicates, correcting bad data
* and so on. This do only apply to GTFS imports.
* and so on. This only applies to GTFS imports.
*/
public class RepairStopTimesForEachTripOperation {
private static final Logger LOG = LoggerFactory.getLogger(RepairStopTimesForEachTripOperation.class);
Expand Down Expand Up @@ -53,6 +53,12 @@ public void run() {
/* Fetch the stop times for this trip. Copy the list since it's immutable. */
List<StopTime> stopTimes = new ArrayList<>(stopTimesByTrip.get(trip));

// if we don't have flex routing enabled then remove all the flex locations and location
// groups
if(OTPFeature.FlexRouting.isOff()) {
stopTimes.removeIf(st -> !(st.getStop() instanceof Stop));
}

/* Stop times frequently contain duplicate, missing, or incorrect entries. Repair them. */
TIntList removedStopSequences = removeRepeatedStops(stopTimes);
if (!removedStopSequences.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ Trip map(org.onebusaway.gtfs.model.Trip orginal) {
return orginal == null ? null : mappedTrips.computeIfAbsent(orginal, this::doMap);
}

Collection<Trip> mappedTrips() {
return mappedTrips.values();
}

private Trip doMap(org.onebusaway.gtfs.model.Trip rhs) {
Trip lhs = new Trip(AgencyAndIdMapper.mapAgencyAndId(rhs.getId()));

Expand Down

0 comments on commit 6a40134

Please sign in to comment.