Skip to content

Set transit-group-priority for requests without via points #6253

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,17 @@ private RaptorRequest<T> doMap() {
}

private boolean hasPassThroughOnly() {
return request.getViaLocations().stream().allMatch(ViaLocation::isPassThroughLocation);
return (
request.isViaSearch() &&
request.getViaLocations().stream().allMatch(ViaLocation::isPassThroughLocation)
);
}

private boolean hasViaLocationsOnly() {
return request.getViaLocations().stream().noneMatch(ViaLocation::isPassThroughLocation);
return (
request.isViaSearch() &&
request.getViaLocations().stream().noneMatch(ViaLocation::isPassThroughLocation)
);
}

private boolean hasViaLocationsAndPassThroughLocations() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.opentripplanner.routing.algorithm.raptoradapter.transit.mappers;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.time.Duration;
Expand Down Expand Up @@ -90,6 +91,37 @@ void testPassThroughPoints() {
);
}

@Test
void testTransitGroupPriority() {
var req = new RouteRequest();

// Set relax transit-group-priority
req.withPreferences(p ->
p.withTransit(t -> t.withRelaxTransitGroupPriority(CostLinearFunction.of("30m + 1.2t")))
);

var result = map(req);

assertFalse(result.multiCriteria().transitPriorityCalculator().isEmpty());
}

@Test
void testVisitViaAllowsTransitGroupPriority() {
var req = new RouteRequest();

// Set visit-via and relax transit-group-priority
req.setViaLocations(
List.of(new VisitViaLocation("Via A", null, List.of(STOP_A.getId()), List.of()))
);
req.withPreferences(p ->
p.withTransit(t -> t.withRelaxTransitGroupPriority(CostLinearFunction.of("30m + 1.2t")))
);

var result = map(req);

assertFalse(result.multiCriteria().transitPriorityCalculator().isEmpty());
}

@Test
void testPassThroughPointsTurnTransitGroupPriorityOff() {
var req = new RouteRequest();
Expand Down
Loading