use of nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint in project Gadgetbridge by Freeyourgadget.
the class GPXExporterTest method shouldCreateValidGpxFromSimulatedData.
@Test
public void shouldCreateValidGpxFromSimulatedData() throws IOException, ParseException, GPXTrackEmptyException, SAXException {
final List<ActivityPoint> points = readActivityPoints("/GPXExporterTest-SampleTracks.csv");
final GPXExporter gpxExporter = new GPXExporter();
gpxExporter.setCreator("Gadgetbridge Test");
final ActivityTrack track = createTestTrack(points);
final File tempFile = File.createTempFile("gpx-exporter-test-track", ".gpx");
tempFile.deleteOnExit();
gpxExporter.performExport(track, tempFile);
validateGpxFile(tempFile);
}
use of nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint in project Gadgetbridge by Freeyourgadget.
the class GPXExporter method exportTrackpointExtensions.
private void exportTrackpointExtensions(XmlSerializer ser, ActivityPoint point, List<ActivityPoint> trackPoints) throws IOException {
if (!includeHeartRate) {
return;
}
int hr = point.getHeartRate();
if (!HeartRateUtils.getInstance().isValidHeartRateValue(hr)) {
if (!includeHeartRateOfNearestSample) {
return;
}
ActivityPoint closestPointItem = findClosestSensibleActivityPoint(point.getTime(), trackPoints);
if (closestPointItem == null) {
return;
}
hr = closestPointItem.getHeartRate();
if (!HeartRateUtils.getInstance().isValidHeartRateValue(hr)) {
return;
}
}
ser.startTag(NS_GPX_URI, "extensions");
ser.setPrefix(NS_TRACKPOINT_EXTENSION, NS_TRACKPOINT_EXTENSION_URI);
ser.startTag(NS_TRACKPOINT_EXTENSION_URI, "TrackPointExtension");
ser.startTag(NS_TRACKPOINT_EXTENSION_URI, "hr").text(String.valueOf(hr)).endTag(NS_TRACKPOINT_EXTENSION_URI, "hr");
ser.endTag(NS_TRACKPOINT_EXTENSION_URI, "TrackPointExtension");
ser.endTag(NS_GPX_URI, "extensions");
}
Aggregations