Skip to content
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
1 change: 1 addition & 0 deletions src/main/java/org/opentripplanner/client/model/Leg.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public record Leg(
OffsetDateTime startTime,
OffsetDateTime endTime,
Boolean realTime,
boolean interlineWithPreviousLeg,
LegMode mode,
Duration duration,
double distance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public final class TripPlanParameters {
@Nullable private final Float carReluctance;
@Nullable private final Float bikeReluctance;
@Nullable private final Float bikeWalkingReluctance;
@Nullable private final Float walkSpeed;
private final boolean wheelchair;
@Nullable private final InputBanned banned;
private final OptimizeType optimize;
Expand All @@ -40,6 +41,7 @@ public TripPlanParameters(
@Nullable Float carReluctance,
@Nullable Float bikeReluctance,
@Nullable Float bikeWalkingReluctance,
@Nullable Float walkSpeed,
boolean wheelchair,
@Nullable InputBanned banned,
OptimizeType optimize,
Expand All @@ -55,6 +57,7 @@ public TripPlanParameters(
this.carReluctance = carReluctance;
this.bikeReluctance = bikeReluctance;
this.bikeWalkingReluctance = bikeWalkingReluctance;
this.walkSpeed = walkSpeed;
this.wheelchair = wheelchair;
this.banned = banned;
this.optimize = optimize;
Expand Down Expand Up @@ -126,6 +129,10 @@ public Optional<Float> bikeWalkingReluctance() {
return Optional.ofNullable(bikeWalkingReluctance);
}

public Optional<Float> walkSpeed() {
return Optional.ofNullable(walkSpeed);
}

public boolean wheelchair() {
return wheelchair;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class TripPlanParametersBuilder {
private Float carReluctance;
private Float bikeReluctance;
private Float bikeWalkingReluctance;
private Float walkSpeed;
private OptimizeType optimize = OptimizeType.QUICK;
private InputTriangle triangle;
private int numItineraries = 5;
Expand Down Expand Up @@ -82,6 +83,11 @@ public TripPlanParametersBuilder withBikeWalkingReluctance(float bwr) {
return this;
}

public TripPlanParametersBuilder withWalkSpeed(float ws) {
this.walkSpeed = ws;
return this;
}

public TripPlanParametersBuilder withNumberOfItineraries(int ni) {
this.numItineraries = ni;
return this;
Expand Down Expand Up @@ -139,6 +145,7 @@ public TripPlanParameters build() {
carReluctance,
bikeReluctance,
bikeWalkingReluctance,
walkSpeed,
wheelchair,
banned,
optimize,
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/queries/plan.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ query {
}
}
}
interlineWithPreviousLeg
mode
headsign
legGeometry {
Expand Down
23 changes: 22 additions & 1 deletion src/test/java/org/opentripplanner/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public void plan() throws IOException {

var leg = result.itineraries().get(0).legs().get(0);

// First leg should not interline with previous leg (since there is no previous leg)
assertFalse(leg.interlineWithPreviousLeg());

var transitLeg =
result.transitItineraries().stream()
.filter(i -> i.legs().stream().anyMatch(l -> l.intermediatePlaces().isPresent()))
Expand Down Expand Up @@ -108,6 +111,9 @@ public void planPlaceToPlace() throws IOException {

var leg = result.itineraries().get(0).legs().get(0);

// Test interlineWithPreviousLeg for first leg
assertFalse(leg.interlineWithPreviousLeg());

var transitLeg = result.transitItineraries().get(0).transitLegs().get(0);
assertFalse(transitLeg.from().stop().isEmpty());
assertFalse(transitLeg.to().stop().isEmpty());
Expand Down Expand Up @@ -246,6 +252,22 @@ public void planWithReluctance() throws IOException {
assertEquals(Optional.of(2.0f), builder.build().bikeWalkingReluctance());
}

@Test
public void planWithWalkSpeed() throws IOException {
TripPlanParametersBuilder builder =
TripPlanParameters.builder()
.withFrom(OSLO_WEST)
.withTo(OSLO_EAST)
.withTime(LocalDateTime.now())
.withModes(Set.of(RequestMode.WALK, RequestMode.TRANSIT));

assertEquals(Optional.empty(), builder.build().walkSpeed());

// Plan with high walk reluctance - should prefer transit
builder.withWalkSpeed(2.5f);
assertEquals(Optional.of(2.5f), builder.build().walkSpeed());
}

@Test
public void arriveByPlan() throws IOException {

Expand Down Expand Up @@ -308,7 +330,6 @@ public void routes() throws IOException {
assertFalse(routes.isEmpty());
routes.forEach(
r -> {
assertFalse(r.name().isEmpty(), "Route %s has no name.".formatted(r));
assertFalse(r.agency().name().isEmpty());
});
}
Expand Down