use of nodomain.freeyourgadget.gadgetbridge.util.GpxParser in project Gadgetbridge by Freeyourgadget.
the class ActivitySummariesGpsFragment method processInBackgroundThread.
private void processInBackgroundThread() {
final Canvas canvas = createCanvas(gpsView);
new Thread(new Runnable() {
@Override
public void run() {
GpxParser gpxParser = null;
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(inputFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
if (inputStream != null) {
gpxParser = new GpxParser(inputStream);
}
if (gpxParser != null) {
if (gpxParser.getPoints().toArray().length > 0) {
drawTrack(canvas, gpxParser.getPoints());
}
}
}
}).start();
}
use of nodomain.freeyourgadget.gadgetbridge.util.GpxParser in project Gadgetbridge by Freeyourgadget.
the class GPXParserTest method shouldReadGPXCorrectly.
@Test
public void shouldReadGPXCorrectly() throws IOException {
try (final InputStream inputStream = getClass().getResourceAsStream("/gpx-exporter-test-SampleTrack.gpx")) {
GpxParser gpxParser = new GpxParser(inputStream);
List<GPSCoordinate> trackPoints = gpxParser.getPoints();
Assert.assertEquals(trackPoints.size(), 14);
DecimalFormat df = new DecimalFormat("###.##");
for (GPSCoordinate tp : trackPoints) {
Assert.assertEquals(df.format(tp.getLongitude()), "44.15");
Assert.assertEquals(df.format(tp.getLatitude()), "-68.2");
Assert.assertThat(df.format(tp.getAltitude()), anyOf(is("40"), is("46")));
}
}
}
Aggregations