mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Reorder waypoint and track writing on export.
The GPX schema requires waypoints to come before the track. Waypoints are not currently used in TCX export, so there are no changes there. In KML files, both tracks and waypoints are "Placemark"s, so it doesn't matter what order they come in there. This does change the order they appear in CSV files, which could potentially invalidate some assumptions made in downstream tools.
This commit is contained in:
@@ -143,7 +143,6 @@ public class GpxTrackWriter implements TrackFormatWriter {
|
||||
@Override
|
||||
public void writeWaypoint(Waypoint waypoint) {
|
||||
if (pw != null) {
|
||||
// TODO: The gpx spec says waypoints should come *before* tracks
|
||||
Location l = waypoint.getLocation();
|
||||
if (l != null) {
|
||||
pw.println("<wpt lat=\""
|
||||
|
||||
@@ -255,9 +255,8 @@ public class TrackWriter {
|
||||
void writeDocument() {
|
||||
Log.d(MyTracksConstants.TAG, "Started writing track.");
|
||||
writer.writeHeader();
|
||||
// TODO: Fix ordering (in GPX waypoints should come first)
|
||||
writeLocations();
|
||||
writeWaypoints(track.getId());
|
||||
writeLocations();
|
||||
writer.writeFooter();
|
||||
writer.close();
|
||||
success = true;
|
||||
|
||||
@@ -267,8 +267,13 @@ public class TrackWriterTest extends AndroidTestCase {
|
||||
wpt.setId(i + 1);
|
||||
}
|
||||
|
||||
// Begin the track
|
||||
formatWriter.writeHeader();
|
||||
|
||||
// Expect reading/writing of the waypoints (except the first)
|
||||
formatWriter.writeWaypoint(wptEq(wps[1]));
|
||||
formatWriter.writeWaypoint(wptEq(wps[2]));
|
||||
|
||||
// Begin the track
|
||||
formatWriter.writeBeginTrack(locEq(locs[0]));
|
||||
|
||||
// Write locations 1-2
|
||||
@@ -289,10 +294,6 @@ public class TrackWriterTest extends AndroidTestCase {
|
||||
// End the track
|
||||
formatWriter.writeEndTrack(locEq(locs[5]));
|
||||
|
||||
// Expect reading/writing of the waypoints (except the first)
|
||||
formatWriter.writeWaypoint(wptEq(wps[1]));
|
||||
formatWriter.writeWaypoint(wptEq(wps[2]));
|
||||
|
||||
formatWriter.writeFooter();
|
||||
formatWriter.close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user