[routing] Remove passed intermediate points when assembling a modified route mid-navigation

Fixes OM #9592

Signed-off-by: Michał Brzozowski <www.haxor@gmail.com>

# Conflicts:
#	libs/map/routing_manager.cpp
This commit is contained in:
Michał Brzozowski
2025-05-24 08:14:34 +02:00
committed by David Gekeler
parent 697e871c1b
commit 57ecf3848b
4 changed files with 24 additions and 3 deletions

View File

@@ -546,8 +546,10 @@ void RoutingManager::RemoveRoute(bool deactivateFollowing)
es.ClearGroup(UserMark::Type::SPEED_CAM); es.ClearGroup(UserMark::Type::SPEED_CAM);
es.ClearGroup(UserMark::Type::ROAD_WARNING); es.ClearGroup(UserMark::Type::ROAD_WARNING);
} }
if (deactivateFollowing) if (deactivateFollowing) {
SetPointsFollowingMode(false /* enabled */); SetPointsFollowingMode(false /* enabled */);
RemovePassedPoints();
}
}); });
if (deactivateFollowing) if (deactivateFollowing)
@@ -937,6 +939,13 @@ void RoutingManager::SetPointsFollowingMode(bool enabled)
routePoints.SetFollowingMode(enabled); routePoints.SetFollowingMode(enabled);
} }
void RoutingManager::RemovePassedPoints()
{
ASSERT(m_bmManager != nullptr, ());
RoutePointsLayout routePoints(*m_bmManager);
routePoints.RemovePassedPoints();
}
void RoutingManager::ReorderIntermediatePoints() void RoutingManager::ReorderIntermediatePoints()
{ {
vector<RouteMarkPoint *> prevPoints; vector<RouteMarkPoint *> prevPoints;

View File

@@ -332,6 +332,8 @@ private:
void SetPointsFollowingMode(bool enabled); void SetPointsFollowingMode(bool enabled);
void RemovePassedPoints();
void ReorderIntermediatePoints(); void ReorderIntermediatePoints();
m2::RectD ShowPreviewSegments(std::vector<RouteMarkData> const & routePoints); m2::RectD ShowPreviewSegments(std::vector<RouteMarkData> const & routePoints);

View File

@@ -347,6 +347,16 @@ void RoutePointsLayout::SetFollowingMode(bool enabled)
m_editSession.GetMarkForEdit<RouteMarkPoint>(markId)->SetFollowingMode(enabled); m_editSession.GetMarkForEdit<RouteMarkPoint>(markId)->SetFollowingMode(enabled);
} }
void RoutePointsLayout::RemovePassedPoints()
{
for (auto markId : m_manager.GetUserMarkIds(UserMark::Type::ROUTING)) {
auto * mark = m_editSession.GetMarkForEdit<RouteMarkPoint>(markId);
if (mark->IsPassed())
m_editSession.DeleteUserMark(mark->GetId());
}
}
RouteMarkPoint const * RoutePointsLayout::GetRoutePoint(RouteMarkType type, size_t intermediateIndex) const RouteMarkPoint const * RoutePointsLayout::GetRoutePoint(RouteMarkType type, size_t intermediateIndex) const
{ {
for (auto markId : m_manager.GetUserMarkIds(UserMark::Type::ROUTING)) for (auto markId : m_manager.GetUserMarkIds(UserMark::Type::ROUTING))

View File

@@ -97,7 +97,7 @@ public:
size_t destIntermediateIndex); size_t destIntermediateIndex);
void PassRoutePoint(RouteMarkType type, size_t intermediateIndex = 0); void PassRoutePoint(RouteMarkType type, size_t intermediateIndex = 0);
void SetFollowingMode(bool enabled); void SetFollowingMode(bool enabled);
void RemovePassedPoints();
private: private:
using TRoutePointCallback = std::function<void(RouteMarkPoint * mark)>; using TRoutePointCallback = std::function<void(RouteMarkPoint * mark)>;
void ForEachIntermediatePoint(TRoutePointCallback const & fn); void ForEachIntermediatePoint(TRoutePointCallback const & fn);