Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed RouteOptionsUpdater to use snapping_include_closures=true for origin of each re-route request #6050

Merged
merged 1 commit into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Mapbox welcomes participation and contributions from everyone.
#### Features

#### Bug fixes and improvements
- Changed `RouteOptionsUpdater` to use `snapping_include_closures=true` for origin of each re-route request. This resolves a situation when Nav SDK returned a route in an opposite direction or on a parallel road when a driver caused a re-route by entering a closed section of a road. [#6050](https://github.com/mapbox/mapbox-navigation-android/pull/6050)

## Mapbox Navigation SDK 2.7.0-alpha.3 - July 8, 2022
### Changelog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import com.mapbox.api.directions.v5.models.Bearing
import com.mapbox.api.directions.v5.models.RouteOptions
import com.mapbox.geojson.Point
import com.mapbox.navigation.base.trip.model.RouteProgress
import com.mapbox.navigation.core.routealternatives.RouteAlternativesController
import com.mapbox.navigation.core.MapboxNavigation
import com.mapbox.navigation.core.reroute.MapboxRerouteController
import com.mapbox.navigation.core.trip.session.LocationMatcherResult
import com.mapbox.navigation.core.trip.session.OffRouteObserver
import com.mapbox.navigation.utils.internal.logE
Expand All @@ -15,17 +16,21 @@ private const val DEFAULT_REROUTE_BEARING_TOLERANCE = 90.0
private const val LOG_CATEGORY = "RouteOptionsUpdater"

/**
* Updater is used for *Reroute* and *Route Alternatives* flow.
* The updater can be used to create a new set of route request options to the existing destination, accounting for the progress along the route.
*
* It's used when turn-by-turn navigation goes off-route (see [OffRouteObserver])
* and when route alternatives (see [RouteAlternativesController]) are requested.
* For example, this is needed in order to filter the waypoints that have been completed.
* It's used by the default [MapboxRerouteController] (see [OffRouteObserver] and [MapboxNavigation.setRerouteController]).
*/
class RouteOptionsUpdater {

/**
* Provides a new [RouteOptions] instance based on the original request options, the current route progress and location matcher result.
*
* This carries over or adapts all of the request parameters to best fit the existing situation and remaining portion of the route.
*
* Notable adjustments:
* - `snapping_include_closures=true` is set for the origin of the request to aid with potential need to navigate out of a closed section of the road
* - `depart_at`/`arrive_by` parameters are cleared as they are not applicable in update/re-route scenario
*
* @return `RouteOptionsResult.Error` if a new [RouteOptions] instance cannot be combined based on the input given.
* `RouteOptionsResult.Success` with a new [RouteOptions] instance if successfully combined.
*/
Expand Down Expand Up @@ -99,11 +104,21 @@ class RouteOptionsUpdater {
.snappingIncludeClosuresList(
let snappingClosures@{
val snappingClosures = routeOptions.snappingIncludeClosuresList()
if (snappingClosures.isNullOrEmpty()) {
return@snappingClosures emptyList<Boolean>()
}
mutableListOf<Boolean>().also {
it.addAll(snappingClosures.subList(index, coordinatesList.size))
mutableListOf<Boolean?>().apply {
RingerJK marked this conversation as resolved.
Show resolved Hide resolved
// append true for the origin of the re-route request
add(true)
if (snappingClosures.isNullOrEmpty()) {
// create `null` value for each upcoming waypoint
addAll(arrayOfNulls<Boolean>(remainingWaypoints))
} else {
// get existing values for each upcoming waypoint
addAll(
snappingClosures.subList(
index + 1,
coordinatesList.size
)
)
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,6 @@ class RouteOptionsUpdaterTest {
)
.build()

private fun provideRouteOptionsWithCoordinatesAndSnappingClosures() =
provideRouteOptionsWithCoordinates()
.toBuilder()
.snappingIncludeClosuresList(
listOf(
true,
false,
true,
false
)
)
.build()

private fun provideRouteOptionsWithCoordinatesAndArriveByDepartAt() =
provideRouteOptionsWithCoordinates()
.toBuilder()
Expand Down Expand Up @@ -475,7 +462,17 @@ class RouteOptionsUpdaterTest {
@Parameterized.Parameters
fun params() = listOf(
arrayOf(
provideRouteOptionsWithCoordinatesAndSnappingClosures(),
provideRouteOptionsWithCoordinates()
.toBuilder()
.snappingIncludeClosuresList(
listOf(
true,
false,
true,
false
)
)
.build(),
3,
0,
"true;false;true;false"
Expand All @@ -484,10 +481,11 @@ class RouteOptionsUpdaterTest {
provideRouteOptionsWithCoordinates(),
1,
2,
null
"true;"
),
arrayOf(
provideRouteOptionsWithCoordinates().toBuilder()
provideRouteOptionsWithCoordinates()
.toBuilder()
.snappingIncludeClosuresList(
listOf(
true,
Expand All @@ -499,7 +497,7 @@ class RouteOptionsUpdaterTest {
.build(),
2,
1,
"false;false;false"
"true;false;false"
),
arrayOf(
provideRouteOptionsWithCoordinates().toBuilder()
Expand Down