Skip to content
Open
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 @@ -204,7 +204,8 @@ public void update(
patternsForDate.remove(tripPatternForDate);
}
} else {
LOG.warn("Could not fetch timetable for {}", pattern);
LOG.warn("Could not fetch timetable for {}, removing.", pattern);
patternsForDate.remove(tripPatternForDate);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most important change in the PR. I absolutely support changing this class but I'm having a hard time understanding the consequences of this change: the code is very complex with several collections updating each other.

If you have a better understanding, do you have time to walk me through the code? Maybe @vpaturet is interested as well.

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -132,10 +133,26 @@ public static Result<TripTimesPatch, UpdateError> createUpdatedTripTimesFromGtfs
}

if (match) {
update.stopHeadsign().ifPresent(x -> builder.withStopHeadsign(index, x));
update.pickup().ifPresent(x -> updatedPickups.put(index, x));
update.dropoff().ifPresent(x -> updatedDropoffs.put(index, x));
update.assignedStopId().ifPresent(x -> replacedStopIndices.put(index, x));
var scheduledStopId = timetable.getPattern().getStop(i).getId().getId();
var scheduledStopHeadsign = tripTimes.getHeadsign(i);
var scheduledPickup = timetable.getPattern().getBoardType(i);
var scheduledDropoff = timetable.getPattern().getAlightType(i);
update
.stopHeadsign()
.filter(x -> !Objects.equals(x, scheduledStopHeadsign))
.ifPresent(x -> builder.withStopHeadsign(index, x));
update
.pickup()
.filter(x -> x != scheduledPickup)
.ifPresent(x -> updatedPickups.put(index, x));
update
.dropoff()
.filter(x -> x != scheduledDropoff)
.ifPresent(x -> updatedDropoffs.put(index, x));
update
.assignedStopId()
.filter(x -> !Objects.equals(x, scheduledStopId))
.ifPresent(x -> replacedStopIndices.put(index, x));

var scheduleRelationship = update.scheduleRelationship();
// Handle each schedule relationship case
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.opentripplanner.transit.model._data;

import java.time.Duration;
import java.util.List;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.TransitTuningParameters;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.transit.model.site.StopTransferPriority;

class TestTransitTuningParameters implements TransitTuningParameters {

@Override
public boolean enableStopTransferPriority() {
return false;
}

@Override
public Integer stopBoardAlightDuringTransferCost(StopTransferPriority key) {
return 0;
}

@Override
public int transferCacheMaxSize() {
return 0;
}

@Override
public Duration maxSearchWindow() {
return null;
}

@Override
public List<Duration> pagingSearchWindowAdjustments() {
return List.of();
}

@Override
public List<RouteRequest> transferCacheRequests() {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import java.time.ZoneId;
import org.opentripplanner.LocalTimeParser;
import org.opentripplanner.model.TimetableSnapshot;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.RaptorTransitData;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.mappers.RaptorTransitDataMapper;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.mappers.RealTimeRaptorTransitDataUpdater;
import org.opentripplanner.transit.service.DefaultTransitService;
import org.opentripplanner.transit.service.TimetableRepository;
import org.opentripplanner.transit.service.TransitService;
Expand Down Expand Up @@ -40,8 +43,14 @@ public static TransitTestEnvironmentBuilder of(LocalDate serviceDate, ZoneId tim
this.timetableRepository = timetableRepository;

this.timetableRepository.index();
this.timetableRepository.setRaptorTransitData(
RaptorTransitDataMapper.map(new TestTransitTuningParameters(), timetableRepository)
);
this.timetableRepository.setRealtimeRaptorTransitData(
new RaptorTransitData(timetableRepository.getRaptorTransitData())
);
this.snapshotManager = new TimetableSnapshotManager(
null,
new RealTimeRaptorTransitDataUpdater(timetableRepository),
TimetableSnapshotParameters.PUBLISH_IMMEDIATELY,
() -> defaultServiceDate
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public interface RealtimeTestConstants {
String STOP_B_ID = "B";
String STOP_C_ID = "C";
String STOP_D_ID = "D";
String STOP_E_ID = "E";
}
Loading
Loading