-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Small clean up of flex duration factor/offset #5856
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
Changes from 3 commits
1fbf5ca
0113169
57c4282
3faf591
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package org.opentripplanner.ext.flex; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.opentripplanner.graph_builder.issue.api.DataImportIssueStore.NOOP; | ||
|
|
||
| import java.util.List; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.opentripplanner.model.StopTime; | ||
| import org.opentripplanner.model.impl.OtpTransitServiceBuilder; | ||
| import org.opentripplanner.transit.model._data.TransitModelForTest; | ||
| import org.opentripplanner.transit.service.StopModel; | ||
|
|
||
| class FlexTripsMapperTest { | ||
|
|
||
| @Test | ||
| void defaultTimePenalty() { | ||
| var builder = new OtpTransitServiceBuilder(StopModel.of().build(), NOOP); | ||
| var stopTimes = List.of(stopTime(0), stopTime(1)); | ||
| builder.getStopTimesSortedByTrip().addAll(stopTimes); | ||
| var trips = FlexTripsMapper.createFlexTrips(builder, NOOP); | ||
| assertEquals("[UnscheduledTrip{F:flex-1 timePenalty=(0s + 1.00 t)}]", trips.toString()); | ||
| } | ||
|
|
||
| private static StopTime stopTime(int seq) { | ||
| var st = FlexStopTimesForTest.area("08:00", "18:00"); | ||
| st.setTrip(TransitModelForTest.trip("flex-1").build()); | ||
| st.setStopSequence(seq); | ||
| return st; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| import java.util.stream.IntStream; | ||
| import java.util.stream.Stream; | ||
| import javax.annotation.Nonnull; | ||
| import javax.annotation.Nullable; | ||
| import org.opentripplanner.ext.flex.FlexServiceDate; | ||
| import org.opentripplanner.ext.flex.flexpathcalculator.FlexPathCalculator; | ||
| import org.opentripplanner.ext.flex.flexpathcalculator.TimePenaltyCalculator; | ||
|
|
@@ -29,6 +30,7 @@ | |
| import org.opentripplanner.routing.graphfinder.NearbyStop; | ||
| import org.opentripplanner.standalone.config.sandbox.FlexConfig; | ||
| import org.opentripplanner.transit.model.framework.FeedScopedId; | ||
| import org.opentripplanner.transit.model.framework.LogInfo; | ||
| import org.opentripplanner.transit.model.framework.TransitBuilder; | ||
| import org.opentripplanner.transit.model.site.GroupStop; | ||
| import org.opentripplanner.transit.model.site.StopLocation; | ||
|
|
@@ -45,7 +47,9 @@ | |
| * <p> | ||
| * For a discussion of this behaviour see https://github.com/MobilityData/gtfs-flex/issues/76 | ||
| */ | ||
| public class UnscheduledTrip extends FlexTrip<UnscheduledTrip, UnscheduledTripBuilder> { | ||
| public class UnscheduledTrip | ||
| extends FlexTrip<UnscheduledTrip, UnscheduledTripBuilder> | ||
| implements LogInfo { | ||
|
|
||
| private static final Set<Integer> N_STOPS = Set.of(1, 2); | ||
| private static final int INDEX_NOT_FOUND = -1; | ||
|
|
@@ -154,9 +158,15 @@ public Stream<FlexAccessTemplate> getFlexAccessTemplates( | |
| ); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public String logName() { | ||
| return "timePenalty=(%s)".formatted(timePenalty.toString()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think this is what the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel a bit stupid because I should have thought of that myself. 🤦♂️ |
||
| } | ||
|
|
||
| /** | ||
| * Get the correct {@link FlexPathCalculator} depending on the {@code timePenalty}. | ||
| * If the modifier doesn't actually modify, we return the regular calculator. | ||
| * If the penalty would not change the result, we return the regular calculator. | ||
| */ | ||
| protected FlexPathCalculator flexPathCalculator(FlexPathCalculator calculator) { | ||
| if (timePenalty.modifies()) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.