From 93a5a50b17563325289a12e549b5a88e76e41ee8 Mon Sep 17 00:00:00 2001 From: Yury Kanetski Date: Mon, 16 Jan 2023 14:41:03 +0100 Subject: [PATCH 1/6] - Changed experimental extension `NavigationRoute#hasUnexpectedClosures` -> `RouteProgress#hasUnexpectedUpcomingClosures`: the algorithm is checking upcoming closures only, ignoring closures where puck already at. --- changelog/unreleased/bugfixes/changes.md | 1 + libnavigation-base/api/current.txt | 2 +- ...avigationRouteEx.kt => RouteProgressEx.kt} | 65 +++++++--- ...nRouteExTest.kt => RouteProgressExTest.kt} | 2 +- ...nRouteExTest.kt => RouteProgressExTest.kt} | 116 +++++++++++++++--- 5 files changed, 153 insertions(+), 33 deletions(-) create mode 100644 changelog/unreleased/bugfixes/changes.md rename libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/{NavigationRouteEx.kt => RouteProgressEx.kt} (65%) rename libnavigation-base/src/test/java/com/mapbox/navigation/base/internal/route/{NavigationRouteExTest.kt => RouteProgressExTest.kt} (99%) rename libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/{NavigationRouteExTest.kt => RouteProgressExTest.kt} (62%) diff --git a/changelog/unreleased/bugfixes/changes.md b/changelog/unreleased/bugfixes/changes.md new file mode 100644 index 00000000000..7919d2a0cfc --- /dev/null +++ b/changelog/unreleased/bugfixes/changes.md @@ -0,0 +1 @@ +- Removed `NavigationRoute#hasUnexpectedClosures` and added `RouteProgress#hasUnexpectedUpcomingClosures` instead that check whenever route has upcoming unexpected closures (the algorithm is not take into account closures that the puck already on) diff --git a/libnavigation-base/api/current.txt b/libnavigation-base/api/current.txt index b0576516e0c..c436e261a65 100644 --- a/libnavigation-base/api/current.txt +++ b/libnavigation-base/api/current.txt @@ -1745,7 +1745,7 @@ package com.mapbox.navigation.base.utils { package com.mapbox.navigation.base.utils.route { public final class NavigationRouteUtils { - method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public static suspend Object? hasUnexpectedClosures(com.mapbox.navigation.base.route.NavigationRoute, kotlin.coroutines.Continuation); + method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public static suspend Object? hasUnexpectedUpcomingClosures(com.mapbox.navigation.base.trip.model.RouteProgress, kotlin.coroutines.Continuation); } } diff --git a/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/NavigationRouteEx.kt b/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt similarity index 65% rename from libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/NavigationRouteEx.kt rename to libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt index 44883bd2a59..96608890ab8 100644 --- a/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/NavigationRouteEx.kt +++ b/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt @@ -8,7 +8,9 @@ import com.mapbox.api.directions.v5.models.RouteOptions import com.mapbox.geojson.Point import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI import com.mapbox.navigation.base.route.NavigationRoute +import com.mapbox.navigation.base.trip.model.RouteProgress import com.mapbox.navigation.base.utils.DecodeUtils.stepGeometryToPoints +import com.mapbox.navigation.utils.internal.ifNonNull import com.mapbox.navigation.utils.internal.logD import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -16,27 +18,51 @@ import kotlinx.coroutines.withContext private const val LOG_CATEGORY = "NavigationRouteUtils" /** - * This function checks whether the [NavigationRoute] has unexpected closures, which could be a reason to re-route. + * This function checks whether the [NavigationRoute] has unexpected upcoming closures, which could be a reason to re-route. * - * `true` is returned whenever there's any [RouteLeg.closures] outside of a direct region around a coordinate from [RouteOptions.coordinatesList] + * The algorithm does not take to account current closures, where the puck is on. + * + * `true` is returned whenever there's any upcoming [RouteLeg.closures] outside of a direct region around a coordinate from [RouteOptions.coordinatesList] * that was allowed for snapping to closures with [RouteOptions.snappingIncludeClosuresList] or [RouteOptions.snappingIncludeStaticClosuresList]. * flags. Otherwise, `false` is returned. */ @ExperimentalPreviewMapboxNavigationAPI -suspend fun NavigationRoute.hasUnexpectedClosures(): Boolean = +suspend fun RouteProgress.hasUnexpectedUpcomingClosures(): Boolean = withContext(Dispatchers.Default) { - val snappingResultList = directionsRoute.getSnappingResultList() + val snappingResultList = navigationRoute.directionsRoute.getSnappingResultList() + + val routeProgressData = ifNonNull( + currentLegProgress, + currentLegProgress?.currentStepProgress + ) { legProgress, stepProgress -> + RouteProgressData(legProgress.legIndex, stepProgress.stepIndex) + } var currentLegFirstWaypointIndex = 0 - directionsRoute.legs()?.forEachIndexed { routeLegIndex, routeLeg -> + navigationRoute.directionsRoute.legs()?.forEachIndexed { routeLegIndex, routeLeg -> val legLastGeometryIndex by lazy { - directionsRoute.stepsGeometryToPoints(routeLeg).lastIndex + navigationRoute.directionsRoute.stepsGeometryToPoints(routeLeg).lastIndex } val silentWaypoints = routeLeg.silentWaypoints() routeLeg.closures()?.forEach { closure -> + if (routeProgressData != null) { + if (routeProgressData.currentLegIndex > routeLegIndex) { + // skipping passed closures + return@forEach + } else if (routeProgressData.currentLegIndex == routeLegIndex && + ( + routeProgressData.currentStepIndex >= closure.geometryIndexEnd() || + routeProgressData.currentStepIndex in + closure.geometryIndexStart()..closure.geometryIndexEnd() + ) + ) { + // skipping current closures + return@forEach + } + } val silentWaypointsInClosureRange = silentWaypoints.inGeometryRange( closure.geometryIndexStart(), closure.geometryIndexEnd() @@ -49,9 +75,10 @@ suspend fun NavigationRoute.hasUnexpectedClosures(): Boolean = snappingResultList.getOrNull(silentWaypointIndex) ?: false if (!isSnapAllowed) { logD( - "Route with id [${this@hasUnexpectedClosures.id}] has closure " + - "at leg index $routeLegIndex, that overlaps silent (via) " + - "waypoint", + "Route with id " + + "[${this@hasUnexpectedUpcomingClosures.navigationRoute.id}] " + + "has closure at leg index $routeLegIndex, that overlaps " + + "silent (via) waypoint", LOG_CATEGORY ) return@withContext true @@ -63,8 +90,9 @@ suspend fun NavigationRoute.hasUnexpectedClosures(): Boolean = silentWaypointsInClosureRange.isEmpty() ) { logD( - "Route with id [${this@hasUnexpectedClosures.id}] has closure at leg " + - "index $routeLegIndex", + "Route with id " + + "[${this@hasUnexpectedUpcomingClosures.navigationRoute.id}] has " + + "closure at leg index $routeLegIndex", ) return@withContext true } @@ -72,8 +100,9 @@ suspend fun NavigationRoute.hasUnexpectedClosures(): Boolean = snappingResultList.getOrNull(currentLegFirstWaypointIndex) != true ) { logD( - "Route with id [${this@hasUnexpectedClosures.id}] has closure at the " + - "start of the leg, leg index $routeLegIndex", + "Route with id " + + "[${this@hasUnexpectedUpcomingClosures.navigationRoute.id}] has " + + "closure at the start of the leg, leg index $routeLegIndex", LOG_CATEGORY ) return@withContext true @@ -84,8 +113,9 @@ suspend fun NavigationRoute.hasUnexpectedClosures(): Boolean = ) != true ) { logD( - "Route with id [${this@hasUnexpectedClosures.id}] has closure at " + - "the end of the leg, leg index $routeLegIndex", + "Route with id " + + "[${this@hasUnexpectedUpcomingClosures.navigationRoute.id}] has " + + "closure at the end of the leg, leg index $routeLegIndex", LOG_CATEGORY ) return@withContext true @@ -98,6 +128,11 @@ suspend fun NavigationRoute.hasUnexpectedClosures(): Boolean = return@withContext false } +private class RouteProgressData( + val currentLegIndex: Int, + val currentStepIndex: Int, +) + private fun DirectionsRoute.getSnappingResultList(): List { val snappingIncludeClosuresList = routeOptions()?.snappingIncludeClosuresList() val snappingIncludeStaticClosuresList = routeOptions()?.snappingIncludeStaticClosuresList() diff --git a/libnavigation-base/src/test/java/com/mapbox/navigation/base/internal/route/NavigationRouteExTest.kt b/libnavigation-base/src/test/java/com/mapbox/navigation/base/internal/route/RouteProgressExTest.kt similarity index 99% rename from libnavigation-base/src/test/java/com/mapbox/navigation/base/internal/route/NavigationRouteExTest.kt rename to libnavigation-base/src/test/java/com/mapbox/navigation/base/internal/route/RouteProgressExTest.kt index 4d6d64f5303..ce0cb2156db 100644 --- a/libnavigation-base/src/test/java/com/mapbox/navigation/base/internal/route/NavigationRouteExTest.kt +++ b/libnavigation-base/src/test/java/com/mapbox/navigation/base/internal/route/RouteProgressExTest.kt @@ -31,7 +31,7 @@ import org.junit.runner.RunWith import org.junit.runners.Parameterized import java.net.URL -class NavigationRouteExTest { +class RouteProgressExTest { @Test fun `update Navigation route`() { diff --git a/libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/NavigationRouteExTest.kt b/libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/RouteProgressExTest.kt similarity index 62% rename from libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/NavigationRouteExTest.kt rename to libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/RouteProgressExTest.kt index c6a7719f509..1df732a1bf0 100644 --- a/libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/NavigationRouteExTest.kt +++ b/libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/RouteProgressExTest.kt @@ -4,11 +4,12 @@ import com.mapbox.api.directions.v5.DirectionsCriteria import com.mapbox.api.directions.v5.models.DirectionsRoute import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI import com.mapbox.navigation.base.route.NavigationRoute +import com.mapbox.navigation.base.trip.model.RouteProgress import com.mapbox.navigation.testing.FileUtils import com.mapbox.navigation.testing.LoggingFrontendTestRule import io.mockk.every import io.mockk.mockk -import junit.framework.Assert +import junit.framework.Assert.assertEquals import kotlinx.coroutines.runBlocking import org.junit.Rule import org.junit.Test @@ -17,22 +18,32 @@ import org.junit.runners.Parameterized private typealias BooleansProvider = () -> List -class NavigationRouteExTest { +class RouteProgressExTest { @OptIn(ExperimentalPreviewMapboxNavigationAPI::class) @RunWith(Parameterized::class) - class RouteHasUnexpectedClosures( + class RouteHasUnexpectedUpcomingClosures( private val description: String, private val routeRaw: String, private val snappingIncludeClosures: BooleansProvider?, private val snappingIncludeStaticClosures: BooleansProvider?, - private val expectedHasUnexpectedClosures: Boolean, + private val currentLegIndex: Int, + private val currentStepIndex: Int, + private val expectedHasUnexpectedUpcomingClosures: Boolean, ) { @get:Rule val loggerRule = LoggingFrontendTestRule() companion object { + /** + * - `route_closure_start_coordinate`: closure[0, 8], leg [0]; + * - `route_closure_second_waypoint`: closure[5, 8], leg [0] and closure[0, 8], leg[1]; + * - `route_closure_second_silent_waypoint`: closure[5, 16], leg [0]; + * - `route_closure_last_coordinate`: closure[4, 7], leg [1]; + * - `route_closure_between_silent_and_regular_waypoints`: closure[12, 13], leg [0]; + * - `route_closure_between_two_regular_waypoints`: closure[2, 3], leg [1]; + */ @JvmStatic @Parameterized.Parameters(name = "{0}") fun data(): List> = @@ -42,20 +53,27 @@ class NavigationRouteExTest { "multileg_route.json", { null }, { null }, + 0, + 0, false, ), arrayOf( - "route closure at starting waypoint, include closures = false", + "route closure at starting waypoint, include closures = false; " + + "the puck is in the very beginning", "route_closure_start_coordinate.json", provideBooleansProvider(false, true, true), provideBooleansProvider(false, true, true), - true, + 0, + 0, + false, ), arrayOf( "route closure at starting waypoint, include closures = true", "route_closure_start_coordinate.json", provideBooleansProvider(true, false, false), provideBooleansProvider(true, false, false), + 0, + 0, false, ), arrayOf( @@ -63,6 +81,8 @@ class NavigationRouteExTest { "route_closure_start_coordinate.json", provideBooleansProvider(false, false, false), provideBooleansProvider(true, false, false), + 0, + 0, false, ), arrayOf( @@ -70,6 +90,8 @@ class NavigationRouteExTest { "route_closure_start_coordinate.json", provideBooleansProvider(true, false, false), provideBooleansProvider(false, false, false), + 0, + 0, false, ), arrayOf( @@ -77,27 +99,65 @@ class NavigationRouteExTest { "route_closure_second_waypoint.json", provideBooleansProvider(true, false, true), provideBooleansProvider(true, false, true), + 0, + 0, true, ), + arrayOf( + "route closure at second waypoint, include closures = false; " + + "the puck is on the first closure of 2", + "route_closure_second_waypoint.json", + provideBooleansProvider(true, false, true), + provideBooleansProvider(true, false, true), + 0, + 6, + true, + ), + arrayOf( + "route closure at second waypoint, include closures = false; " + + "the puck is on the second closure of 2", + "route_closure_second_waypoint.json", + provideBooleansProvider(true, false, true), + provideBooleansProvider(true, false, true), + 1, + 7, + false, + ), arrayOf( "route closure at second waypoint, include closures = true", "route_closure_second_waypoint.json", provideBooleansProvider(false, true, false), provideBooleansProvider(false, true, false), + 0, + 0, false, ), arrayOf( "route closure at second *silent* waypoint, include closures = false", - "route_closure_second_silent_waypoin.json", + "route_closure_second_silent_waypoint.json", provideBooleansProvider(true, false, true), provideBooleansProvider(true, false, true), + 0, + 5, + false, + ), + arrayOf( + "route closure at second *silent* waypoint, include closures = false;" + + "the puck has just stepped on the closure", + "route_closure_second_silent_waypoint.json", + provideBooleansProvider(true, false, true), + provideBooleansProvider(true, false, true), + 0, + 0, true, ), arrayOf( "route closure at second *silent* waypoint, include closures = true", - "route_closure_second_silent_waypoin.json", + "route_closure_second_silent_waypoint.json", provideBooleansProvider(false, true, false), provideBooleansProvider(false, true, false), + 0, + 0, false, ), arrayOf( @@ -105,6 +165,8 @@ class NavigationRouteExTest { "route_closure_last_coordinate.json", provideBooleansProvider(true, true, false), provideBooleansProvider(true, true, false), + 0, + 0, true, ), arrayOf( @@ -112,6 +174,8 @@ class NavigationRouteExTest { "route_closure_last_coordinate.json", provideBooleansProvider(false, false, true), provideBooleansProvider(false, false, true), + 0, + 0, false, ), arrayOf( @@ -119,6 +183,8 @@ class NavigationRouteExTest { "route_closure_between_silent_and_regular_waypoints.json", provideBooleansProvider(true, true, true), provideBooleansProvider(true, true, true), + 0, + 0, true, ), arrayOf( @@ -126,6 +192,8 @@ class NavigationRouteExTest { "route_closure_between_two_regular_waypoints.json", provideBooleansProvider(true, true, true), provideBooleansProvider(true, true, true), + 0, + 0, true, ), ) @@ -158,6 +226,18 @@ class NavigationRouteExTest { } } + private fun mockRouteProgress( + navigationRoute: NavigationRoute, + currentLegIndex: Int, + currentStepIndex: Int, + ): RouteProgress = mockk { + every { this@mockk.navigationRoute } returns navigationRoute + every { currentLegProgress } returns mockk { + every { legIndex } returns currentLegIndex + every { currentStepProgress?.stepIndex } returns currentStepIndex + } + } + private fun provideBooleansProvider( vararg bool: Boolean?, ): BooleansProvider = { bool.asList() } @@ -165,18 +245,22 @@ class NavigationRouteExTest { @Test fun testCases() = runBlocking { - val navRoute = mockNavigationRoute( - routeRaw, - snappingIncludeClosures, - snappingIncludeStaticClosures, + val routeProgress = mockRouteProgress( + mockNavigationRoute( + routeRaw, + snappingIncludeClosures, + snappingIncludeStaticClosures, + ), + currentLegIndex, + currentStepIndex, ) - val hasUnexpectedClosures = navRoute.hasUnexpectedClosures() + val hasUnexpectedUpcomingClosures = routeProgress.hasUnexpectedUpcomingClosures() - Assert.assertEquals( + assertEquals( description, - expectedHasUnexpectedClosures, - hasUnexpectedClosures + expectedHasUnexpectedUpcomingClosures, + hasUnexpectedUpcomingClosures ) } } From ced3462db139028d931750bd0901ae3b276fb6cb Mon Sep 17 00:00:00 2001 From: Yury Kanetski Date: Mon, 16 Jan 2023 15:16:51 +0100 Subject: [PATCH 2/6] fix typo --- ...ent_waypoin.json => route_closure_second_silent_waypoint.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libnavigation-base/src/test/resources/{route_closure_second_silent_waypoin.json => route_closure_second_silent_waypoint.json} (100%) diff --git a/libnavigation-base/src/test/resources/route_closure_second_silent_waypoin.json b/libnavigation-base/src/test/resources/route_closure_second_silent_waypoint.json similarity index 100% rename from libnavigation-base/src/test/resources/route_closure_second_silent_waypoin.json rename to libnavigation-base/src/test/resources/route_closure_second_silent_waypoint.json From 8f8bed31f3abe2d9cea495769f129d9a8d4eb7cc Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 16 Jan 2023 14:17:25 +0000 Subject: [PATCH 3/6] Rename changelog files --- changelog/unreleased/bugfixes/{changes.md => 6841.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/unreleased/bugfixes/{changes.md => 6841.md} (100%) diff --git a/changelog/unreleased/bugfixes/changes.md b/changelog/unreleased/bugfixes/6841.md similarity index 100% rename from changelog/unreleased/bugfixes/changes.md rename to changelog/unreleased/bugfixes/6841.md From cf620f068eba2ac55e98fa7b251723c5c15d2907 Mon Sep 17 00:00:00 2001 From: Yury Kanetski Date: Wed, 18 Jan 2023 10:32:47 +0100 Subject: [PATCH 4/6] wip --- .../navigation/base/utils/route/RouteProgressEx.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt b/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt index 96608890ab8..af8e8667832 100644 --- a/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt +++ b/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt @@ -50,16 +50,13 @@ suspend fun RouteProgress.hasUnexpectedUpcomingClosures(): Boolean = routeLeg.closures()?.forEach { closure -> if (routeProgressData != null) { if (routeProgressData.currentLegIndex > routeLegIndex) { - // skipping passed closures + // skipping passed legs return@forEach - } else if (routeProgressData.currentLegIndex == routeLegIndex && - ( - routeProgressData.currentStepIndex >= closure.geometryIndexEnd() || - routeProgressData.currentStepIndex in - closure.geometryIndexStart()..closure.geometryIndexEnd() - ) + } else if ( + routeProgressData.currentLegIndex == routeLegIndex && + routeProgressData.currentStepIndex >= closure.geometryIndexStart() ) { - // skipping current closures + // skipping current and passed closures on the **current** leg return@forEach } } From 23446fff6336526fda912404fc72f14f2618ff6a Mon Sep 17 00:00:00 2001 From: Yury Kanetski Date: Wed, 18 Jan 2023 10:33:49 +0100 Subject: [PATCH 5/6] fix changelog and comment --- changelog/unreleased/bugfixes/6841.md | 2 +- .../com/mapbox/navigation/base/utils/route/RouteProgressEx.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/unreleased/bugfixes/6841.md b/changelog/unreleased/bugfixes/6841.md index 7919d2a0cfc..4c56a280a22 100644 --- a/changelog/unreleased/bugfixes/6841.md +++ b/changelog/unreleased/bugfixes/6841.md @@ -1 +1 @@ -- Removed `NavigationRoute#hasUnexpectedClosures` and added `RouteProgress#hasUnexpectedUpcomingClosures` instead that check whenever route has upcoming unexpected closures (the algorithm is not take into account closures that the puck already on) +- Removed `NavigationRoute#hasUnexpectedClosures` and added `RouteProgress#hasUnexpectedUpcomingClosures` instead that checks whether route has upcoming unexpected closures (the algorithm does not take into account closures that the puck has already been on) diff --git a/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt b/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt index af8e8667832..7e0b5d62439 100644 --- a/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt +++ b/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt @@ -56,7 +56,7 @@ suspend fun RouteProgress.hasUnexpectedUpcomingClosures(): Boolean = routeProgressData.currentLegIndex == routeLegIndex && routeProgressData.currentStepIndex >= closure.geometryIndexStart() ) { - // skipping current and passed closures on the **current** leg + // skipping current and passed closures on the current leg return@forEach } } From 2ec65912b82bb4d17b275476395eba68a76c78c9 Mon Sep 17 00:00:00 2001 From: Yury Kanetski Date: Wed, 18 Jan 2023 12:57:05 +0100 Subject: [PATCH 6/6] wip --- .../navigation/base/utils/route/RouteProgressEx.kt | 9 ++++----- .../navigation/base/utils/route/RouteProgressExTest.kt | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt b/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt index 7e0b5d62439..3bab649d033 100644 --- a/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt +++ b/libnavigation-base/src/main/java/com/mapbox/navigation/base/utils/route/RouteProgressEx.kt @@ -33,9 +33,8 @@ suspend fun RouteProgress.hasUnexpectedUpcomingClosures(): Boolean = val routeProgressData = ifNonNull( currentLegProgress, - currentLegProgress?.currentStepProgress - ) { legProgress, stepProgress -> - RouteProgressData(legProgress.legIndex, stepProgress.stepIndex) + ) { legProgress -> + RouteProgressData(legProgress.legIndex, legProgress.geometryIndex) } var currentLegFirstWaypointIndex = 0 @@ -54,7 +53,7 @@ suspend fun RouteProgress.hasUnexpectedUpcomingClosures(): Boolean = return@forEach } else if ( routeProgressData.currentLegIndex == routeLegIndex && - routeProgressData.currentStepIndex >= closure.geometryIndexStart() + routeProgressData.currentGeometryLegIndex >= closure.geometryIndexStart() ) { // skipping current and passed closures on the current leg return@forEach @@ -127,7 +126,7 @@ suspend fun RouteProgress.hasUnexpectedUpcomingClosures(): Boolean = private class RouteProgressData( val currentLegIndex: Int, - val currentStepIndex: Int, + val currentGeometryLegIndex: Int, ) private fun DirectionsRoute.getSnappingResultList(): List { diff --git a/libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/RouteProgressExTest.kt b/libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/RouteProgressExTest.kt index 1df732a1bf0..c777ac04324 100644 --- a/libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/RouteProgressExTest.kt +++ b/libnavigation-base/src/test/java/com/mapbox/navigation/base/utils/route/RouteProgressExTest.kt @@ -28,7 +28,7 @@ class RouteProgressExTest { private val snappingIncludeClosures: BooleansProvider?, private val snappingIncludeStaticClosures: BooleansProvider?, private val currentLegIndex: Int, - private val currentStepIndex: Int, + private val currentGeometryLegIndex: Int, private val expectedHasUnexpectedUpcomingClosures: Boolean, ) { @@ -229,12 +229,12 @@ class RouteProgressExTest { private fun mockRouteProgress( navigationRoute: NavigationRoute, currentLegIndex: Int, - currentStepIndex: Int, + currentLegGeometryIndex: Int, ): RouteProgress = mockk { every { this@mockk.navigationRoute } returns navigationRoute every { currentLegProgress } returns mockk { every { legIndex } returns currentLegIndex - every { currentStepProgress?.stepIndex } returns currentStepIndex + every { geometryIndex } returns currentLegGeometryIndex } } @@ -252,7 +252,7 @@ class RouteProgressExTest { snappingIncludeStaticClosures, ), currentLegIndex, - currentStepIndex, + currentGeometryLegIndex, ) val hasUnexpectedUpcomingClosures = routeProgress.hasUnexpectedUpcomingClosures()