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 authored and VysotskiVadim committed May 17, 2023
1 parent 2f7cc7a commit 53e5e35
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 @@ -60,6 +60,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 @@ -663,9 +664,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 @@ -823,6 +826,12 @@ class MapboxRouteLineApi(
routeProgressUpdatesQueue.addJob(
CoalescingBlockingQueue.Item(
{
logI(
"Update with route progress. " +
"Leg index: ${routeProgress.currentLegProgress?.legIndex}, " +
"state: ${routeProgress.currentState}",
LOG_CATEGORY
)
val currentPrimaryRoute = primaryRoute
if (currentPrimaryRoute == null) {
val msg =
Expand All @@ -845,6 +854,12 @@ class MapboxRouteLineApi(
updateVanishingPointState(routeProgress.currentState)

val currentLegIndex = routeProgress.currentLegProgress?.legIndex
logI(
"Calculate routeLineMaskingLayerDynamicData. " +
"Leg index: ${routeProgress.currentLegProgress?.legIndex}, " +
"state: ${routeProgress.currentState}, activeLegIndex: $activeLegIndex",
LOG_CATEGORY
)
val routeLineMaskingLayerDynamicData =
when ((currentLegIndex ?: INVALID_ACTIVE_LEG_INDEX) != activeLegIndex) {
true -> getRouteLineDynamicDataForMaskingLayers(
Expand All @@ -855,6 +870,7 @@ class MapboxRouteLineApi(
}
val legChange = (currentLegIndex ?: 0) > activeLegIndex
activeLegIndex = currentLegIndex ?: 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 @@ -1036,6 +1052,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 @@ -1421,6 +1442,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 @@ -1653,10 +1675,18 @@ class MapboxRouteLineApi(
when (legsCount > 1) {
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 53e5e35

Please sign in to comment.