mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-10 14:24:21 +00:00
[map] Save points altitudes when saving route as a track (#10759)
[map] Save points altitudes when saving route as a track Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
21cc2bbf52
commit
cc6958282b
@@ -1181,8 +1181,10 @@ std::string BookmarkManager::GenerateSavedRouteName(std::string const & from, st
|
||||
return GenerateTrackRecordingName();
|
||||
}
|
||||
|
||||
kml::TrackId BookmarkManager::SaveRoute(std::vector<m2::PointD> const & points, std::string const & from, std::string const & to)
|
||||
kml::TrackId BookmarkManager::SaveRoute(std::vector<geometry::PointWithAltitude> const & 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();
|
||||
|
||||
@@ -435,7 +435,7 @@ public:
|
||||
std::string GenerateTrackRecordingName() const;
|
||||
dp::Color GenerateTrackRecordingColor() const;
|
||||
|
||||
kml::TrackId SaveRoute(std::vector<m2::PointD> const & points, std::string const & from, std::string const & to);
|
||||
kml::TrackId SaveRoute(std::vector<geometry::PointWithAltitude> const & points, std::string const & from, std::string const & to);
|
||||
|
||||
private:
|
||||
class MarksChangesTracker : public df::UserMarksProvider
|
||||
|
||||
@@ -1644,12 +1644,12 @@ UNIT_CLASS_TEST(Runner, Bookmarks_TestSaveRoute)
|
||||
{
|
||||
BookmarkManager bmManager(BM_CALLBACKS);
|
||||
bmManager.EnableTestMode(true);
|
||||
auto const points = {m2::PointD(0.0, 0.0), m2::PointD(0.001, 0.001)};
|
||||
auto const points = {geometry::PointWithAltitude({0.0, 0.0}, 0.0), geometry::PointWithAltitude({0.001, 0.001}, 0.001)};
|
||||
auto const trackId = bmManager.SaveRoute(points, "London", "Paris");
|
||||
auto const * track = bmManager.GetTrack(trackId);
|
||||
TEST_EQUAL(track->GetName(), "London - Paris", ());
|
||||
auto const line = track->GetData().m_geometry.m_lines[0];
|
||||
std::vector const expectedLine = {{geometry::PointWithAltitude(m2::PointD(0.0, 0.0)), geometry::PointWithAltitude(m2::PointD(0.001, 0.001))}};
|
||||
std::vector const expectedLine = {{geometry::PointWithAltitude(m2::PointD(0.0, 0.0), 0.0), geometry::PointWithAltitude(m2::PointD(0.001, 0.001), 0.001)}};
|
||||
TEST_EQUAL(line, expectedLine, ());
|
||||
}
|
||||
|
||||
|
||||
@@ -1100,16 +1100,26 @@ static std::string GetNameFromPoint(RouteMarkData const & rmd)
|
||||
|
||||
kml::TrackId RoutingManager::SaveRoute()
|
||||
{
|
||||
auto points = GetRoutePolyline().GetPolyline().GetPoints();
|
||||
std::vector<geometry::PointWithAltitude> junctions;
|
||||
RoutingSession().GetRouteJunctionPoints(junctions);
|
||||
|
||||
junctions.erase(
|
||||
std::unique(
|
||||
junctions.begin(),
|
||||
junctions.end(),
|
||||
[](const geometry::PointWithAltitude & p1, const geometry::PointWithAltitude & p2)
|
||||
{
|
||||
return AlmostEqualAbs(p1, p2, kMwmPointAccuracy);
|
||||
}
|
||||
),
|
||||
junctions.end()
|
||||
);
|
||||
|
||||
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());
|
||||
|
||||
return m_bmManager->SaveRoute(points, from, to);
|
||||
return m_bmManager->SaveRoute(junctions, from, to);
|
||||
}
|
||||
|
||||
bool RoutingManager::DisableFollowMode()
|
||||
|
||||
Reference in New Issue
Block a user