Search in sources :

Example 11 with ActivityPoint

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);
}
Also used : ActivityPoint(nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint) ActivityTrack(nodomain.freeyourgadget.gadgetbridge.model.ActivityTrack) File(java.io.File) Test(org.junit.Test)

Example 12 with ActivityPoint

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");
}
Also used : ActivityPoint(nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint) ActivityPoint(nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint)

Aggregations

ActivityPoint (nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint)12 ActivityTrack (nodomain.freeyourgadget.gadgetbridge.model.ActivityTrack)5 Test (org.junit.Test)4 File (java.io.File)3 InputStream (java.io.InputStream)3 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2 BipActivitySummary (nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.BipActivitySummary)2 GPSCoordinate (nodomain.freeyourgadget.gadgetbridge.model.GPSCoordinate)2 HuamiActivityDetailsParser (nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiActivityDetailsParser)2 Nullable (androidx.annotation.Nullable)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 ParsePosition (java.text.ParsePosition)1 GBException (nodomain.freeyourgadget.gadgetbridge.GBException)1 HeartRateUtils (nodomain.freeyourgadget.gadgetbridge.activities.HeartRateUtils)1 Device (nodomain.freeyourgadget.gadgetbridge.entities.Device)1 User (nodomain.freeyourgadget.gadgetbridge.entities.User)1 GPXExporter (nodomain.freeyourgadget.gadgetbridge.export.GPXExporter)1