Skip to content

Commit a880c62

Browse files
kiryldzyunikkk
authored andcommitted
Expose PredictiveCacheLocationOptions.loadPredictiveCacheForAlternativeRoutes; create HD predictive cache (#10233)
* HD predictive cache * PR fixes * More docs --------- Co-authored-by: yunikkk <[email protected]> GitOrigin-RevId: ef1f7558c927359c4ce05e78a82b7a4ca015d8a9
1 parent 1678580 commit a880c62

File tree

6 files changed

+41
-8
lines changed

6 files changed

+41
-8
lines changed

base/api/current.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,12 @@ package com.mapbox.navigation.base.options {
753753
public final class PredictiveCacheLocationOptions {
754754
method public int getCurrentLocationRadiusInMeters();
755755
method public int getDestinationLocationRadiusInMeters();
756+
method public boolean getLoadPredictiveCacheForAlternativeRoutes();
756757
method public int getRouteBufferRadiusInMeters();
757758
method public com.mapbox.navigation.base.options.PredictiveCacheLocationOptions.Builder toBuilder();
758759
property public final int currentLocationRadiusInMeters;
759760
property public final int destinationLocationRadiusInMeters;
761+
property public final boolean loadPredictiveCacheForAlternativeRoutes;
760762
property public final int routeBufferRadiusInMeters;
761763
}
762764

@@ -765,9 +767,14 @@ package com.mapbox.navigation.base.options {
765767
method public com.mapbox.navigation.base.options.PredictiveCacheLocationOptions build();
766768
method public com.mapbox.navigation.base.options.PredictiveCacheLocationOptions.Builder currentLocationRadiusInMeters(int radiusInMeters);
767769
method public com.mapbox.navigation.base.options.PredictiveCacheLocationOptions.Builder destinationLocationRadiusInMeters(int radiusInMeters);
770+
method public com.mapbox.navigation.base.options.PredictiveCacheLocationOptions.Builder loadPredictiveCacheForAlternativeRoutes(boolean load);
768771
method public com.mapbox.navigation.base.options.PredictiveCacheLocationOptions.Builder routeBufferRadiusInMeters(int radiusInMeters);
769772
}
770773

774+
public final class PredictiveCacheLocationOptionsKt {
775+
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public static com.mapbox.navigator.PredictiveLocationTrackerOptions toPredictiveLocationTrackerOptions(com.mapbox.navigation.base.options.PredictiveCacheLocationOptions);
776+
}
777+
771778
public final class PredictiveCacheMapsOptions {
772779
method public com.mapbox.bindgen.Value? getExtraOptions();
773780
method public byte getMaxZoom();

base/src/main/java/com/mapbox/navigation/base/options/PredictiveCacheLocationOptions.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
package com.mapbox.navigation.base.options
22

3+
import androidx.annotation.RestrictTo
4+
import com.mapbox.navigator.PredictiveLocationTrackerOptions
5+
36
/**
47
* PredictiveCacheLocationOptions.
58
*
69
* @param currentLocationRadiusInMeters How far around the user's location we're going to cache, in meters. Defaults to 20000 (20 km)
710
* @param routeBufferRadiusInMeters How far around the active route we're going to cache, in meters (if route is set). Defaults to 5000 (5 km)
811
* @param destinationLocationRadiusInMeters How far around the destination location we're going to cache, in meters (if route is set). Defaults to 50000 (50 km)
12+
* @param loadPredictiveCacheForAlternativeRoutes Whether alternative routes will be loaded for predictive cache. Defaults to false.
913
*/
1014
class PredictiveCacheLocationOptions private constructor(
1115
val currentLocationRadiusInMeters: Int,
1216
val routeBufferRadiusInMeters: Int,
1317
val destinationLocationRadiusInMeters: Int,
18+
val loadPredictiveCacheForAlternativeRoutes: Boolean,
1419
) {
1520

1621
/**
@@ -20,6 +25,7 @@ class PredictiveCacheLocationOptions private constructor(
2025
currentLocationRadiusInMeters(currentLocationRadiusInMeters)
2126
routeBufferRadiusInMeters(routeBufferRadiusInMeters)
2227
destinationLocationRadiusInMeters(destinationLocationRadiusInMeters)
28+
loadPredictiveCacheForAlternativeRoutes(loadPredictiveCacheForAlternativeRoutes)
2329
}
2430

2531
/**
@@ -36,6 +42,11 @@ class PredictiveCacheLocationOptions private constructor(
3642
if (destinationLocationRadiusInMeters != other.destinationLocationRadiusInMeters) {
3743
return false
3844
}
45+
if (loadPredictiveCacheForAlternativeRoutes !=
46+
other.loadPredictiveCacheForAlternativeRoutes
47+
) {
48+
return false
49+
}
3950

4051
return true
4152
}
@@ -47,6 +58,7 @@ class PredictiveCacheLocationOptions private constructor(
4758
var result = currentLocationRadiusInMeters.hashCode()
4859
result = 31 * result + routeBufferRadiusInMeters.hashCode()
4960
result = 31 * result + destinationLocationRadiusInMeters.hashCode()
61+
result = 31 * result + loadPredictiveCacheForAlternativeRoutes.hashCode()
5062
return result
5163
}
5264

@@ -58,6 +70,7 @@ class PredictiveCacheLocationOptions private constructor(
5870
"currentLocationRadiusInMeters=$currentLocationRadiusInMeters, " +
5971
"routeBufferRadiusInMeters=$routeBufferRadiusInMeters, " +
6072
"destinationLocationRadiusInMeters=$destinationLocationRadiusInMeters" +
73+
"loadPredictiveCacheForAlternativeRoutes=$loadPredictiveCacheForAlternativeRoutes" +
6174
")"
6275
}
6376

@@ -69,6 +82,7 @@ class PredictiveCacheLocationOptions private constructor(
6982
private var currentLocationRadiusInMeters: Int = 20_000
7083
private var routeBufferRadiusInMeters: Int = 5_000
7184
private var destinationLocationRadiusInMeters: Int = 50_000
85+
private var loadPredictiveCacheForAlternativeRoutes: Boolean = false
7286

7387
/**
7488
* How far around the user's location we're going to cache, in meters. Defaults to 20000 (20 km)
@@ -88,6 +102,12 @@ class PredictiveCacheLocationOptions private constructor(
88102
fun destinationLocationRadiusInMeters(radiusInMeters: Int): Builder =
89103
apply { this.destinationLocationRadiusInMeters = radiusInMeters }
90104

105+
/**
106+
* Whether alternative routes will be loaded for predictive cache. Defaults to false.
107+
*/
108+
fun loadPredictiveCacheForAlternativeRoutes(load: Boolean): Builder =
109+
apply { this.loadPredictiveCacheForAlternativeRoutes = load }
110+
91111
/**
92112
* Build the [PredictiveCacheLocationOptions]
93113
*/
@@ -96,7 +116,17 @@ class PredictiveCacheLocationOptions private constructor(
96116
currentLocationRadiusInMeters = currentLocationRadiusInMeters,
97117
routeBufferRadiusInMeters = routeBufferRadiusInMeters,
98118
destinationLocationRadiusInMeters = destinationLocationRadiusInMeters,
119+
loadPredictiveCacheForAlternativeRoutes = loadPredictiveCacheForAlternativeRoutes,
99120
)
100121
}
101122
}
102123
}
124+
125+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
126+
fun PredictiveCacheLocationOptions.toPredictiveLocationTrackerOptions() =
127+
PredictiveLocationTrackerOptions(
128+
currentLocationRadiusInMeters,
129+
routeBufferRadiusInMeters,
130+
destinationLocationRadiusInMeters,
131+
loadPredictiveCacheForAlternativeRoutes,
132+
)

base/src/test/java/com/mapbox/navigation/base/options/PredictiveCacheLocationOptionsTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class PredictiveCacheLocationOptionsTest :
1212
.currentLocationRadiusInMeters(25000)
1313
.routeBufferRadiusInMeters(15000)
1414
.destinationLocationRadiusInMeters(55000)
15+
.loadPredictiveCacheForAlternativeRoutes(true)
1516

1617
@Test
1718
override fun trigger() {

base/src/test/java/com/mapbox/navigation/base/options/PredictiveCacheOptionsBuilderTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class PredictiveCacheOptionsBuilderTest :
2020
currentLocationRadiusInMeters(300)
2121
routeBufferRadiusInMeters(50)
2222
destinationLocationRadiusInMeters(20)
23+
loadPredictiveCacheForAlternativeRoutes(false)
2324
}.build(),
2425
)
2526
}.build(),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Expose PredictiveCacheLocationOptions.loadPredictiveCacheForAlternativeRoutes property

navigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigatorImpl.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.mapbox.navigation.base.internal.route.nativeRoute
1616
import com.mapbox.navigation.base.internal.utils.Constants
1717
import com.mapbox.navigation.base.options.PredictiveCacheLocationOptions
1818
import com.mapbox.navigation.base.options.PredictiveCacheNavigationOptions
19+
import com.mapbox.navigation.base.options.toPredictiveLocationTrackerOptions
1920
import com.mapbox.navigation.base.route.NavigationRoute
2021
import com.mapbox.navigation.navigator.internal.utils.toEvStateData
2122
import com.mapbox.navigation.utils.internal.ThreadController
@@ -42,7 +43,6 @@ import com.mapbox.navigator.Navigator
4243
import com.mapbox.navigator.NavigatorObserver
4344
import com.mapbox.navigator.PredictiveCacheController
4445
import com.mapbox.navigator.PredictiveCacheControllerOptions
45-
import com.mapbox.navigator.PredictiveLocationTrackerOptions
4646
import com.mapbox.navigator.RefreshRouteResult
4747
import com.mapbox.navigator.RerouteControllerInterface
4848
import com.mapbox.navigator.RerouteDetectorInterface
@@ -540,13 +540,6 @@ class MapboxNativeNavigatorImpl(
540540
}
541541
}
542542

543-
private fun PredictiveCacheLocationOptions.toPredictiveLocationTrackerOptions() =
544-
PredictiveLocationTrackerOptions(
545-
currentLocationRadiusInMeters,
546-
routeBufferRadiusInMeters,
547-
destinationLocationRadiusInMeters,
548-
)
549-
550543
override fun updateLaneSensorInfo(data: LaneSensorInfo) {
551544
inputsService.updateLaneSensorInfo(data)
552545
}

0 commit comments

Comments
 (0)