From c72bbac9b70f3e82377054b58c00f07d0aa68e46 Mon Sep 17 00:00:00 2001 From: Ellen Poe Date: Tue, 2 Dec 2025 12:37:22 -0800 Subject: [PATCH] refactor: move literals in FerrostarWrapper.kt to companion object --- .../maps/cardinal/routing/FerrostarWrapper.kt | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/cardinal-android/app/src/main/java/earth/maps/cardinal/routing/FerrostarWrapper.kt b/cardinal-android/app/src/main/java/earth/maps/cardinal/routing/FerrostarWrapper.kt index 3492023..e37001d 100644 --- a/cardinal-android/app/src/main/java/earth/maps/cardinal/routing/FerrostarWrapper.kt +++ b/cardinal-android/app/src/main/java/earth/maps/cardinal/routing/FerrostarWrapper.kt @@ -121,11 +121,11 @@ class FerrostarWrapper( httpClient = OkHttpClientProvider(OkHttpClient()), locationProvider = locationProvider, navigationControllerConfig = NavigationControllerConfig( - waypointAdvance = WaypointAdvanceMode.WaypointWithinRange(100.0), - stepAdvanceCondition = stepAdvanceDistanceEntryAndExit(30u, 5u, 32u), - arrivalStepAdvanceCondition = stepAdvanceDistanceToEndOfStep(30u, 32u), - routeDeviationTracking = RouteDeviationTracking.StaticThreshold(15U, 50.0), - snappedLocationCourseFiltering = CourseFiltering.SNAP_TO_ROUTE + waypointAdvance = WaypointAdvanceMode.WaypointWithinRange(WAYPOINT_ADVANCE_RANGE), + stepAdvanceCondition = stepAdvanceDistanceEntryAndExit(STEP_ADVANCE_DISTANCE_TO_END.toUShort(), STEP_ADVANCE_DISTANCE_AFTER_END.toUShort(), STEP_ADVANCE_MINIMUM_HORIZONTAL_ACCURACY.toUShort()), + arrivalStepAdvanceCondition = stepAdvanceDistanceToEndOfStep(ARRIVAL_STEP_ADVANCE_DISTANCE.toUShort(), ARRIVAL_STEP_ADVANCE_MINIMUM_HORIZONTAL_ACCURACY.toUShort()), + routeDeviationTracking = RouteDeviationTracking.StaticThreshold(ROUTE_DEVIATION_MINIMUM_ACCURACY.toUShort(), ROUTE_DEVIATION_MAX_DEVIATION), + snappedLocationCourseFiltering = COURSE_FILTERING ), foregroundServiceManager = foregroundServiceManager, ) @@ -152,14 +152,27 @@ class FerrostarWrapper( httpClient = OkHttpClientProvider(OkHttpClient()), locationProvider = locationProvider, navigationControllerConfig = NavigationControllerConfig( - waypointAdvance = WaypointAdvanceMode.WaypointWithinRange(100.0), - stepAdvanceCondition = stepAdvanceDistanceEntryAndExit(30u, 5u, 32u), - arrivalStepAdvanceCondition = stepAdvanceDistanceToEndOfStep(30u, 32u), - routeDeviationTracking = RouteDeviationTracking.StaticThreshold(15U, 50.0), - snappedLocationCourseFiltering = CourseFiltering.SNAP_TO_ROUTE + waypointAdvance = WaypointAdvanceMode.WaypointWithinRange(WAYPOINT_ADVANCE_RANGE), + stepAdvanceCondition = stepAdvanceDistanceEntryAndExit(STEP_ADVANCE_DISTANCE_TO_END.toUShort(), STEP_ADVANCE_DISTANCE_AFTER_END.toUShort(), STEP_ADVANCE_MINIMUM_HORIZONTAL_ACCURACY.toUShort()), + arrivalStepAdvanceCondition = stepAdvanceDistanceToEndOfStep(ARRIVAL_STEP_ADVANCE_DISTANCE.toUShort(), ARRIVAL_STEP_ADVANCE_MINIMUM_HORIZONTAL_ACCURACY.toUShort()), + routeDeviationTracking = RouteDeviationTracking.StaticThreshold(ROUTE_DEVIATION_MINIMUM_ACCURACY.toUShort(), ROUTE_DEVIATION_MAX_DEVIATION), + snappedLocationCourseFiltering = COURSE_FILTERING ), foregroundServiceManager = foregroundServiceManager ) core.spokenInstructionObserver = androidTtsObserver } + + companion object { + const val WAYPOINT_ADVANCE_RANGE = 100.0 + const val STEP_ADVANCE_DISTANCE_TO_END = 30u + const val STEP_ADVANCE_DISTANCE_AFTER_END = 5u + const val STEP_ADVANCE_MINIMUM_HORIZONTAL_ACCURACY = 32u + const val ARRIVAL_STEP_ADVANCE_DISTANCE = 30u + const val ARRIVAL_STEP_ADVANCE_MINIMUM_HORIZONTAL_ACCURACY = 32u + const val ROUTE_DEVIATION_MINIMUM_ACCURACY = 15u + const val ROUTE_DEVIATION_MAX_DEVIATION = 50.0 + val COURSE_FILTERING = CourseFiltering.SNAP_TO_ROUTE + + } } -- GitLab