Bugfix: GpxTrackImporter needs to reset data when it encounters a new TrackPoint; affected only sensor data.

This commit is contained in:
Dennis Guse
2022-01-02 14:41:08 +01:00
parent dbc29a88ce
commit 1fb8fc6a09
@@ -111,7 +111,7 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
protected String uuid; protected String uuid;
protected String gain; protected String gain;
protected String loss; protected String loss;
protected String distance; protected String sensorDistance;
private final LinkedList<TrackPoint> currentSegment = new LinkedList<>(); private final LinkedList<TrackPoint> currentSegment = new LinkedList<>();
@@ -237,7 +237,7 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
break; break;
case TAG_EXTENSION_DISTANCE: case TAG_EXTENSION_DISTANCE:
if (content != null) { if (content != null) {
distance = content.trim(); sensorDistance = content.trim();
} }
break; break;
} }
@@ -335,11 +335,11 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
throw new ParsingException(createErrorMessage(String.format(Locale.US, "Unable to parse altitude loss: %s", loss)), e); throw new ParsingException(createErrorMessage(String.format(Locale.US, "Unable to parse altitude loss: %s", loss)), e);
} }
} }
if (distance != null) { if (sensorDistance != null) {
try { try {
trackPoint.setSensorDistance(Distance.of(distance)); trackPoint.setSensorDistance(Distance.of(sensorDistance));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new ParsingException(createErrorMessage(String.format(Locale.US, "Unable to parse distance: %s", distance)), e); throw new ParsingException(createErrorMessage(String.format(Locale.US, "Unable to parse distance: %s", sensorDistance)), e);
} }
} }
@@ -352,9 +352,14 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
altitude = null; altitude = null;
time = null; time = null;
speed = null; speed = null;
power = null;
gain = null; gain = null;
loss = null; loss = null;
sensorDistance = null;
power = null;
heartrate = null;
cadence = null;
} }
private void onMarkerStart(Attributes attributes) { private void onMarkerStart(Attributes attributes) {