Skip to content

Commit

Permalink
add experimental route line logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dzinad committed Apr 28, 2023
1 parent 9da2a96 commit 0d86931
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle/artifact-settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ext {
mapboxArtifactLicenseUrl = 'https://www.mapbox.com/legal/tos/'
snapshot = project.hasProperty("snapshot") ? project.property("snapshot").toBoolean() : false
releaseTagPrefix = project.hasProperty('RELEASE_TAG_PREFIX') ? project.property('RELEASE_TAG_PREFIX') : 'v'
versionName = getVersionName()
versionName = '2.13.0-route-line-SNAPSHOT'
}

def getVersionName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import com.mapbox.navigation.ui.maps.util.CacheResultUtils.cacheResult
import com.mapbox.navigation.ui.utils.internal.ifNonNull
import com.mapbox.navigation.utils.internal.InternalJobControlFactory
import com.mapbox.navigation.utils.internal.logE
import com.mapbox.navigation.utils.internal.logI
import com.mapbox.navigation.utils.internal.logW
import com.mapbox.navigation.utils.internal.parallelMap
import kotlinx.coroutines.Deferred
Expand Down Expand Up @@ -637,9 +638,11 @@ class MapboxRouteLineApi(
lastLocationPoint = null
routeLineOptions.vanishingRouteLine?.vanishPointOffset = 0.0
activeLegIndex = INVALID_ACTIVE_LEG_INDEX
logI("Updated leg index to $activeLegIndex (from clearRouteLine)", LOG_CATEGORY)
routes.clear()
routeFeatureData.clear()
routeLineExpressionData = emptyList()
logI("Cleared route line expression data (from clearRouteLine)", LOG_CATEGORY)
resetCaches()

consumer.accept(
Expand Down Expand Up @@ -794,6 +797,12 @@ class MapboxRouteLineApi(
routeProgress: RouteProgress,
consumer: MapboxNavigationConsumer<Expected<RouteLineError, RouteLineUpdateValue>>
) {
logI(
"Update with route progress. " +
"Leg index: ${routeProgress.currentLegProgress?.legIndex}, " +
"state: ${routeProgress.currentState}",
LOG_CATEGORY
)
val currentPrimaryRoute = primaryRoute
if (currentPrimaryRoute == null) {
val msg = "You're calling #updateWithRouteProgress without any routes being set."
Expand All @@ -816,6 +825,12 @@ class MapboxRouteLineApi(
updateUpcomingRoutePointIndex(routeProgress)
updateVanishingPointState(routeProgress.currentState)

logI(
"Calculate routeLineMaskingLayerDynamicData. " +
"Leg index: ${routeProgress.currentLegProgress?.legIndex}, " +
"state: ${routeProgress.currentState}, activeLegIndex: $activeLegIndex",
LOG_CATEGORY
)
val routeLineMaskingLayerDynamicData = when (
(routeProgress.currentLegProgress?.legIndex ?: INVALID_ACTIVE_LEG_INDEX) !=
activeLegIndex
Expand All @@ -825,6 +840,7 @@ class MapboxRouteLineApi(
}
val legChange = (routeProgress.currentLegProgress?.legIndex ?: 0) > activeLegIndex
activeLegIndex = routeProgress.currentLegProgress?.legIndex ?: INVALID_ACTIVE_LEG_INDEX
logI("Update leg index to $activeLegIndex (from route progress update)", LOG_CATEGORY)

// If the de-emphasize inactive route legs feature is enabled and the vanishing route line
// feature is enabled and the active leg index has changed, then calling the
Expand Down Expand Up @@ -987,6 +1003,11 @@ class MapboxRouteLineApi(
return ifNonNull(route, routeProgress.currentLegProgress) { navRoute, currentLegProgress ->
val numLegs = navRoute.directionsRoute.legs()?.size ?: 0
val legIndex = currentLegProgress.legIndex
logI(
"getRouteLineDynamicDataForMaskingLayers for legIndex: $legIndex, " +
"numLegs: $numLegs, data size: ${routeLineExpressionData.size}",
LOG_CATEGORY
)
if (numLegs > 1 && legIndex < numLegs) {
getRouteLineDynamicDataForMaskingLayers(routeLineExpressionData, legIndex)
} else {
Expand Down Expand Up @@ -1371,6 +1392,7 @@ class MapboxRouteLineApi(
primaryRoute = distinctNewRoutes.firstOrNull()
MapboxRouteLineUtils.trimRouteDataCacheToSize(size = distinctNewRoutes.size)
this.activeLegIndex = INVALID_ACTIVE_LEG_INDEX
logI("Updated activeLegIndex to $activeLegIndex (from setNewRouteData)", LOG_CATEGORY)

preWarmRouteCaches(
distinctNewRoutes,
Expand Down Expand Up @@ -1604,10 +1626,18 @@ class MapboxRouteLineApi(
) {
true -> {
routeLineExpressionData = deferred.await()
logI(
"Inited route line expression data: ${routeLineExpressionData.size} sync",
LOG_CATEGORY
)
}
false -> {
jobControl.scope.launch(Dispatchers.Main) {
routeLineExpressionData = deferred.await()
logI(
"Inited route line expression data: ${routeLineExpressionData.size} async",
LOG_CATEGORY
)
}
}
}
Expand Down

0 comments on commit 0d86931

Please sign in to comment.