Skip to content

Commit 70f7cee

Browse files
authored
Merge pull request opentripplanner#7089 from ibi-group/fix-arrive-by
To fix arriveBy searches always set arriveBy property to false in transfer requests
2 parents ae106c8 + d7e65b7 commit 70f7cee

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

application/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public static StreetSearchRequestBuilder mapToTransferRequest(RouteRequest reque
4646
return mapInternal(request)
4747
.withFrom(null)
4848
.withTo(null)
49+
// transfer requests are always depart-at
50+
.withArriveBy(false)
4951
.withStartTime(Instant.ofEpochSecond(0))
5052
.withMode(request.journey().transfer().mode());
5153
}

application/src/test/java/org/opentripplanner/street/search/request/StreetSearchRequestMapperTest.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.time.Instant;
1313
import java.util.Set;
1414
import org.junit.jupiter.api.Test;
15+
import org.junit.jupiter.params.ParameterizedTest;
16+
import org.junit.jupiter.params.provider.ValueSource;
1517
import org.opentripplanner.framework.model.Cost;
1618
import org.opentripplanner.model.GenericLocation;
1719
import org.opentripplanner.routing.api.request.RequestModes;
@@ -47,18 +49,19 @@ void mapVehicleWalking() {
4749
assertTrue(subject.wheelchairEnabled());
4850
}
4951

50-
@Test
51-
void mapVehicleWalkingToTransferRequest() {
52-
var builder = builder();
53-
54-
Instant dateTime = Instant.parse("2022-11-10T10:00:00Z");
55-
builder.withDateTime(dateTime);
52+
@ParameterizedTest
53+
@ValueSource(booleans = { true, false })
54+
void mapTransferRequest(boolean arriveBy) {
5655
var from = new GenericLocation(null, id("STOP"), null, null);
57-
builder.withFrom(from);
5856
var to = GenericLocation.fromCoordinate(60.0, 20.0);
59-
builder.withTo(to);
60-
builder.withPreferences(it -> it.withWalk(walk -> walk.withSpeed(2.4)));
61-
builder.withJourney(j -> j.withWheelchair(true));
57+
var dateTime = Instant.parse("2022-11-10T10:00:00Z");
58+
var builder = builder()
59+
.withArriveBy(arriveBy)
60+
.withDateTime(dateTime)
61+
.withFrom(from)
62+
.withTo(to)
63+
.withPreferences(it -> it.withWalk(walk -> walk.withSpeed(2.4)))
64+
.withJourney(j -> j.withWheelchair(true));
6265

6366
var request = builder.buildRequest();
6467

@@ -68,6 +71,10 @@ void mapVehicleWalkingToTransferRequest() {
6871
assertNull(subject.fromEnvelope());
6972
assertNull(subject.toEnvelope());
7073
assertTrue(subject.wheelchairEnabled());
74+
assertEquals(2.4, subject.walk().speed());
75+
assertEquals(Instant.ofEpochSecond(0), subject.startTime());
76+
// arrive by must always be false for transfer requests
77+
assertFalse(subject.arriveBy());
7178
}
7279

7380
@Test

0 commit comments

Comments
 (0)