forked from upstream-mirrors/OpenTracks
@@ -153,25 +153,19 @@ public class CSVTrackExporter implements TrackExporter {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (printWriter != null) {
|
||||
printWriter.flush();
|
||||
printWriter = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void writeHeader(List<Column> columns) {
|
||||
if (printWriter != null) {
|
||||
String columnNames = columns.stream().map(c -> c.columnName).reduce((s, s2) -> s + "," + s2).orElseThrow(() -> new RuntimeException("No columns defined"));
|
||||
printWriter.println("#" + columnNames);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTrackPoint(List<Column> columns, TrackPoint trackPoint) {
|
||||
if (printWriter != null) {
|
||||
String columnNames = columns.stream().map(c -> c.extractor.apply(trackPoint)).reduce((s, s2) -> s + "," + s2).orElseThrow(() -> new RuntimeException("No columns defined"));
|
||||
printWriter.println(columnNames);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Column {
|
||||
final String columnName;
|
||||
|
||||
@@ -199,15 +199,12 @@ public class GPXTrackExporter implements TrackExporter {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (printWriter != null) {
|
||||
printWriter.flush();
|
||||
printWriter = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeHeader() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
printWriter.println("<gpx");
|
||||
printWriter.println("version=\"1.1\"");
|
||||
@@ -229,13 +226,10 @@ public class GPXTrackExporter implements TrackExporter {
|
||||
+ " http://www.cluetrust.com/Schemas http://www.cluetrust.com/Schemas/gpxdata10.xsd"
|
||||
+ " http://opentracksapp.com/xmlschemas/v1 http://opentracksapp.com/xmlschemas/OpenTracks_v1.xsd\">");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeFooter() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("</gpx>");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeMarkers(Track track) throws InterruptedException {
|
||||
try (Cursor cursor = contentProviderUtils.getMarkerCursor(track.getId(), null, -1)) {
|
||||
@@ -254,7 +248,6 @@ public class GPXTrackExporter implements TrackExporter {
|
||||
}
|
||||
|
||||
public void writeMarker(ZoneOffset zoneOffset, Marker marker) {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<wpt " + formatLocation(marker.getLatitude(), marker.getLongitude()) + ">");
|
||||
if (marker.hasAltitude()) {
|
||||
printWriter.println("<ele>" + ALTITUDE_FORMAT.format(marker.getAltitude().toM()) + "</ele>");
|
||||
@@ -265,10 +258,8 @@ public class GPXTrackExporter implements TrackExporter {
|
||||
printWriter.println("<type>" + StringUtils.formatCData(marker.getCategory()) + "</type>");
|
||||
printWriter.println("</wpt>");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeBeginTrack(Track track) {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<trk>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(track.getName()) + "</name>");
|
||||
printWriter.println("<desc>" + StringUtils.formatCData(track.getDescription()) + "</desc>");
|
||||
@@ -291,13 +282,10 @@ public class GPXTrackExporter implements TrackExporter {
|
||||
|
||||
printWriter.println("</extensions>");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeEndTrack() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("</trk>");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeOpenSegment() {
|
||||
printWriter.println("<trkseg>");
|
||||
@@ -310,8 +298,6 @@ public class GPXTrackExporter implements TrackExporter {
|
||||
public Distance writeTrackPoint(ZoneOffset zoneOffset, TrackPoint trackPoint, List<TrackPoint> sensorPoints, Distance trackDistance) {
|
||||
Distance cumulativeDistance = null;
|
||||
|
||||
if (printWriter != null) {
|
||||
|
||||
printWriter.println("<trkpt " + formatLocation(trackPoint.getLatitude(), trackPoint.getLongitude()) + ">");
|
||||
|
||||
if (trackPoint.hasAltitude()) {
|
||||
@@ -370,7 +356,7 @@ public class GPXTrackExporter implements TrackExporter {
|
||||
}
|
||||
|
||||
printWriter.println("</trkpt>");
|
||||
}
|
||||
|
||||
if (cumulativeDistance != null) {
|
||||
return cumulativeDistance;
|
||||
}
|
||||
|
||||
@@ -212,14 +212,11 @@ public class KMLTrackExporter implements TrackExporter {
|
||||
|
||||
@VisibleForTesting
|
||||
void close() {
|
||||
if (printWriter != null) {
|
||||
printWriter.flush();
|
||||
printWriter = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeHeader(List<Track> tracks) {
|
||||
if (printWriter != null) {
|
||||
printWriter.println(
|
||||
"""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
@@ -252,25 +249,19 @@ public class KMLTrackExporter implements TrackExporter {
|
||||
|
||||
printWriter.println("</Schema>");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFooter() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("</Document>");
|
||||
printWriter.println("</kml>");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeBeginMarkers(Track track) {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<Folder>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(context.getString(R.string.track_markers, track.getName())) + "</name>");
|
||||
printWriter.println("<open>1</open>");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeMarker(Marker marker, ZoneOffset zoneOffset) {
|
||||
if (printWriter != null) {
|
||||
boolean existsPhoto = MarkerUtils.buildInternalPhotoFile(context, marker.getTrackId(), marker.getPhotoURI()) != null;
|
||||
if (marker.hasPhoto() && exportPhotos && existsPhoto) {
|
||||
float heading = getHeading(marker.getTrackId(), marker.getLocation());
|
||||
@@ -279,30 +270,22 @@ public class KMLTrackExporter implements TrackExporter {
|
||||
writePlacemark(marker.getName(), marker.getCategory(), marker.getDescription(), marker.getLocation(), zoneOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeEndMarkers() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("</Folder>");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeMultiTrackBegin() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<Folder id=\"tracks\">");
|
||||
printWriter.println("<name>" + context.getString(R.string.generic_tracks) + "</name>");
|
||||
printWriter.println("<open>1</open>");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeMultiTrackEnd() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("</Folder>");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeBeginTrack(Track track) {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<Placemark>");
|
||||
|
||||
printWriter.println("<name>" + StringUtils.formatCData(track.getName()) + "</name>");
|
||||
@@ -316,19 +299,15 @@ public class KMLTrackExporter implements TrackExporter {
|
||||
printWriter.println("<altitudeMode>absolute</altitudeMode>");
|
||||
printWriter.println("<interpolate>1</interpolate>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void writeEndTrack() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("</MultiTrack>");
|
||||
printWriter.println("</Placemark>");
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void writeOpenSegment() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<Track>");
|
||||
speedList.clear();
|
||||
distanceList.clear();
|
||||
@@ -340,11 +319,9 @@ public class KMLTrackExporter implements TrackExporter {
|
||||
accuracyHorizontal.clear();
|
||||
accuracyVertical.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void writeCloseSegment() {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<ExtendedData>");
|
||||
printWriter.println("<SchemaData schemaUrl=\"#" + SCHEMA_ID + "\">");
|
||||
if (speedList.stream().anyMatch(Objects::nonNull)) {
|
||||
@@ -378,11 +355,9 @@ public class KMLTrackExporter implements TrackExporter {
|
||||
printWriter.println("</ExtendedData>");
|
||||
printWriter.println("</Track>");
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void writeTrackPoint(ZoneOffset zoneOffset, TrackPoint trackPoint) {
|
||||
if (printWriter != null) {
|
||||
printWriter.println("<when>" + getTime(zoneOffset, trackPoint.getLocation()) + "</when>");
|
||||
|
||||
if (trackPoint.hasLocation()) {
|
||||
@@ -402,7 +377,6 @@ public class KMLTrackExporter implements TrackExporter {
|
||||
accuracyHorizontal.add(trackPoint.hasHorizontalAccuracy() ? (float) trackPoint.getHorizontalAccuracy().toM() : null);
|
||||
accuracyVertical.add(trackPoint.hasVerticalAccuracy() ? (float) trackPoint.getVerticalAccuracy().toM() : null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the simple array data.
|
||||
|
||||
Reference in New Issue
Block a user