diff --git a/src/main/java/de/dennisguse/opentracks/data/models/TrackPoint.java b/src/main/java/de/dennisguse/opentracks/data/models/TrackPoint.java index 775bcf141d..a9c64045c7 100644 --- a/src/main/java/de/dennisguse/opentracks/data/models/TrackPoint.java +++ b/src/main/java/de/dennisguse/opentracks/data/models/TrackPoint.java @@ -35,6 +35,8 @@ */ public class TrackPoint { + public static final Speed IDLE_SPEED = Speed.of(0); + private static final Duration MAX_LOCATION_AGE = Duration.ofMinutes(1); private TrackPoint.Id id; diff --git a/src/main/java/de/dennisguse/opentracks/io/file/exporter/GPXTrackExporter.java b/src/main/java/de/dennisguse/opentracks/io/file/exporter/GPXTrackExporter.java index fbb0400d4b..3fd35aee8c 100644 --- a/src/main/java/de/dennisguse/opentracks/io/file/exporter/GPXTrackExporter.java +++ b/src/main/java/de/dennisguse/opentracks/io/file/exporter/GPXTrackExporter.java @@ -167,6 +167,9 @@ private void writeTrackPoints(Track track) throws InterruptedException { sensorPoints.add(trackPoint); } } + case IDLE -> { + // Not supported as IDLE-TrackPoints have no location. + } default -> throw new RuntimeException("Exporting this TrackPoint type is not implemented: " + trackPoint.getType()); } diff --git a/src/main/java/de/dennisguse/opentracks/io/file/exporter/KMLTrackExporter.java b/src/main/java/de/dennisguse/opentracks/io/file/exporter/KMLTrackExporter.java index 3de5f615a7..c0c26a3e92 100644 --- a/src/main/java/de/dennisguse/opentracks/io/file/exporter/KMLTrackExporter.java +++ b/src/main/java/de/dennisguse/opentracks/io/file/exporter/KMLTrackExporter.java @@ -38,6 +38,7 @@ import de.dennisguse.opentracks.data.ContentProviderUtils; import de.dennisguse.opentracks.data.TrackPointIterator; import de.dennisguse.opentracks.data.models.Marker; +import de.dennisguse.opentracks.data.models.Speed; import de.dennisguse.opentracks.data.models.Track; import de.dennisguse.opentracks.data.models.TrackPoint; import de.dennisguse.opentracks.ui.markers.MarkerUtils; @@ -177,12 +178,17 @@ private void writeLocations(Track track) throws InterruptedException { writeCloseSegment(); wroteSegment = false; } - case TRACKPOINT -> { + case TRACKPOINT, IDLE -> { if (!wroteSegment) { // Might happen for older data (pre v3.15.0) writeOpenSegment(); wroteSegment = true; } + + if (trackPoint.getType() == TrackPoint.Type.IDLE) { + // TODO Should we do this while loading the TrackPoints? + trackPoint.setSpeed(Speed.of(0)); + } writeTrackPoint(track.getZoneOffset(), trackPoint); } default -> diff --git a/src/main/java/de/dennisguse/opentracks/io/file/importer/KmlTrackImporter.java b/src/main/java/de/dennisguse/opentracks/io/file/importer/KmlTrackImporter.java index 9dce6b4070..572bec9146 100644 --- a/src/main/java/de/dennisguse/opentracks/io/file/importer/KmlTrackImporter.java +++ b/src/main/java/de/dennisguse/opentracks/io/file/importer/KmlTrackImporter.java @@ -315,6 +315,10 @@ private void onTrackSegmentEnd() { if (i < sensorSpeedList.size() && sensorSpeedList.get(i) != null) { trackPoint.setSpeed(Speed.of(sensorSpeedList.get(i))); + + if (TrackPoint.IDLE_SPEED.lessThan(trackPoint.getSpeed())) { + trackPoint.setType(TrackPoint.Type.IDLE); + } } if (i < sensorDistanceList.size() && sensorDistanceList.get(i) != null) { trackPoint.setSensorDistance(Distance.of(sensorDistanceList.get(i)));