diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java index 3cb259d3a67..74a5d7a6352 100644 --- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java +++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java @@ -19,6 +19,11 @@ static List> mapTransfers(StopModel stopModel, TransitModel trans for (int i = 0; i < stopModel.stopIndexSize(); ++i) { var stop = stopModel.stopByIndex(i); + + if (stop == null) { + continue; + } + ArrayList list = new ArrayList<>(); for (PathTransfer pathTransfer : transitModel.getTransfersByStop(stop)) { diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerMapper.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerMapper.java index 210c8b42066..546a97b1d6e 100644 --- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerMapper.java +++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerMapper.java @@ -190,12 +190,21 @@ static int[] createStopBoardAlightTransferCosts( if (!tuningParams.enableStopTransferPriority()) { return null; } + int defaultCost = RaptorCostConverter.toRaptorCost( + tuningParams.stopBoardAlightDuringTransferCost(StopTransferPriority.ALLOWED) + ); int[] stopBoardAlightTransferCosts = new int[stops.stopIndexSize()]; for (int i = 0; i < stops.stopIndexSize(); ++i) { - StopTransferPriority priority = stops.stopByIndex(i).getPriority(); - int domainCost = tuningParams.stopBoardAlightDuringTransferCost(priority); - stopBoardAlightTransferCosts[i] = RaptorCostConverter.toRaptorCost(domainCost); + // There can be wholes in the stop index, so we need to account for 'null' here. + var stop = stops.stopByIndex(i); + if (stop == null) { + stopBoardAlightTransferCosts[i] = defaultCost; + } else { + var priority = stop.getPriority(); + int domainCost = tuningParams.stopBoardAlightDuringTransferCost(priority); + stopBoardAlightTransferCosts[i] = RaptorCostConverter.toRaptorCost(domainCost); + } } return stopBoardAlightTransferCosts; } diff --git a/src/main/java/org/opentripplanner/transit/service/StopModel.java b/src/main/java/org/opentripplanner/transit/service/StopModel.java index 763aa504c40..4f55ca25b5b 100644 --- a/src/main/java/org/opentripplanner/transit/service/StopModel.java +++ b/src/main/java/org/opentripplanner/transit/service/StopModel.java @@ -162,6 +162,7 @@ public Collection listGroupStops() { return groupStopById.values(); } + @Nullable public StopLocation stopByIndex(int stopIndex) { return index.stopByIndex(stopIndex); }