Horizon information
Horizon 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:
1import android.util.Log2import com.tomtom.automotive.integration.client.api.horizon.HorizonManager3import com.tomtom.automotive.integration.client.api.horizon.observehorizonevent.HorizonEventsListener4import com.tomtom.automotive.integration.client.api.horizon.observehorizonevent.HorizonInfo5import com.tomtom.automotive.integration.client.common.Callback6import com.tomtom.automotive.integration.client.common.SdkReleasable78private const val TAG = "HorizonExample"9private var observeHorizonEventsReleasable: SdkReleasable? = null1011fun observeHorizonEvents(horizonManager: HorizonManager) {12 observeHorizonEventsReleasable = horizonManager.observeHorizonEvents(13 object : HorizonEventsListener {14 override fun onHorizonEventsChanged(horizonInfo: HorizonInfo) {15 Log.d(TAG, "Horizon events updated: $horizonInfo")1617 horizonInfo.horizonEvents.forEach { event ->18 val distanceMeters = event.distanceToEntryPoint.inMeters()19 Log.d(TAG, "Event: ${event::class.simpleName} in ${distanceMeters}m")20 }21 }2223 override fun onFunctionalityUnavailable(reason: Callback.Reason) {24 Log.e(TAG, "Horizon events unavailable: ${reason.devMessage}")25 }26 }27 )28}2930fun stopObservingHorizonEvents() {31 observeHorizonEventsReleasable?.release()32 observeHorizonEventsReleasable = null33}
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:
1import android.util.Log2import com.tomtom.automotive.integration.client.api.model.horizon.HorizonEvent34private const val TAG = "HorizonExample"56private fun processHorizonEvent(event: HorizonEvent) {7 val distanceMeters = event.distanceToEntryPoint.inMeters()89 when (event) {10 is HorizonEvent.FixedSpeedCamera -> {11 val speedLimitKmh = event.speedLimit.inKilometersPerHour()12 Log.d(TAG, "Fixed speed camera ahead: $speedLimitKmh km/h limit in ${distanceMeters}m")13 }14 is HorizonEvent.MobileCamera -> {15 val speedLimitKmh = event.speedLimit.inKilometersPerHour()16 Log.d(TAG, "Mobile speed camera ahead: $speedLimitKmh km/h limit in ${distanceMeters}m")17 }18 is HorizonEvent.SpeedEnforcement -> {19 val speedLimitKmh = event.speedLimit.inKilometersPerHour()20 val exitDistanceMeters = event.distanceToExitPoint.inMeters()21 val zoneLength = exitDistanceMeters - distanceMeters22 Log.d(TAG, "Speed enforcement zone: $speedLimitKmh km/h for ${zoneLength}m, starting in ${distanceMeters}m")23 }24 is HorizonEvent.TrafficJamEvent -> {25 val delaySeconds = event.delay.inSeconds()26 Log.d(TAG, "Traffic jam ahead in ${distanceMeters}m, delay: ${delaySeconds}s")27 }28 is HorizonEvent.RoadWorkEvent -> {29 val delaySeconds = event.delay.inSeconds()30 Log.d(TAG, "Road work ahead in ${distanceMeters}m, delay: ${delaySeconds}s")31 }32 is HorizonEvent.RailroadCrossingEvent -> {33 Log.d(TAG, "Railroad crossing ahead in ${distanceMeters}m")34 }35 is HorizonEvent.EvWaypointEvent -> {36 Log.d(TAG, "EV charging waypoint ahead in ${distanceMeters}m")37 }38 is HorizonEvent.AccidentEvent -> {39 Log.d(TAG, "Accident ahead in ${distanceMeters}m")40 }41 is HorizonEvent.SlipperyRoadEvent -> {42 Log.d(TAG, "Slippery road ahead in ${distanceMeters}m")43 }44 is HorizonEvent.StrongWindEvent -> {45 Log.d(TAG, "Strong wind area ahead in ${distanceMeters}m")46 }47 else -> {48 Log.d(TAG, "Other event: ${event::class.simpleName} in ${distanceMeters}m")49 }50 }51}
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 |
1import android.util.Log2import com.tomtom.automotive.integration.client.api.model.horizon.ChargingStopType3import com.tomtom.automotive.integration.client.api.model.horizon.HorizonEvent45private const val TAG = "HorizonExample"67private fun handleEvWaypoint(event: HorizonEvent.EvWaypointEvent, distanceMeters: Double) {8 val chargingType = event.chargingStopType910 val chargerDescription = when (chargingType) {11 ChargingStopType.FAST -> "Fast charger (≥50 kW)"12 ChargingStopType.REGULAR -> "Regular charger (12-49 kW)"13 ChargingStopType.SLOW -> "Slow charger (<12 kW)"14 ChargingStopType.UNHANDLED -> "Charging station"15 }1617 Log.d(TAG, "$chargerDescription ahead in ${distanceMeters}m")18}
Hazard events
Handle weather and road hazards:
1import android.util.Log2import com.tomtom.automotive.integration.client.api.model.horizon.HorizonEvent3import com.tomtom.automotive.integration.client.api.model.horizon.ReducedVisibilityReason45private const val TAG = "HorizonExample"67private fun processHazardEvents(event: HorizonEvent) {8 when (event) {9 is HorizonEvent.ReducedVisibilityEvent -> {10 val reasons = event.reasons.joinToString { reason ->11 when (reason) {12 ReducedVisibilityReason.FOG -> "fog"13 ReducedVisibilityReason.HEAVY_RAIN -> "heavy rain"14 ReducedVisibilityReason.UNHANDLED -> "reduced visibility"15 }16 }17 Log.d(TAG, "Reduced visibility ahead due to: $reasons")18 }19 is HorizonEvent.SlipperyRoadEvent -> {20 Log.d(TAG, "Slippery road conditions ahead")21 }22 is HorizonEvent.StrongWindEvent -> {23 Log.d(TAG, "Strong wind area ahead")24 }25 is HorizonEvent.BadRoadConditionsEvent -> {26 Log.d(TAG, "Bad road conditions ahead")27 }28 is HorizonEvent.ObjectsOnRoadEvent -> {29 Log.d(TAG, "Objects on road ahead")30 }31 is HorizonEvent.BrokenDownVehicleEvent -> {32 Log.d(TAG, "Broken down vehicle ahead")33 }34 is HorizonEvent.WrongWayDriverEvent -> {35 Log.d(TAG, "Wrong way driver reported ahead")36 }37 else -> { }38 }39}