[routing] SaveRoute minor fixes and CHECK.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako
2025-07-17 08:23:04 -03:00
committed by Konstantin Pastbin
parent c4599f4889
commit b107638b8b
4 changed files with 17 additions and 32 deletions

View File

@@ -1163,32 +1163,25 @@ std::string BookmarkManager::GenerateSavedRouteName(std::string const & from, st
return GenerateTrackRecordingName();
}
kml::TrackId BookmarkManager::SaveRoute(std::vector<geometry::PointWithAltitude> const & points,
std::string const & from, std::string const & to)
kml::TrackId BookmarkManager::SaveRoute(std::vector<geometry::PointWithAltitude> points, std::string const & from,
std::string const & to)
{
CHECK(!points.empty(), ("Route points should not be empty"));
kml::MultiGeometry geometry;
geometry.m_lines.emplace_back();
geometry.m_timestamps.emplace_back();
auto & line = geometry.m_lines.back();
for (auto const & pt : points)
line.emplace_back(pt);
kml::TrackData trackData;
trackData.m_geometry = std::move(geometry);
trackData.m_geometry.m_lines.push_back(std::move(points));
trackData.m_geometry.m_timestamps.emplace_back();
auto trackName = GenerateSavedRouteName(from, to);
kml::SetDefaultStr(trackData.m_name, trackName);
kml::SetDefaultStr(trackData.m_name, GenerateSavedRouteName(from, to));
kml::ColorData colorData;
colorData.m_rgba = GenerateTrackRecordingColor().GetRGBA();
kml::TrackLayer layer;
layer.m_color = colorData;
std::vector<kml::TrackLayer> m_layers;
m_layers.emplace_back(layer);
trackData.m_layers = std::move(m_layers);
std::vector<kml::TrackLayer> layers;
layers.emplace_back(layer);
trackData.m_layers = std::move(layers);
trackData.m_timestamp = kml::TimestampClock::now();

View File

@@ -430,7 +430,7 @@ public:
std::string GenerateTrackRecordingName() const;
dp::Color GenerateTrackRecordingColor() const;
kml::TrackId SaveRoute(std::vector<geometry::PointWithAltitude> const & points, std::string const & from,
kml::TrackId SaveRoute(std::vector<geometry::PointWithAltitude> points, std::string const & from,
std::string const & to);
private:

View File

@@ -1084,16 +1084,14 @@ kml::TrackId RoutingManager::SaveRoute()
std::vector<geometry::PointWithAltitude> junctions;
RoutingSession().GetRouteJunctionPoints(junctions);
junctions.erase(std::unique(junctions.begin(), junctions.end(),
[](geometry::PointWithAltitude const & p1, geometry::PointWithAltitude const & p2)
{ return AlmostEqualAbs(p1, p2, kMwmPointAccuracy); }),
junctions.end());
base::Unique(junctions, [](geometry::PointWithAltitude const & p1, geometry::PointWithAltitude const & p2)
{ return AlmostEqualAbs(p1, p2, kMwmPointAccuracy); });
auto const routePoints = GetRoutePoints();
std::string const from = GetNameFromPoint(routePoints.front());
std::string const to = GetNameFromPoint(routePoints.back());
return m_bmManager->SaveRoute(junctions, from, to);
return m_bmManager->SaveRoute(std::move(junctions), from, to);
}
bool RoutingManager::DisableFollowMode()

View File

@@ -1,8 +1,5 @@
#include "routing/routing_session.hpp"
#include "routing/routing_helpers.hpp"
#include "routing/speed_camera.hpp"
#include "platform/distance.hpp"
#include "platform/location.hpp"
#include "platform/measurement_utils.hpp"
@@ -789,15 +786,12 @@ bool RoutingSession::GetRouteJunctionPoints(std::vector<geometry::PointWithAltit
return false;
auto const & segments = m_route->GetRouteSegments();
CHECK(!segments.empty(), ());
routeJunctionPoints.reserve(segments.size());
for (auto const & s : segments)
routeJunctionPoints.push_back(s.GetJunction());
for (size_t i = 0; i < segments.size(); ++i)
{
auto const & junction = segments[i].GetJunction();
routeJunctionPoints.push_back(junction);
}
ASSERT_EQUAL(routeJunctionPoints.size(), routeJunctionPoints.size(), ());
return true;
}