[drape] Add FollowAndRotateRoute mode

This adds a new mode to rotate the camera towards the route while driving.
This is done by looking ahead X number of seconds along the current route,
up to the next turn, and calculating the angle between the current position
and then.

Squashed commits:

[drape] Add bearing calculation via route lookahead while navigating
[drape] Extract NavigationContext from OnLocationUpdate params
[drape] Increase rotation animation duration during navigation
[drape] Seperate route and compass rotation into two modes
[drape] Reduce route lookahead maximum to 25 seconds
[drape] Fix case where rotation was incorrectly considered invalid
[drape] Make FollowAndRotateRoute mode only available during driving navigation
[drape] Rewrite FollowedPolyline::GetLookaheadPoint
[drape] Cleanup

Signed-off-by: Leonardo Bishop <me@leonardobishop.net>
This commit is contained in:
Leonardo Bishop
2025-12-05 16:47:59 +00:00
committed by Konstantin Pastbin
parent 0d01076c0f
commit 515cf98cef
13 changed files with 243 additions and 108 deletions

View File

@@ -237,4 +237,34 @@ Iter FollowedPolyline::GetClosestMatchingProjectionInInterval(m2::RectD const &
return nearestIter;
}
m2::PointD FollowedPolyline::GetLookaheadPoint(double lookaheadDistanceM) const
{
if (!IsValid())
return m2::PointD();
size_t segmentIdx = m_current.m_ind;
m2::PointD prev = m_current.m_pt;
size_t const maxSegmentIdx = m_poly.GetSize() - 1;
double remaining = lookaheadDistanceM;
while (segmentIdx < maxSegmentIdx)
{
m2::PointD const & next = m_poly.GetPoint(segmentIdx + 1);
double segLen = mercator::DistanceOnEarth(prev, next);
if (remaining <= segLen)
{
double t = remaining / segLen;
return prev + (next - prev) * t;
}
remaining -= segLen;
prev = next;
segmentIdx += 1;
}
return m_poly.GetPoint(segmentIdx);
}
} // namespace routing