Closed ahmedre closed 1 week ago
I have no idea if this is the ideal fix or not, but I saw this case while testing, where, while logging:
"metadata: " +
navigatingState.tripState.remainingSteps.size +
" remaining steps, current index; " +
navigatingState.tripState.currentStepGeometryIndex +
" geometry size " +
navigatingState.tripState.remainingSteps.firstOrNull()?.geometry?.size
I saw a case where the geometry index was greater than the geometry size (and, at that point, the current remaining steps size had decreased by 1). Looking at the code, it seems that there's no re-computation of the current step geometry index after the current step changes, causing this to be incorrect.
Thanks - I was doing the recalculation in the wrong function (in the advance function). The caller actually disregards all fields it isn't interested in, and the comment actually says that this is by design, since the caller should re-compute whatever it needs to.
After advancing the step, the geometry index sometimes incorrectly refers to an index in the previous RouteStep instead of the current one. This patch recomputes the geometry index when the RouteSteps change.