Skip to content

Handle Intersection Approaching Alert

Handle intersection approaching alerts

This tutorial shows how to handle intersection approaching alerts.

Get started

All intersection approaching alerts are point alerts. It is a vital safety feature designed to enhance driver awareness and promote safe driving behavior when approaching intersections. The driver should reduce speed to minimize the risk of accidents and potential conflicts here.

void AlertObserver::onAlertInfoUpdated(const tn::drive::models::v1::AlertInfo& alertInfo)
{
    const auto& aheadAlerts = alertInfo.alerts_ahead;
    for (const auto& alert : aheadAlerts.intersection_approaching_alerts)
    {
        // following type is intersection approaching alert:
        // tn::drive::models::v1::AlertType::IntersectionApproaching
        const auto type = alert.basic.type;

        // each alert item has a unique identifier, can be used to match alert updates
        const auto id = alert.basic.id;

        // current speed
        const auto& currentSpeed = alert.current_speed;

        // severity level
        const auto& severity = alert.severity;

        // intersection type
        const auto& intersectionType = alert.intersection_type

        showIntersectionIconOnMap(id, currentSpeed, alert.point->location, severity, intersectionType);
    }
}