Horizon information
Request accessHorizon information
The HorizonManager provides information about upcoming road conditions, events, and attributes ahead of the vehicle.
Overview
HorizonManager provides functionality for:
- Observing upcoming road events
- Detecting speed cameras and enforcement zones
- Receiving traffic incident notifications
- Monitoring hazards (weather, road conditions, traffic)
- Tracking EV charging waypoints
Observable road events
The following specific road events can be observed through the HorizonManager:
Safety Location Events:
FixedSpeedCamera- Permanently installed speed camerasMobileCamera- Temporary or mobile speed enforcementSpeedEnforcement- Speed enforcement zones with multiple camerasRedLightCamera- Red light enforcement systemsAverageSpeedArea- Average speed monitoring zonesFixedDangerZone- Fixed camera danger zonesMobileRiskZone- Mobile camera risk zonesRestricted- Access-restricted areas
Traffic Events:
TrafficJamEvent- Traffic congestionRoadWorkEvent- Road construction and maintenanceRoadClosureEvent- Closed roads
Traffic Hazard Events:
AccidentEvent- Traffic accidentsBrokenDownVehicleEvent- Disabled vehiclesWrongWayDriverEvent- Wrong-way driver warnings
Weather Hazard Events:
ReducedVisibilityEvent- Poor visibility (fog, heavy rain)SlipperyRoadEvent- Slippery road conditionsStrongWindEvent- Strong wind areas
Road Hazard Events:
BadRoadConditionsEvent- Poor road surface conditionsObjectsOnRoadEvent- Objects or obstacles on the road (animals, people)
Other Events:
RailroadCrossingEvent- Railroad crossingsEvWaypointEvent- EV charging waypointsGenericHazardEvent- Unclassified hazardsInformativeDirectionEvent- Directional information (highway exits, intersections)PoiEvent- Points of interest
Observing horizon events
Subscribe to receive updates about upcoming road events:
import android.util.Logimport com.tomtom.automotive.integration.client.api.horizon.HorizonManagerimport com.tomtom.automotive.integration.client.api.horizon.observehorizonevent.HorizonEventsListenerimport com.tomtom.automotive.integration.client.api.horizon.observehorizonevent.HorizonInfoimport com.tomtom.automotive.integration.client.common.Callbackimport com.tomtom.automotive.integration.client.common.SdkReleasable
private const val TAG = "HorizonExample"private var observeHorizonEventsReleasable: SdkReleasable? = null
fun observeHorizonEvents(horizonManager: HorizonManager) { observeHorizonEventsReleasable = horizonManager.observeHorizonEvents( object : HorizonEventsListener { override fun onHorizonEventsChanged(horizonInfo: HorizonInfo) { Log.d(TAG, "Horizon events updated: $horizonInfo")
horizonInfo.horizonEvents.forEach { event -> val distanceMeters = event.distanceToEntryPoint.inMeters() Log.d(TAG, "Event: ${event::class.simpleName} in ${distanceMeters}m") } }
override fun onFunctionalityUnavailable(reason: Callback.Reason) { Log.e(TAG, "Horizon events unavailable: ${reason.devMessage}") } } )}
fun stopObservingHorizonEvents() { observeHorizonEventsReleasable?.release() observeHorizonEventsReleasable = null}HorizonInfo structure
The HorizonInfo object contains:
horizonEvents- List of upcoming road events
Each event is a specific type implementing the HorizonEvent sealed interface:
distanceToEntryPoint- Distance to the start of the event
Processing event types
Handle different types of horizon events using Kotlin’s when expression:
import android.util.Logimport com.tomtom.automotive.integration.client.api.model.horizon.HorizonEvent
private const val TAG = "HorizonExample"
private fun processHorizonEvent(event: HorizonEvent) { val distanceMeters = event.distanceToEntryPoint.inMeters()
when (event) { is HorizonEvent.FixedSpeedCamera -> { val speedLimitKmh = event.speedLimit.inKilometersPerHour() Log.d(TAG, "Fixed speed camera ahead: $speedLimitKmh km/h limit in ${distanceMeters}m") } is HorizonEvent.MobileCamera -> { val speedLimitKmh = event.speedLimit.inKilometersPerHour() Log.d(TAG, "Mobile speed camera ahead: $speedLimitKmh km/h limit in ${distanceMeters}m") } is HorizonEvent.SpeedEnforcement -> { val speedLimitKmh = event.speedLimit.inKilometersPerHour() val exitDistanceMeters = event.distanceToExitPoint.inMeters() val zoneLength = exitDistanceMeters - distanceMeters Log.d(TAG, "Speed enforcement zone: $speedLimitKmh km/h for ${zoneLength}m, starting in ${distanceMeters}m") } is HorizonEvent.TrafficJamEvent -> { val delaySeconds = event.delay.inSeconds() Log.d(TAG, "Traffic jam ahead in ${distanceMeters}m, delay: ${delaySeconds}s") } is HorizonEvent.RoadWorkEvent -> { val delaySeconds = event.delay.inSeconds() Log.d(TAG, "Road work ahead in ${distanceMeters}m, delay: ${delaySeconds}s") } is HorizonEvent.RailroadCrossingEvent -> { Log.d(TAG, "Railroad crossing ahead in ${distanceMeters}m") } is HorizonEvent.EvWaypointEvent -> { Log.d(TAG, "EV charging waypoint ahead in ${distanceMeters}m") } is HorizonEvent.AccidentEvent -> { Log.d(TAG, "Accident ahead in ${distanceMeters}m") } is HorizonEvent.SlipperyRoadEvent -> { Log.d(TAG, "Slippery road ahead in ${distanceMeters}m") } is HorizonEvent.StrongWindEvent -> { Log.d(TAG, "Strong wind area ahead in ${distanceMeters}m") } else -> { Log.d(TAG, "Other event: ${event::class.simpleName} in ${distanceMeters}m") } }}EV waypoint events
Track charging stops along the route. Charging stations are categorized by their power output:
| Category | Power Range | Example |
|---|---|---|
SLOW | < 12 kW | 10 kW charger |
REGULAR | 12 kW - 49 kW | 20 kW charger |
FAST | ≥ 50 kW | 70 kW charger |
import android.util.Logimport com.tomtom.automotive.integration.client.api.model.horizon.ChargingStopTypeimport com.tomtom.automotive.integration.client.api.model.horizon.HorizonEvent
private const val TAG = "HorizonExample"
private fun handleEvWaypoint(event: HorizonEvent.EvWaypointEvent, distanceMeters: Double) { val chargingType = event.chargingStopType
val chargerDescription = when (chargingType) { ChargingStopType.FAST -> "Fast charger (≥50 kW)" ChargingStopType.REGULAR -> "Regular charger (12-49 kW)" ChargingStopType.SLOW -> "Slow charger (<12 kW)" ChargingStopType.UNHANDLED -> "Charging station" }
Log.d(TAG, "$chargerDescription ahead in ${distanceMeters}m")}Hazard events
Handle weather and road hazards:
import android.util.Logimport com.tomtom.automotive.integration.client.api.model.horizon.HorizonEventimport com.tomtom.automotive.integration.client.api.model.horizon.ReducedVisibilityReason
private const val TAG = "HorizonExample"
private fun processHazardEvents(event: HorizonEvent) { when (event) { is HorizonEvent.ReducedVisibilityEvent -> { val reasons = event.reasons.joinToString { reason -> when (reason) { ReducedVisibilityReason.FOG -> "fog" ReducedVisibilityReason.HEAVY_RAIN -> "heavy rain" ReducedVisibilityReason.UNHANDLED -> "reduced visibility" } } Log.d(TAG, "Reduced visibility ahead due to: $reasons") } is HorizonEvent.SlipperyRoadEvent -> { Log.d(TAG, "Slippery road conditions ahead") } is HorizonEvent.StrongWindEvent -> { Log.d(TAG, "Strong wind area ahead") } is HorizonEvent.BadRoadConditionsEvent -> { Log.d(TAG, "Bad road conditions ahead") } is HorizonEvent.ObjectsOnRoadEvent -> { Log.d(TAG, "Objects on road ahead") } is HorizonEvent.BrokenDownVehicleEvent -> { Log.d(TAG, "Broken down vehicle ahead") } is HorizonEvent.WrongWayDriverEvent -> { Log.d(TAG, "Wrong way driver reported ahead") } else -> { } }}