Handle Traffic Sign Alerts
Handle traffic sign alerts
This tutorial shows how to handle traffic sign alerts.
Get started
There are various types of traffic sign alerts, all of them are point alerts, representing that there's a traffic sign around the alert location.
| void AlertObserver::onAlertInfoUpdated(const tn::drive::models::v1::AlertInfo& alertInfo)
{
const auto& aheadAlerts = alertInfo.alerts_ahead;
for (const auto& alert : aheadAlerts.point_alerts)
{
// following types are speed limit alerts:
// tn::drive::models::v1::AlertType::BeginOvertaking
// tn::drive::models::v1::AlertType::EndOvertaking
// tn::drive::models::v1::AlertType::ProtectedOvertakingExtraLane
// tn::drive::models::v1::AlertType::ProtectedOvertakingExtraRight
// tn::drive::models::v1::AlertType::ProtectedOvertakingExtraLeft
// tn::drive::models::v1::AlertType::LaneMergeRight
// tn::drive::models::v1::AlertType::LaneMergeLeft
// tn::drive::models::v1::AlertType::LaneMergeCenter
// tn::drive::models::v1::AlertType::RoadNarrows
// tn::drive::models::v1::AlertType::SharpCurveLeft
// tn::drive::models::v1::AlertType::SharpCurveRight
// tn::drive::models::v1::AlertType::WindingRoadStartingLeft
// tn::drive::models::v1::AlertType::WindingRoadStartingRight
// tn::drive::models::v1::AlertType::BeginOvertakingTrucks
// tn::drive::models::v1::AlertType::EndOvertakingTrucks
// tn::drive::models::v1::AlertType::LateralWind
// tn::drive::models::v1::AlertType::GeneralWarningSign
// tn::drive::models::v1::AlertType::RiskOfGrounding
// tn::drive::models::v1::AlertType::GeneralCurve
// tn::drive::models::v1::AlertType::EndOfAllRestrictions
// tn::drive::models::v1::AlertType::GeneralHill
// tn::drive::models::v1::AlertType::AnimalCrossing
// tn::drive::models::v1::AlertType::IcyConditions
// tn::drive::models::v1::AlertType::SlipperyRoad
// tn::drive::models::v1::AlertType::FallingRocks
// tn::drive::models::v1::AlertType::LeftFallingRocks
// tn::drive::models::v1::AlertType::RightFallingRocks
// tn::drive::models::v1::AlertType::TramwayCrossing
// tn::drive::models::v1::AlertType::CongestionHazard
// tn::drive::models::v1::AlertType::AccidentHazard
// tn::drive::models::v1::AlertType::PriorityOverOncomingTraffic
// tn::drive::models::v1::AlertType::YieldToOncomingTraffic
// tn::drive::models::v1::AlertType::CrossingWithPriorityFromRight
// tn::drive::models::v1::AlertType::PedestrianCrossing
// tn::drive::models::v1::AlertType::Yield
// tn::drive::models::v1::AlertType::BeginNoEngineBrake
// tn::drive::models::v1::AlertType::EndNoEngineBrake
// tn::drive::models::v1::AlertType::NoIdling
// tn::drive::models::v1::AlertType::TruckRollOver
// tn::drive::models::v1::AlertType::BeginLowGear
// tn::drive::models::v1::AlertType::EndLowGear
// tn::drive::models::v1::AlertType::UrbanArea
// tn::drive::models::v1::AlertType::Embankment
// tn::drive::models::v1::AlertType::TwoWayTraffic
// tn::drive::models::v1::AlertType::UnevenRoad
// tn::drive::models::v1::AlertType::MaxSpeed
// tn::drive::models::v1::AlertType::BicycleCrossing
// tn::drive::models::v1::AlertType::YieldToBicycles
// tn::drive::models::v1::AlertType::FloodArea
// tn::drive::models::v1::AlertType::HumpBridge
// tn::drive::models::v1::AlertType::STurns
// tn::drive::models::v1::AlertType::WindingRoad
// tn::drive::models::v1::AlertType::RailwayCrossing
// tn::drive::models::v1::AlertType::TrafficLight
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;
showAlertIconOnMap(id, type, alert.point.location);
}
}
|
Steep grade alerts
Steep grade alerts are traffic sign alerts with additional information.
| void AlertObserver::onAlertInfoUpdated(const tn::drive::models::v1::AlertInfo& alertInfo)
{
const auto& aheadAlerts = alertInfo.alerts_ahead;
for (const auto& alert : aheadAlerts.steep_grade_alerts)
{
// following types are speed limit alerts:
// tn::drive::models::v1::AlertType::SteepHillUpwards
// tn::drive::models::v1::AlertType::SteepHillDownwards
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;
// slope grade percent is greater than 7%
if (alert.severity == tn::drive::models::v1::Severity::Critical)
{
showAlertIconOnMap(id, type, alert.point.location);
}
// slope grade percent is greater than 3% and less equal to 7%
else if (alert.severity == tn::drive::models::v1::Severity::kMedium)
{
showHintIconOnMap(id, type, alert.point.location);
}
}
}
|