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 cameras
  • MobileCamera - Temporary or mobile speed enforcement
  • SpeedEnforcement - Speed enforcement zones with multiple cameras
  • RedLightCamera - Red light enforcement systems
  • AverageSpeedArea - Average speed monitoring zones
  • FixedDangerZone - Fixed camera danger zones
  • MobileRiskZone - Mobile camera risk zones
  • Restricted - Access-restricted areas

Traffic Events:

  • TrafficJamEvent - Traffic congestion
  • RoadWorkEvent - Road construction and maintenance
  • RoadClosureEvent - Closed roads

Traffic Hazard Events:

  • AccidentEvent - Traffic accidents
  • BrokenDownVehicleEvent - Disabled vehicles
  • WrongWayDriverEvent - Wrong-way driver warnings

Weather Hazard Events:

  • ReducedVisibilityEvent - Poor visibility (fog, heavy rain)
  • SlipperyRoadEvent - Slippery road conditions
  • StrongWindEvent - Strong wind areas

Road Hazard Events:

  • BadRoadConditionsEvent - Poor road surface conditions
  • ObjectsOnRoadEvent - Objects or obstacles on the road (animals, people)

Other Events:

  • RailroadCrossingEvent - Railroad crossings
  • EvWaypointEvent - EV charging waypoints
  • GenericHazardEvent - Unclassified hazards
  • InformativeDirectionEvent - Directional information (highway exits, intersections)
  • PoiEvent - Points of interest

Observing horizon events

Subscribe to receive updates about upcoming road events:

1import android.util.Log
2import com.tomtom.automotive.integration.client.api.horizon.HorizonManager
3import com.tomtom.automotive.integration.client.api.horizon.observehorizonevent.HorizonEventsListener
4import com.tomtom.automotive.integration.client.api.horizon.observehorizonevent.HorizonInfo
5import com.tomtom.automotive.integration.client.common.Callback
6import com.tomtom.automotive.integration.client.common.SdkReleasable
7
8private const val TAG = "HorizonExample"
9private var observeHorizonEventsReleasable: SdkReleasable? = null
10
11fun observeHorizonEvents(horizonManager: HorizonManager) {
12 observeHorizonEventsReleasable = horizonManager.observeHorizonEvents(
13 object : HorizonEventsListener {
14 override fun onHorizonEventsChanged(horizonInfo: HorizonInfo) {
15 Log.d(TAG, "Horizon events updated: $horizonInfo")
16
17 horizonInfo.horizonEvents.forEach { event ->
18 val distanceMeters = event.distanceToEntryPoint.inMeters()
19 Log.d(TAG, "Event: ${event::class.simpleName} in ${distanceMeters}m")
20 }
21 }
22
23 override fun onFunctionalityUnavailable(reason: Callback.Reason) {
24 Log.e(TAG, "Horizon events unavailable: ${reason.devMessage}")
25 }
26 }
27 )
28}
29
30fun stopObservingHorizonEvents() {
31 observeHorizonEventsReleasable?.release()
32 observeHorizonEventsReleasable = null
33}

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.Log
2import com.tomtom.automotive.integration.client.api.model.horizon.HorizonEvent
3
4private const val TAG = "HorizonExample"
5
6private fun processHorizonEvent(event: HorizonEvent) {
7 val distanceMeters = event.distanceToEntryPoint.inMeters()
8
9 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 - distanceMeters
22 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:

CategoryPower RangeExample
SLOW< 12 kW10 kW charger
REGULAR12 kW - 49 kW20 kW charger
FAST≥ 50 kW70 kW charger
1import android.util.Log
2import com.tomtom.automotive.integration.client.api.model.horizon.ChargingStopType
3import com.tomtom.automotive.integration.client.api.model.horizon.HorizonEvent
4
5private const val TAG = "HorizonExample"
6
7private fun handleEvWaypoint(event: HorizonEvent.EvWaypointEvent, distanceMeters: Double) {
8 val chargingType = event.chargingStopType
9
10 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 }
16
17 Log.d(TAG, "$chargerDescription ahead in ${distanceMeters}m")
18}

Hazard events

Handle weather and road hazards:

1import android.util.Log
2import com.tomtom.automotive.integration.client.api.model.horizon.HorizonEvent
3import com.tomtom.automotive.integration.client.api.model.horizon.ReducedVisibilityReason
4
5private const val TAG = "HorizonExample"
6
7private 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}