MCPcopy Create free account
hub / github.com/comaps/comaps / OnLocationPositionChanged

Method OnLocationPositionChanged

libs/routing/speed_camera_manager.cpp:49–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49void SpeedCameraManager::OnLocationPositionChanged(location::GpsInfo const & info)
50{
51 CHECK_THREAD_CHECKER(m_threadChecker, ());
52 CHECK(!m_route.expired(), ());
53
54 auto const passedDistanceMeters = m_route.lock()->GetCurrentDistanceFromBeginMeters();
55
56 // Step 1. Find new cameras and cache them.
57 FindCamerasOnRouteAndCache(passedDistanceMeters);
58
59 double distFromCurrentPosAndClosestCam = -1.0;
60 m_speedLimitExceeded = false;
61 if (m_closestCamera.IsValid())
62 {
63 distFromCurrentPosAndClosestCam = m_closestCamera.m_distFromBeginMeters - passedDistanceMeters;
64 if (distFromCurrentPosAndClosestCam < -kInfluenceZoneMeters)
65 {
66 m_closestCamera.Invalidate();
67 m_speedCamClearCallback();
68 }
69 else if (!m_closestCamera.NoSpeed())
70 {
71 m_speedLimitExceeded = IsSpeedHigh(distFromCurrentPosAndClosestCam, info.m_speed, m_closestCamera);
72 }
73 }
74
75 // Step 2. Check cached cameras. Do it only after pass through closest camera.
76 if (!m_cachedSpeedCameras.empty() && distFromCurrentPosAndClosestCam < 0)
77 {
78 // Do not use reference here, because ProcessCameraWarning() can
79 // invalidate |closestSpeedCam|.
80 auto const closestSpeedCam = m_cachedSpeedCameras.front();
81
82 if (NeedToUpdateClosestCamera(passedDistanceMeters, info.m_speed, closestSpeedCam))
83 {
84 m_closestCamera = closestSpeedCam;
85 ResetNotifications();
86 m_cachedSpeedCameras.pop();
87 PassClosestCameraToUI();
88 }
89 }
90
91 if (m_closestCamera.IsValid() && SetNotificationFlags(passedDistanceMeters, info.m_speed, m_closestCamera))
92 {
93 // If some notifications available now.
94 SendNotificationStat(passedDistanceMeters, info.m_speed, m_closestCamera);
95 }
96}
97
98void SpeedCameraManager::GenerateNotifications(std::vector<std::string> & notifications)
99{

Callers

nothing calls this directly

Calls 8

lockMethod · 0.80
NoSpeedMethod · 0.80
frontMethod · 0.80
popMethod · 0.80
IsValidMethod · 0.45
InvalidateMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected