Skip to content

Commit

Permalink
Correctly split states which contain a mode for a single State
Browse files Browse the repository at this point in the history
When traversing *Link edges `backMode = null`, which in most cases
doesn't cause problems. When splitting Flex states, there is only a
single `BUS` state, which the logic skipped.

The last-seen mode is tracked, instead of the previous mode, which
correct the check for mode changes.
  • Loading branch information
flaktack committed Jun 4, 2021
1 parent 7cebc60 commit b5c0e11
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,18 @@ private static State[][] sliceStates(State[] states) {
int[] legIndexPairs = {0, states.length - 1};
List<int[]> legsIndexes = new ArrayList<int[]>();

TraverseMode lastMode = null;
for (int i = 1; i < states.length - 1; i++) {
var backState = states[i];
var forwardState = states[i + 1];
var backMode = backState.getBackMode();
var forwardMode = forwardState.getBackMode();

var modeChange = backMode != forwardMode && backMode != null && forwardMode != null;
if (backMode != null) {
lastMode = backMode;
}

var modeChange = lastMode != forwardMode && lastMode != null && forwardMode != null;
var parkingChange = backState.isVehicleParked() != forwardState.isVehicleParked();
var rentalChange = isRentalPickUp(backState) || isRentalDropOff(backState);

Expand Down

0 comments on commit b5c0e11

Please sign in to comment.