Skip to content

Commit dad2fa0

Browse files
DzmitryFomchyngithub-actions[bot]
authored andcommitted
Support ADAS tiles loading (#8855)
GitOrigin-RevId: 4856155e079618989364819d25086e7edb1a1b09
1 parent dbb0c8a commit dad2fa0

File tree

4 files changed

+115
-8
lines changed

4 files changed

+115
-8
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- `TilesetDescriptorFactory#build` and `TilesetDescriptorFactory#getSpecificVersion` function now provide overloaded variants that accept a flag whether ADAS tiles should be loaded.

navigation/api/current.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,13 @@ package com.mapbox.navigation.core.navigator {
628628
method public com.mapbox.common.TilesetDescriptor build(String? tilesDataset = null, String? tilesProfile = null);
629629
method public com.mapbox.common.TilesetDescriptor build(String? tilesDataset = null);
630630
method public com.mapbox.common.TilesetDescriptor build();
631+
method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public com.mapbox.common.TilesetDescriptor build(String? tilesDataset = null, String? tilesProfile = null, String? tilesVersion = null, boolean includeAdas);
632+
method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public com.mapbox.common.TilesetDescriptor build(String? tilesDataset = null, String? tilesProfile = null, boolean includeAdas);
633+
method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public com.mapbox.common.TilesetDescriptor build(String? tilesDataset = null, boolean includeAdas);
634+
method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public com.mapbox.common.TilesetDescriptor build(boolean includeAdas);
631635
method public com.mapbox.common.TilesetDescriptor getLatest();
632636
method public com.mapbox.common.TilesetDescriptor getSpecificVersion(String tilesVersion);
637+
method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public com.mapbox.common.TilesetDescriptor getSpecificVersion(String tilesVersion, boolean includeAdas);
633638
}
634639

635640
public final class TilesetDescriptorFactoryKt {

navigation/src/main/java/com/mapbox/navigation/core/navigator/TilesetDescriptorFactory.kt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.mapbox.navigation.core.navigator
22

33
import com.mapbox.common.TilesetDescriptor
4+
import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
45
import com.mapbox.navigation.base.options.RoutingTilesOptions
56
import com.mapbox.navigator.CacheHandle
67

@@ -38,6 +39,33 @@ class TilesetDescriptorFactory internal constructor(
3839
tilesVersion ?: routingTilesOptions.tilesVersion,
3940
)
4041

42+
/**
43+
* Creates TilesetDescriptor using the specified dataset, profile and version.
44+
*
45+
* @param tilesDataset string built out of `<account>[.<graph>]` variables.
46+
* Account can be `mapbox` for default datasets or your username for other.
47+
* Graph can be left blank if you don't target any custom datasets.
48+
* If null [RoutingTilesOptions.tilesDataset] will be used.
49+
* @param tilesProfile profile of the dataset.
50+
* If null [RoutingTilesOptions.tilesProfile] will be used.
51+
* @param tilesVersion tiles version
52+
* If null [RoutingTilesOptions.tilesVersion] will be used.
53+
* @param includeAdas Whether to include ADAS tiles.
54+
*/
55+
@ExperimentalPreviewMapboxNavigationAPI
56+
@JvmOverloads
57+
fun build(
58+
tilesDataset: String? = null,
59+
tilesProfile: String? = null,
60+
tilesVersion: String? = null,
61+
includeAdas: Boolean,
62+
): TilesetDescriptor =
63+
nativeFactoryWrapper.build(
64+
combineDatasetWithProfile(tilesDataset, tilesProfile),
65+
tilesVersion ?: routingTilesOptions.tilesVersion,
66+
includeAdas,
67+
)
68+
4169
/**
4270
* Gets TilesetDescriptor which corresponds to the currently used routing tiles dataset
4371
* and the specified `tilesVersion`.
@@ -46,6 +74,16 @@ class TilesetDescriptorFactory internal constructor(
4674
fun getSpecificVersion(tilesVersion: String): TilesetDescriptor =
4775
nativeFactoryWrapper.getSpecificVersion(cache, tilesVersion)
4876

77+
/**
78+
* Gets TilesetDescriptor which corresponds to the currently used routing tiles dataset
79+
* and the specified `tilesVersion`.
80+
* @param tilesVersion TilesetDescriptor version
81+
* @param includeAdas Whether to include ADAS tiles.
82+
*/
83+
@ExperimentalPreviewMapboxNavigationAPI
84+
fun getSpecificVersion(tilesVersion: String, includeAdas: Boolean): TilesetDescriptor =
85+
nativeFactoryWrapper.getSpecificVersion(cache, tilesVersion, includeAdas)
86+
4987
/**
5088
* Gets TilesetDescriptor which corresponds to the latest available version of routing tiles.
5189
*/
@@ -69,12 +107,24 @@ class TilesetDescriptorFactory internal constructor(
69107
tilesVersion: String,
70108
): TilesetDescriptor
71109

110+
fun getSpecificVersion(
111+
cache: CacheHandle,
112+
tilesVersion: String,
113+
includeAdas: Boolean,
114+
): TilesetDescriptor
115+
72116
fun getLatest(cache: CacheHandle): TilesetDescriptor
73117

74118
fun build(
75119
tilesDatasetAndProfile: String,
76120
tilesVersion: String,
77121
): TilesetDescriptor
122+
123+
fun build(
124+
tilesDatasetAndProfile: String,
125+
tilesVersion: String,
126+
includeAdas: Boolean,
127+
): TilesetDescriptor
78128
}
79129

80130
internal class NativeFactoryWrapperImpl : NativeFactoryWrapper {
@@ -89,6 +139,18 @@ class TilesetDescriptorFactory internal constructor(
89139
)
90140
}
91141

142+
override fun getSpecificVersion(
143+
cache: CacheHandle,
144+
tilesVersion: String,
145+
includeAdas: Boolean,
146+
): TilesetDescriptor {
147+
return NativeTilesetDescriptorFactory.getSpecificVersion(
148+
cache,
149+
tilesVersion,
150+
includeAdas,
151+
)
152+
}
153+
92154
override fun getLatest(cache: CacheHandle): TilesetDescriptor {
93155
return NativeTilesetDescriptorFactory.getLatest(cache)
94156
}
@@ -102,5 +164,17 @@ class TilesetDescriptorFactory internal constructor(
102164
tilesVersion,
103165
)
104166
}
167+
168+
override fun build(
169+
tilesDatasetAndProfile: String,
170+
tilesVersion: String,
171+
includeAdas: Boolean,
172+
): TilesetDescriptor {
173+
return NativeTilesetDescriptorFactory.build(
174+
tilesDatasetAndProfile,
175+
tilesVersion,
176+
includeAdas,
177+
)
178+
}
105179
}
106180
}

