Skip to Content
API ReferenceRoutingRoutingStatusRepository

RoutingStatusRepository

class RoutingStatusRepository(locationRepository: LocationMergedRepository, externalScope: CoroutineScope, targetTolerance: Double = 2.0, compassDataSource: CompassDataSource? = null, customSharingStarted: SharingStarted = SharingStarted.WhileSubscribed(5000), replay: Int = 4)

Calculates navigation status based on user location and active route.

Why this repository exists: During navigation, the app needs to know:

  • Is the user on-route or off-route?
  • Which route step is the user currently on?
  • Has the user reached the destination?
  • Is the user approaching a turn or checkpoint?

This repository consumes location updates from LocationMergedRepository and produces navigation status information, enabling turn-by-turn guidance and route visualization.

How navigation status works:

  • ON_ROUTE: User is following the route correctly (within tolerance)
  • OUT_OF_ROUTE: User has deviated significantly from the route
  • FINISHED: User has reached the destination
  • NO_ROUTE: No route is set, or user hasn’t started navigation yet

Step tracking: The repository tracks which route step the user is on by:

  • Finding the nearest route step to the user’s current position
  • Validating that the user is within the step’s polyline
  • Handling floor transitions (indoor navigation)
  • Detecting when user advances to the next step

Tolerance handling: The targetTolerance parameter controls how far the user can deviate from the route before being considered “off-route”. This accounts for:

  • GPS/beacon accuracy limitations
  • Natural walking variations
  • Indoor vs outdoor differences (indoor tolerance is typically tighter)

Compass integration: When CompassDataSource is provided, heading information is combined with location to provide bearing-aware navigation status. This enables features like “turn right in 50 meters” with proper direction indication.

Flow behavior: The locatorResultFlow emits PositionCallbackData containing both location and routing status. This flow:

  • Replays the last few values to new subscribers (configurable via replay)
  • Shares across multiple collectors efficiently
  • Handles lifecycle properly (stops when no subscribers)

When to use: This is the primary interface for navigation features. Use it to:

  • Display turn-by-turn instructions
  • Show route progress
  • Detect when user goes off-route
  • Provide navigation feedback to users

Constructors

RoutingStatusRepositoryconstructor(locationRepository: LocationMergedRepository, externalScope: CoroutineScope, targetTolerance: Double  = 2.0, compassDataSource: CompassDataSource? = null, customSharingStarted: SharingStarted = SharingStarted.WhileSubscribed(5000), replay: Int  = 4)

Types

NameSummary
Companionobject Companion

Properties

locatorResultFlow

val locatorResultFlow: SharedFlow<PositionCallbackData?>

Types: PositionCallbackData

Functions

setRoute

fun setRoute(route: SdkRoute?)

Types: SdkRoute

Sets the active route for navigation status calculation.

simulateBeacons

fun simulateBeacons(targetList: List<String>)

Simulates beacon detection for testing/development.

Last updated on