forked from upstream-mirrors/OpenTracks
GPX export: re-implemented basic support for multiple tracks.
Fixes #614.
This commit is contained in:
@@ -34,9 +34,10 @@ import de.dennisguse.opentracks.content.provider.TrackPointIterator;
|
|||||||
import de.dennisguse.opentracks.util.StringUtils;
|
import de.dennisguse.opentracks.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert {@link Track} incl. {@link Marker} and {@link TrackPoint} to KML.
|
* Convert {@link Track} incl. {@link Marker} and {@link TrackPoint} to GPX.
|
||||||
* NOTE:
|
* NOTE:
|
||||||
* * does not export {@link TrackPoint} without a latitude/longitude (not supported by GPX 1.1).
|
* * does not export {@link TrackPoint} without a latitude/longitude (not supported by GPX 1.1).
|
||||||
|
* * cannot export multiple {@link Track}s - all {@link TrackPoint}s are exported as if they would belong to the first track.
|
||||||
*
|
*
|
||||||
* @author Sandor Dornbush
|
* @author Sandor Dornbush
|
||||||
* @author Rodrigo Damazio
|
* @author Rodrigo Damazio
|
||||||
@@ -85,13 +86,21 @@ public class GPXTrackExporter implements TrackExporter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
|
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
|
||||||
|
return writeTrack(new Track[]{track}, outputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean writeTrack(Track[] tracks, @NonNull OutputStream outputStream) {
|
||||||
|
Track mainTrack = tracks[0];
|
||||||
try {
|
try {
|
||||||
prepare(outputStream);
|
prepare(outputStream);
|
||||||
writeHeader(track);
|
writeHeader(mainTrack);
|
||||||
|
|
||||||
writeMarkers(track);
|
writeMarkers(mainTrack);
|
||||||
|
|
||||||
writeLocations(track);
|
for (Track track : tracks) {
|
||||||
|
writeLocations(track);
|
||||||
|
}
|
||||||
|
|
||||||
writeFooter();
|
writeFooter();
|
||||||
close();
|
close();
|
||||||
@@ -103,11 +112,6 @@ public class GPXTrackExporter implements TrackExporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean writeTrack(Track[] tracks, @NonNull OutputStream outputStream) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeLocations(Track track) throws InterruptedException {
|
private void writeLocations(Track track) throws InterruptedException {
|
||||||
boolean wroteTrack = false;
|
boolean wroteTrack = false;
|
||||||
boolean wroteSegment = false;
|
boolean wroteSegment = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user