Skip to content

Commit

Permalink
Fix: NullPointerException in TransitLayerMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
t2gran committed Jul 3, 2024
1 parent d6c9f6f commit 76e9139
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ static List<List<Transfer>> mapTransfers(StopModel stopModel, TransitModel trans

for (int i = 0; i < stopModel.stopIndexSize(); ++i) {
var stop = stopModel.stopByIndex(i);

if (stop == null) {
continue;
}

ArrayList<Transfer> list = new ArrayList<>();

for (PathTransfer pathTransfer : transitModel.getTransfersByStop(stop)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public Collection<GroupStop> listGroupStops() {
return groupStopById.values();
}

@Nullable
public StopLocation stopByIndex(int stopIndex) {
return index.stopByIndex(stopIndex);
}
Expand Down

0 comments on commit 76e9139

Please sign in to comment.