[routing] Add possibility to save routes as tracks

Signed-off-by: cyber-toad <the.cyber.toad@proton.me>
This commit is contained in:
cyber-toad
2025-03-11 10:13:57 +01:00
committed by Konstantin Pastbin
parent 9e8accc8f5
commit 45bba5fb5e
16 changed files with 165 additions and 18 deletions

View File

@@ -1091,6 +1091,27 @@ void RoutingManager::SetUserCurrentPosition(m2::PointD const & position)
}
}
static std::string GetNameFromPoint(RouteMarkData const & rmd)
{
if (rmd.m_subTitle.empty())
return "";
return rmd.m_title;
}
void RoutingManager::SaveRoute()
{
auto points = GetRoutePolyline().GetPolyline().GetPoints();
auto const routePoints = GetRoutePoints();
std::string const from = GetNameFromPoint(routePoints.front());
std::string const to = GetNameFromPoint(routePoints.back());
// remove equal sequential points
points.erase(
std::unique(points.begin(), points.end(), [](const m2::PointD & p1, const m2::PointD & p2) { return AlmostEqualAbs(p1, p2, kMwmPointAccuracy); }),
points.end());
m_bmManager->SaveRoute(points, from, to);
}
bool RoutingManager::DisableFollowMode()
{
bool const disabled = m_routingSession.DisableFollowMode();