Skip to content

Commit bf165b5

Browse files
committed
wip
1 parent 5615c98 commit bf165b5

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Mapbox welcomes participation and contributions from everyone.
66
#### Features
77
#### Bug fixes and improvements
88

9+
:warning: `RouteProgress#remainingWaypoints` defines the amount of all remaining waypoints, include explicit (requested with `RouteOptions#coorinatesList`) and implicit (added on the fly, like Electric Vehicle waypoints - [see](https://docs.mapbox.com/api/navigation/directions/#electric-vehicle-routing)).
10+
911
## Mapbox Navigation SDK 2.9.0-beta.3 - 21 October, 2022
1012
### Changelog
1113
[Changes between v2.9.0-beta.2 and v2.9.0-beta.3](https://github.com/mapbox/mapbox-navigation-android/compare/v2.9.0-beta.2...v2.9.0-beta.3)

libnavigation-base/src/main/java/com/mapbox/navigation/base/internal/extensions/WaypointEx.kt

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:JvmName("WaypointEx")
2-
31
package com.mapbox.navigation.base.internal.extensions
42

53
import com.mapbox.api.directions.v5.models.DirectionsRoute
@@ -12,7 +10,7 @@ import com.mapbox.navigation.base.trip.model.RouteProgress
1210
*/
1311
fun List<Waypoint>.requestedWaypoints(): List<Waypoint> =
1412
this.filter {
15-
when(it.type) {
13+
when (it.type) {
1614
Waypoint.REGULAR,
1715
Waypoint.SILENT -> true
1816
Waypoint.EV_CHARGING -> false
@@ -26,7 +24,7 @@ fun List<Waypoint>.requestedWaypoints(): List<Waypoint> =
2624
*/
2725
fun List<Waypoint>.legsWaypoints(): List<Waypoint> =
2826
this.filter {
29-
when(it.type) {
27+
when (it.type) {
3028
Waypoint.REGULAR,
3129
Waypoint.EV_CHARGING -> true
3230
Waypoint.SILENT -> false

libnavigation-base/src/main/java/com/mapbox/navigation/base/trip/model/RouteProgress.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ import com.mapbox.navigation.base.trip.model.roadobject.UpcomingRoadObject
3333
* @param durationRemaining [Double] seconds time remaining until the route destination is reached.
3434
* @param fractionTraveled [Float] fraction traveled along the current route. This value is
3535
* between 0 and 1 and isn't guaranteed to reach 1 before the user reaches the end of the route.
36-
* @param remainingWaypoints [Int] number of waypoints remaining on the current route.
36+
* @param remainingWaypoints [Int] number of waypoints remaining on the current route. The waypoints number can be different
37+
* with number of requested coordinates. For instance, [EV routing](https://docs.mapbox.com/api/navigation/directions/#electric-vehicle-routing)
38+
* is adding additional waypoints, that are not requested explicitly.
3739
* @param upcomingRoadObjects list of upcoming road objects.
3840
* @param stale `true` if there were no location updates for a significant amount which causes
3941
* a lack of confidence in the progress updates being sent.

libnavigation-core/src/main/java/com/mapbox/navigation/core/routeoptions/RouteOptionsUpdater.kt

+5-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class RouteOptionsUpdater {
5252
val (nextCoordinateIndex, remainingCoordinates) = indexOfNextRequestedCoordinate(
5353
routeProgress.navigationRoute.internalWaypoints(),
5454
routeProgress.remainingWaypoints,
55-
).let { it ->
55+
).let {
5656
if (it == null) {
5757
val msg = "Index of next coordinate is not defined"
5858
logE(msg, LOG_CATEGORY)
@@ -93,14 +93,10 @@ class RouteOptionsUpdater {
9393
if (radiusesList.isNullOrEmpty()) {
9494
return@radiusesList emptyList<Double?>()
9595
}
96-
mutableListOf<Double?>().also {
97-
it.addAll(
98-
radiusesList.subList(
99-
nextCoordinateIndex - 1,
100-
coordinatesList.size
101-
)
102-
)
103-
}
96+
radiusesList.subList(
97+
nextCoordinateIndex - 1,
98+
coordinatesList.size
99+
)
104100
}
105101
)
106102
.approachesList(

libnavigation-core/src/test/java/com/mapbox/navigation/core/routeoptions/RouteOptionsUpdaterTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,14 @@ class RouteOptionsUpdaterTest {
458458
fun setup() {
459459
MockKAnnotations.init(this, relaxUnitFun = true, relaxed = true)
460460
mockLocation()
461-
mockkStatic("com.mapbox.navigation.base.internal.extensions.WaypointEx")
461+
mockkStatic(::indexOfNextRequestedCoordinate)
462462

463463
routeRefreshAdapter = RouteOptionsUpdater()
464464
}
465465

466466
@After
467467
fun cleanup() {
468-
unmockkStatic("com.mapbox.navigation.base.internal.extensions.WaypointEx")
468+
unmockkStatic(::indexOfNextRequestedCoordinate)
469469
}
470470

471471
@Test

0 commit comments

Comments
 (0)