Handle Special Road Alerts
Handle special road alerts
This tutorial shows how to handle special road alerts.
Get started
All special road alerts are zone alerts representing a zone with special road condition.
| void AlertObserver::onAlertInfoUpdated(const tn::drive::models::v1::AlertInfo& alertInfo)
{
const auto& aheadAlerts = alertInfo.alerts_ahead;
for (const auto& alert : aheadAlerts.zone_alerts)
{
// following types are special road alerts:
// tn::drive::models::v1::AlertType::Ferry
// tn::drive::models::v1::AlertType::Tunnel
// tn::drive::models::v1::AlertType::Overpass
// tn::drive::models::v1::AlertType::Underpass
// tn::drive::models::v1::AlertType::SpeedBumper
// tn::drive::models::v1::AlertType::Unpaved
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;
if (alert.basic.distance_to_vehicle == 0)
{
// vehicle has entered the zone
// get distance along road between zone begin location and current vehicle location
const auto pastDistance = alert.zone.past_distance;
}
showAlertIconOnMap(id, type, alert.zone.begin, alert.zone.end);
}
}
|