File tree Expand file tree Collapse file tree 2 files changed +10
-14
lines changed
libnavigation-core/src/main/java/com/mapbox/navigation/core/replay/route Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -96,19 +96,11 @@ class ReplayPolylineDecodeStream(
9696 }
9797
9898 /* *
99- * Skip the next [minDistance] of the geometry. Similar to decode except that this does not
99+ * Skip the next [count] points of the geometry. Similar to decode except that this does not
100100 * hold any points in memory.
101101 */
102- fun skip (
103- minDistance : Double ,
104- @TurfConstants.TurfUnitCriteria units : String = TurfConstants .UNIT_KILOMETERS
105- ) {
106- var travelled = 0.0
107- current?.let { if (minDistance > 0.0 && hasNext()) next() }
108- while (travelled < minDistance && hasNext()) {
109- val previous = current
110- val next = next()
111- travelled + = previous?.let { TurfMeasurement .distance(previous, next, units) } ? : 0.0
112- }
102+ fun skip (count : Int ) {
103+ var skipped = 0
104+ while (skipped++ < count && hasNext()) { next() }
113105 }
114106}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import com.mapbox.navigation.core.replay.history.ReplayEventBase
1919import com.mapbox.navigation.core.replay.history.ReplayEventUpdateLocation
2020import com.mapbox.navigation.core.replay.history.ReplayEventsObserver
2121import com.mapbox.navigation.core.trip.session.RouteProgressObserver
22+ import com.mapbox.navigation.utils.internal.logI
2223import com.mapbox.navigation.utils.internal.logW
2324import com.mapbox.turf.TurfConstants
2425import java.util.*
@@ -156,9 +157,12 @@ class ReplayRouteSession : MapboxNavigationObserver {
156157 }
157158 return
158159 }
159- val distanceTraveled = routeProgress.distanceTraveled.toDouble()
160160 polylineDecodeStream = ReplayPolylineDecodeStream (geometry, 6 )
161- polylineDecodeStream.skip(distanceTraveled, TurfConstants .UNIT_METERS )
161+
162+ // Skip up to the current geometry index. There is some imprecision here because the
163+ // distance traveled is not equal to a route index.
164+ polylineDecodeStream.skip(routeProgress.currentRouteGeometryIndex)
165+
162166 pushMorePoints()
163167 }
164168
You can’t perform that action at this time.
0 commit comments