Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
VysotskiVadim committed Oct 24, 2023
1 parent 70a972f commit fd68f16
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ fun parseRouteInterfaces(
.flatten()
.sortedBy { routes.indexOf(it.nativeRoute) }
.let { ExpectedFactory.createValue(it) }
}
catch (ex: Exception) {
} catch (ex: Exception) {
when (ex) {
is JSONException,
is IllegalStateException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ interface RouteParsingManager {
): AlternativesParsingResult<T>
}

fun createRouteParsingManager(longRoutesOptimisationOptions: LongRoutesOptimisationOptions): RouteParsingManager {
fun createRouteParsingManager(
longRoutesOptimisationOptions: LongRoutesOptimisationOptions
): RouteParsingManager {
return when (longRoutesOptimisationOptions) {
LongRoutesOptimisationOptions.NoOptimisations -> NotOptimisedRoutesParsingManager()
is LongRoutesOptimisationOptions.OptimiseNavigationForLongRoutes -> OptimisedRoutesParsingManager(longRoutesOptimisationOptions)
is LongRoutesOptimisationOptions.OptimiseNavigationForLongRoutes ->
OptimisedRoutesParsingManager(longRoutesOptimisationOptions)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ sealed class LongRoutesOptimisationOptions {
*/
data class OptimiseNavigationForLongRoutes(
val responseToParseSizeBytes: Int,
): LongRoutesOptimisationOptions()
) : LongRoutesOptimisationOptions()

/**
* Default navigation behavior.
*/
object NoOptimisations: LongRoutesOptimisationOptions()
}
object NoOptimisations : LongRoutesOptimisationOptions()
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class NavigationRoute internal constructor(
expirationTimeElapsedSeconds,
)


companion object {

private const val LOG_CATEGORY = "NavigationRoute"
Expand Down Expand Up @@ -301,7 +300,9 @@ class NavigationRoute internal constructor(
directionsResponse.toBuilder().routes(
emptyList()
).build()
} else directionsResponse
} else {
directionsResponse
}
NavigationRoute(
responseToSaveInRoute,
index,
Expand Down Expand Up @@ -601,11 +602,14 @@ internal fun RouteInterface.toNavigationRoute(
): NavigationRoute {
val refreshTtl = directionsResponse.routes().getOrNull(routeIndex)?.refreshTtl()
val routeOptions = RouteOptions.fromUrl(URL(requestUri))
val response = if (optimiseDirectionsResponse) {
directionsResponse.toBuilder().routes(emptyList())
.build()
} else {
directionsResponse
}
return NavigationRoute(
directionsResponse = if (optimiseDirectionsResponse) {
directionsResponse.toBuilder().routes(emptyList())
.build()
} else directionsResponse,
directionsResponse = response,
routeOptions = routeOptions,
routeIndex = routeIndex,
directionsRoute = getDirectionsRoute(directionsResponse, routeIndex, routeOptions),
Expand Down Expand Up @@ -762,4 +766,4 @@ private fun getDirectionsRoute(
.requestUuid(response.uuid())
.routeIndex(routeIndex.toString())
.routeOptions(routeOptions)
.build()
.build()
Original file line number Diff line number Diff line change
Expand Up @@ -697,40 +697,44 @@ class RouteProgressExTest {
return com.mapbox.navigation.testing.factories.createNavigationRoutes(
DirectionsResponse.builder()
.waypoints(dirWaypoints)
.routes(listOf(DirectionsRoute.builder()
.duration(10.0)
.distance(distance)
.legs(
mutableListOf(
RouteLeg.builder()
.annotation(annotations)
.incidents(incidents)
.closures(closures)
.steps(List(2) { validStep })
.build()
).apply {
if (addLeg) {
add(
.routes(
listOf(
DirectionsRoute.builder()
.duration(10.0)
.distance(distance)
.legs(
mutableListOf(
RouteLeg.builder()
.annotation(annotations)
.incidents(incidents)
.closures(closures)
.steps(List(2) { validStep })
.build()
).apply {
if (addLeg) {
add(
RouteLeg.builder()
.annotation(annotations)
.incidents(incidents)
.closures(closures)
.steps(List(2) { validStep })
.build()
)
}
}
)
.geometry(
PolylineUtils.encode(
listOf(
Point.fromLngLat(11.22, 33.44),
Point.fromLngLat(23.34, 34.45)
),
5
)
}
}
)
.geometry(
PolylineUtils.encode(
listOf(
Point.fromLngLat(11.22, 33.44),
Point.fromLngLat(23.34, 34.45)
),
5
)
)
.build()
)
.build()))
)
.code("Ok")
.build(),
createRouteOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ private fun createParsingManager(
config
)


fun createParsingManagerWithoutOptimisations() =
createRouteParsingManager(LongRoutesOptimisationOptions.NoOptimisations)

Expand Down

0 comments on commit fd68f16

Please sign in to comment.