diff --git a/kml/serdes_gpx.cpp b/kml/serdes_gpx.cpp index 3054323c27..18ad99c294 100644 --- a/kml/serdes_gpx.cpp +++ b/kml/serdes_gpx.cpp @@ -492,15 +492,31 @@ void SaveTrackData(Writer & writer, TrackData const & trackData) writer << "\n" << kIndent2 << "\n"; } bool const trackHasAltitude = TrackHasAltitudes(trackData); - for (auto const & line : trackData.m_geometry.m_lines) + auto const & geom = trackData.m_geometry; + for (size_t lineIndex = 0; lineIndex < geom.m_lines.size(); ++lineIndex) { + auto const & line = geom.m_lines[lineIndex]; + auto const & timestampsForLine = geom.m_timestamps[lineIndex]; + auto const lineHasTimestamps = geom.HasTimestampsFor(lineIndex); + + if (lineHasTimestamps) + CHECK_EQUAL(line.size(), timestampsForLine.size(), ()); + writer << kIndent2 << "\n"; - for (auto const & point : line) + + for (size_t pointIndex = 0; pointIndex < line.size(); ++pointIndex) { + auto const & point = line[pointIndex]; auto const [lat, lon] = mercator::ToLatLon(point); + writer << kIndent4 << "\n"; + if (trackHasAltitude) writer << kIndent6 << "" << CoordToString(point.GetAltitude()) << "\n"; + + if (lineHasTimestamps) + writer << kIndent6 << "\n"; + writer << kIndent4 << "\n"; } writer << kIndent2 << "\n";