From f426348a43226829e711bc18aba0e263e50b04b1 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 2 Oct 2017 13:00:15 +0300 Subject: [PATCH 1/2] Fix #4478 --- OsmAnd/src/net/osmand/plus/GPXUtilities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index c11d56b723..87f13d56fe 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -1012,7 +1012,6 @@ public class GPXUtilities { } private void removeGeneralTrackIfExists() { - Track generalTrack = getGeneralTrack(); if (generalTrack != null) { tracks.remove(generalTrack); this.generalTrack = null; @@ -1163,6 +1162,7 @@ public class GPXUtilities { } public static String writeGpxFile(File fout, GPXFile file, OsmandApplication ctx) { + file.removeGeneralTrackIfExists(); Writer output = null; try { output = new OutputStreamWriter(new FileOutputStream(fout), "UTF-8"); //$NON-NLS-1$ From 1e0b32c7c47db80da6665bc98c0e9d4ed2b4287f Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 2 Oct 2017 17:12:45 +0300 Subject: [PATCH 2/2] Don't remove general track --- OsmAnd/src/net/osmand/plus/GPXUtilities.java | 27 ++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index 87f13d56fe..8d96630b1c 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -1162,7 +1162,6 @@ public class GPXUtilities { } public static String writeGpxFile(File fout, GPXFile file, OsmandApplication ctx) { - file.removeGeneralTrackIfExists(); Writer output = null; try { output = new OutputStreamWriter(new FileOutputStream(fout), "UTF-8"); //$NON-NLS-1$ @@ -1202,20 +1201,22 @@ public class GPXUtilities { "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"); for (Track track : file.tracks) { - serializer.startTag(null, "trk"); //$NON-NLS-1$ - writeNotNullText(serializer, "name", track.name); - writeNotNullText(serializer, "desc", track.desc); - for (TrkSegment segment : track.segments) { - serializer.startTag(null, "trkseg"); //$NON-NLS-1$ - for (WptPt p : segment.points) { - serializer.startTag(null, "trkpt"); //$NON-NLS-1$ - writeWpt(format, serializer, p); - serializer.endTag(null, "trkpt"); //$NON-NLS-1$ + if (!track.generalTrack) { + serializer.startTag(null, "trk"); //$NON-NLS-1$ + writeNotNullText(serializer, "name", track.name); + writeNotNullText(serializer, "desc", track.desc); + for (TrkSegment segment : track.segments) { + serializer.startTag(null, "trkseg"); //$NON-NLS-1$ + for (WptPt p : segment.points) { + serializer.startTag(null, "trkpt"); //$NON-NLS-1$ + writeWpt(format, serializer, p); + serializer.endTag(null, "trkpt"); //$NON-NLS-1$ + } + serializer.endTag(null, "trkseg"); //$NON-NLS-1$ } - serializer.endTag(null, "trkseg"); //$NON-NLS-1$ + writeExtensions(serializer, track); + serializer.endTag(null, "trk"); //$NON-NLS-1$ } - writeExtensions(serializer, track); - serializer.endTag(null, "trk"); //$NON-NLS-1$ } for (Route track : file.routes) {