navigation/src/test/java/com/mapbox/navigation/core/navigator/TilesDescriptorFactoryTest.kt

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mapbox.navigation.core.navigator
22

3+
import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
34
import com.mapbox.navigation.base.options.RoutingTilesOptions
45
import com.mapbox.navigation.core.navigator.TilesetDescriptorFactory.NativeFactoryWrapper
56
import com.mapbox.navigator.CacheHandle
@@ -9,6 +10,7 @@ import io.mockk.verify
910
import org.junit.Before
1011
import org.junit.Test
1112

13+
@OptIn(ExperimentalPreviewMapboxNavigationAPI::class)
1214
class TilesDescriptorFactoryTest {
1315

1416
private val routingTilesOptions: RoutingTilesOptions = mockk(relaxed = true)
@@ -27,37 +29,62 @@ class TilesDescriptorFactoryTest {
2729

2830
@Test
2931
fun checkBuildWithParams() {
30-
tilesetDescriptorFactory.build(DATASET, PROFILE, VERSION)
32+
tilesetDescriptorFactory.build(DATASET, PROFILE, VERSION, true)
3133

3234
verify {
33-
nativeFactoryWrapper.build("$DATASET/$PROFILE", VERSION)
35+
nativeFactoryWrapper.build("$DATASET/$PROFILE", VERSION, true)
3436
}
3537
}
3638

3739
@Test
3840
fun checkBuildWithDefaultDataset() {
39-
tilesetDescriptorFactory.build(tilesProfile = PROFILE, tilesVersion = VERSION)
41+
tilesetDescriptorFactory.build(
42+
tilesProfile = PROFILE,
43+
tilesVersion = VERSION,
44+
includeAdas = true,
45+
)
4046

4147
verify {
42-
nativeFactoryWrapper.build("$OPTIONS_DATASET/$PROFILE", VERSION)
48+
nativeFactoryWrapper.build("$OPTIONS_DATASET/$PROFILE", VERSION, true)
4349
}
4450
}
4551

4652
@Test
4753
fun checkBuildWithDefaultProfile() {
48-
tilesetDescriptorFactory.build(tilesDataset = DATASET, tilesVersion = VERSION)
54+
tilesetDescriptorFactory.build(
55+
tilesDataset = DATASET,
56+
tilesVersion = VERSION,
57+
includeAdas = true,
58+
)
4959

5060
verify {
51-
nativeFactoryWrapper.build("$DATASET/$OPTIONS_PROFILE", VERSION)
61+
nativeFactoryWrapper.build("$DATASET/$OPTIONS_PROFILE", VERSION, true)
5262
}
5363
}
5464

5565
@Test
5666
fun checkBuildWithDefaultVersion() {
57-
tilesetDescriptorFactory.build(tilesDataset = DATASET, tilesProfile = PROFILE)
67+
tilesetDescriptorFactory.build(
68+
tilesDataset = DATASET,
69+
tilesProfile = PROFILE,
70+
includeAdas = true,
71+
)
72+
73+
verify {
74+
nativeFactoryWrapper.build("$DATASET/$PROFILE", OPTIONS_VERSION, true)
75+
}
76+
}
77+
78+
@Test
79+
fun checkBuildWithDefaultAdasis() {
80+
tilesetDescriptorFactory.build(
81+
tilesDataset = DATASET,
82+
tilesProfile = PROFILE,
83+
tilesVersion = VERSION,
84+
)
5885

5986
verify {
60-
nativeFactoryWrapper.build("$DATASET/$PROFILE", OPTIONS_VERSION)
87+
nativeFactoryWrapper.build("$DATASET/$PROFILE", VERSION)
6188
}
6289
}
6390

0 commit comments

Comments
 (0)