11package 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 */
1014class 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+ )
0 commit comments