diff --git a/src/androidTest/java/de/dennisguse/opentracks/TrackStubUtils.java b/src/androidTest/java/de/dennisguse/opentracks/TrackStubUtils.java index 3bccd8869..4cdcdcf9e 100644 --- a/src/androidTest/java/de/dennisguse/opentracks/TrackStubUtils.java +++ b/src/androidTest/java/de/dennisguse/opentracks/TrackStubUtils.java @@ -18,7 +18,7 @@ package de.dennisguse.opentracks; import android.location.Location; -import de.dennisguse.opentracks.content.SensorDataSetLocation; +import de.dennisguse.opentracks.content.TrackPoint; import de.dennisguse.opentracks.content.data.Track; import de.dennisguse.opentracks.content.sensor.SensorDataSet; @@ -60,16 +60,16 @@ public class TrackStubUtils { * * @return a track stub. */ - public static SensorDataSetLocation createSensorDataSetLocation() { + public static TrackPoint createSensorDataSetLocation() { return createSensorDataSetLocation(INITIAL_LATITUDE, INITIAL_LONGITUDE, INITIAL_ALTITUDE); } /** - * Creates a {@link SensorDataSetLocation} stub with specified values. + * Creates a {@link TrackPoint} stub with specified values. * * @return a SensorDataSetLocation stub. */ - private static SensorDataSetLocation createSensorDataSetLocation(double latitude, double longitude, double altitude) { + private static TrackPoint createSensorDataSetLocation(double latitude, double longitude, double altitude) { // Initial Location Location loc = new Location(LOCATION_PROVIDER); loc.setLatitude(latitude); @@ -81,6 +81,6 @@ public class TrackStubUtils { loc.setBearing(INITIAL_BEARING); SensorDataSet sd = new SensorDataSet(Float.NaN, Float.NaN); - return new SensorDataSetLocation(loc, sd); + return new TrackPoint(loc, sd); } } diff --git a/src/androidTest/java/de/dennisguse/opentracks/fragments/ChartFragmentTest.java b/src/androidTest/java/de/dennisguse/opentracks/fragments/ChartFragmentTest.java index 7851db826..2277239d3 100644 --- a/src/androidTest/java/de/dennisguse/opentracks/fragments/ChartFragmentTest.java +++ b/src/androidTest/java/de/dennisguse/opentracks/fragments/ChartFragmentTest.java @@ -31,7 +31,7 @@ import org.junit.runner.RunWith; import de.dennisguse.opentracks.TrackStubUtils; import de.dennisguse.opentracks.chart.ChartView; -import de.dennisguse.opentracks.content.SensorDataSetLocation; +import de.dennisguse.opentracks.content.TrackPoint; import de.dennisguse.opentracks.content.sensor.SensorDataSet; import de.dennisguse.opentracks.util.UnitConversions; @@ -72,7 +72,7 @@ public class ChartFragmentTest { */ @Test public void testFillDataPoint_sensorIncorrect() { - SensorDataSetLocation sensorDataSetLocation = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation = TrackStubUtils.createSensorDataSetLocation(); // No input. double[] point = fillDataPointTestHelper(sensorDataSetLocation); @@ -96,7 +96,7 @@ public class ChartFragmentTest { */ @Test public void testFillDataPoint_sensorCorrect() { - SensorDataSetLocation sensorDataSetLocation = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation = TrackStubUtils.createSensorDataSetLocation(); // No input. double[] point = fillDataPointTestHelper(sensorDataSetLocation); Assert.assertEquals(Float.NaN, point[ChartView.HEART_RATE_SERIES + 1], 0.01); @@ -123,17 +123,17 @@ public class ChartFragmentTest { // By distance. chartFragment.setChartByDistance(true); // Resets last location and writes first location. - SensorDataSetLocation sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); double[] point = fillDataPointTestHelper(sensorDataSetLocation1); Assert.assertEquals(0.0, point[0], 0.01); // The second is a same location, just different time. - SensorDataSetLocation sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); point = fillDataPointTestHelper(sensorDataSetLocation2); Assert.assertEquals(0.0, point[0], 0.01); // The third location is a new location, and use metric. - SensorDataSetLocation sensorDataSetLocation3 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation3 = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation3.setLatitude(23); point = fillDataPointTestHelper(sensorDataSetLocation3); @@ -145,7 +145,7 @@ public class ChartFragmentTest { Assert.assertEquals(distance1, point[0], 0.01); // The fourth location is a new location, and use metric. - SensorDataSetLocation sensorDataSetLocation4 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation4 = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation4.setLatitude(24); point = fillDataPointTestHelper(sensorDataSetLocation4); @@ -167,12 +167,12 @@ public class ChartFragmentTest { chartFragment.setMetricUnits(false); // The first is a same location, just different time. - SensorDataSetLocation sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); double[] point = fillDataPointTestHelper(sensorDataSetLocation1); Assert.assertEquals(0.0, point[0], 0.01); // The second location is a new location, and use imperial. - SensorDataSetLocation sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation2.setLatitude(23); point = fillDataPointTestHelper(sensorDataSetLocation2); @@ -186,7 +186,7 @@ public class ChartFragmentTest { Assert.assertEquals(distance1, point[0], 0.01); // The third location is a new location, and use imperial. - SensorDataSetLocation sensorDataSetLocation3 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation3 = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation3.setLatitude(24); point = fillDataPointTestHelper(sensorDataSetLocation3); @@ -206,11 +206,11 @@ public class ChartFragmentTest { public void testFillDataPoint_time() { // By time chartFragment.setChartByDistance(false); - SensorDataSetLocation sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); double[] point = fillDataPointTestHelper(sensorDataSetLocation1); Assert.assertEquals(0.0, point[0], 0.01); long timeSpan = 222; - SensorDataSetLocation sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation2.setTime(sensorDataSetLocation1.getTime() + timeSpan); point = fillDataPointTestHelper(sensorDataSetLocation2); Assert.assertEquals((double) timeSpan, point[0], 0.01); @@ -221,7 +221,7 @@ public class ChartFragmentTest { */ @Test public void testFillDataPoint_elevation() { - SensorDataSetLocation sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); /* * At first, clear old points of elevation, so give true to the second parameter. @@ -233,7 +233,7 @@ public class ChartFragmentTest { /* * Send another value to buffer, now there are two values, INITIAL_ALTITUDE and INITIAL_ALTITUDE * 2. */ - SensorDataSetLocation sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation2.setAltitude(TrackStubUtils.INITIAL_ALTITUDE * 2); point = fillDataPointTestHelper(sensorDataSetLocation2); Assert.assertEquals((TrackStubUtils.INITIAL_ALTITUDE + TrackStubUtils.INITIAL_ALTITUDE * 2) / 2.0, @@ -251,7 +251,7 @@ public class ChartFragmentTest { * At first, clear old points of speed, so give true to the second parameter. * It will not be filled in to the speed buffer. */ - SensorDataSetLocation sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation1.setSpeed(128.5f); double[] point = fillDataPointTestHelper(sensorDataSetLocation1); Assert.assertEquals(0.0, point[ChartView.SPEED_SERIES + 1], 0.01); @@ -260,7 +260,7 @@ public class ChartFragmentTest { * Tests the logic when both metricUnits and reportSpeed are true. * This location will be filled into speed buffer. */ - SensorDataSetLocation sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); /* * Add a time span here to make sure the second point is valid, the value 222 here is doesn't matter. @@ -280,12 +280,12 @@ public class ChartFragmentTest { chartFragment.setMetricUnits(false); // First data point is not added to the speed buffer - SensorDataSetLocation sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation1.setSpeed(100.0f); double[] point = fillDataPointTestHelper(sensorDataSetLocation1); Assert.assertEquals(0.0, point[ChartView.SPEED_SERIES + 1], 0.01); - SensorDataSetLocation sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); /* * Add a time span here to make sure the second point and the speed is valid. @@ -306,12 +306,12 @@ public class ChartFragmentTest { chartFragment.setReportSpeed(false); // First data point is not added to the speed buffer - SensorDataSetLocation sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation1 = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation1.setSpeed(100.0f); double[] point = fillDataPointTestHelper(sensorDataSetLocation1); Assert.assertEquals(0.0, point[ChartView.SPEED_SERIES + 1], 0.01); - SensorDataSetLocation sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation2 = TrackStubUtils.createSensorDataSetLocation(); /* * Add a time span here to make sure the second point and the speed is valid. @@ -330,7 +330,7 @@ public class ChartFragmentTest { public void testFillDataPoint_pace_zeroSpeed() { // Setups reportSpeed to false. chartFragment.setReportSpeed(false); - SensorDataSetLocation sensorDataSetLocation = TrackStubUtils.createSensorDataSetLocation(); + TrackPoint sensorDataSetLocation = TrackStubUtils.createSensorDataSetLocation(); sensorDataSetLocation.setSpeed(0); double[] point = fillDataPointTestHelper(sensorDataSetLocation); Assert.assertEquals(0.0, point[ChartView.PACE_SERIES + 1], 0.01); diff --git a/src/main/java/de/dennisguse/opentracks/content/ContentProviderUtils.java b/src/main/java/de/dennisguse/opentracks/content/ContentProviderUtils.java index 27f2307c2..338716a48 100644 --- a/src/main/java/de/dennisguse/opentracks/content/ContentProviderUtils.java +++ b/src/main/java/de/dennisguse/opentracks/content/ContentProviderUtils.java @@ -732,7 +732,7 @@ public class ContentProviderUtils { * @param cursor the cursor pointing to the location */ public Location createTrackPoint(Cursor cursor) { - Location location = new SensorDataSetLocation(""); + Location location = new TrackPoint(""); fillTrackPoint(cursor, new CachedTrackPointsIndexes(cursor), location); return location; } @@ -994,8 +994,8 @@ public class ContentProviderUtils { } //SensorData - if (location instanceof SensorDataSetLocation) { - SensorDataSetLocation sensorDataSetLocation = (SensorDataSetLocation) location; + if (location instanceof TrackPoint) { + TrackPoint sensorDataSetLocation = (TrackPoint) location; SensorDataSet sensorDataSet = sensorDataSetLocation.getSensorDataSet(); if (sensorDataSet != null && sensorDataSet.hasHeartRate()) { values.put(TrackPointsColumns.SENSOR_HEARTRATE, sensorDataSetLocation.getSensorDataSet().getHeartRate()); @@ -1041,8 +1041,8 @@ public class ContentProviderUtils { if (!cursor.isNull(indexes.bearingIndex)) { location.setBearing(cursor.getFloat(indexes.bearingIndex)); } - if (location instanceof SensorDataSetLocation) { - SensorDataSetLocation sensorDataSetLocation = (SensorDataSetLocation) location; + if (location instanceof TrackPoint) { + TrackPoint sensorDataSetLocation = (TrackPoint) location; float heartRate = cursor.isNull(indexes.sensorHeartRateIndex) ? SensorDataSet.DATA_UNAVAILABLE : cursor.getFloat(indexes.sensorHeartRateIndex); float cadence = cursor.isNull(indexes.sensorCadenceIndex) ? SensorDataSet.DATA_UNAVAILABLE : cursor.getFloat(indexes.sensorCadenceIndex); diff --git a/src/main/java/de/dennisguse/opentracks/content/LocationFactory.java b/src/main/java/de/dennisguse/opentracks/content/LocationFactory.java index a52b3e6da..6527e27a3 100644 --- a/src/main/java/de/dennisguse/opentracks/content/LocationFactory.java +++ b/src/main/java/de/dennisguse/opentracks/content/LocationFactory.java @@ -4,7 +4,7 @@ import android.location.Location; import android.location.LocationManager; /** - * Creates a new {@link SensorDataSetLocation}. + * Creates a new {@link TrackPoint}. * An implementation can create new instances or reuse existing instances for optimization. */ public class LocationFactory { @@ -15,6 +15,6 @@ public class LocationFactory { public static LocationFactory DEFAULT_LOCATION_FACTORY = new LocationFactory(); public Location createLocation() { - return new SensorDataSetLocation(LocationManager.GPS_PROVIDER); + return new TrackPoint(LocationManager.GPS_PROVIDER); } } diff --git a/src/main/java/de/dennisguse/opentracks/content/SensorDataSetLocation.java b/src/main/java/de/dennisguse/opentracks/content/TrackPoint.java similarity index 87% rename from src/main/java/de/dennisguse/opentracks/content/SensorDataSetLocation.java rename to src/main/java/de/dennisguse/opentracks/content/TrackPoint.java index 341519e09..19f82759a 100644 --- a/src/main/java/de/dennisguse/opentracks/content/SensorDataSetLocation.java +++ b/src/main/java/de/dennisguse/opentracks/content/TrackPoint.java @@ -24,16 +24,16 @@ import de.dennisguse.opentracks.content.sensor.SensorDataSet; * * @author Sandor Dornbush */ -public class SensorDataSetLocation extends Location { +public class TrackPoint extends Location { private SensorDataSet sensorDataSet = null; - public SensorDataSetLocation(Location location, SensorDataSet sensorDataSet) { + public TrackPoint(Location location, SensorDataSet sensorDataSet) { super(location); this.sensorDataSet = sensorDataSet; } - public SensorDataSetLocation(String provider) { + public TrackPoint(String provider) { super(provider); } diff --git a/src/main/java/de/dennisguse/opentracks/fragments/ChartFragment.java b/src/main/java/de/dennisguse/opentracks/fragments/ChartFragment.java index 4f0b631b6..5aef964e5 100644 --- a/src/main/java/de/dennisguse/opentracks/fragments/ChartFragment.java +++ b/src/main/java/de/dennisguse/opentracks/fragments/ChartFragment.java @@ -36,10 +36,10 @@ import java.util.List; import de.dennisguse.opentracks.R; import de.dennisguse.opentracks.TrackDetailActivity; import de.dennisguse.opentracks.chart.ChartView; -import de.dennisguse.opentracks.content.SensorDataSetLocation; import de.dennisguse.opentracks.content.TrackDataHub; import de.dennisguse.opentracks.content.TrackDataListener; import de.dennisguse.opentracks.content.TrackDataType; +import de.dennisguse.opentracks.content.TrackPoint; import de.dennisguse.opentracks.content.data.Track; import de.dennisguse.opentracks.content.data.Waypoint; import de.dennisguse.opentracks.content.sensor.SensorDataSet; @@ -424,8 +424,8 @@ public abstract class ChartFragment extends Fragment implements TrackDataListene double heartRate = Double.NaN; double cadence = Double.NaN; double power = Double.NaN; - if (location instanceof SensorDataSetLocation && ((SensorDataSetLocation) location).getSensorDataSet() != null) { - SensorDataSet sensorDataSet = ((SensorDataSetLocation) location).getSensorDataSet(); + if (location instanceof TrackPoint && ((TrackPoint) location).getSensorDataSet() != null) { + SensorDataSet sensorDataSet = ((TrackPoint) location).getSensorDataSet(); if (sensorDataSet.hasHeartRate()) { heartRate = sensorDataSet.getHeartRate(); } diff --git a/src/main/java/de/dennisguse/opentracks/io/file/exporter/FileTrackExporter.java b/src/main/java/de/dennisguse/opentracks/io/file/exporter/FileTrackExporter.java index 313467bad..4004b72bd 100644 --- a/src/main/java/de/dennisguse/opentracks/io/file/exporter/FileTrackExporter.java +++ b/src/main/java/de/dennisguse/opentracks/io/file/exporter/FileTrackExporter.java @@ -28,7 +28,7 @@ import java.io.OutputStream; import de.dennisguse.opentracks.content.ContentProviderUtils; import de.dennisguse.opentracks.content.LocationFactory; import de.dennisguse.opentracks.content.LocationIterator; -import de.dennisguse.opentracks.content.SensorDataSetLocation; +import de.dennisguse.opentracks.content.TrackPoint; import de.dennisguse.opentracks.content.data.Track; import de.dennisguse.opentracks.content.data.Waypoint; import de.dennisguse.opentracks.util.LocationUtils; @@ -214,7 +214,7 @@ public class FileTrackExporter implements TrackExporter { @Override public Location createLocation() { if (currentLocation == null) { - currentLocation = new SensorDataSetLocation(""); + currentLocation = new TrackPoint(""); } return currentLocation; } diff --git a/src/main/java/de/dennisguse/opentracks/io/file/exporter/KmlTrackWriter.java b/src/main/java/de/dennisguse/opentracks/io/file/exporter/KmlTrackWriter.java index e1294884d..f73317e39 100644 --- a/src/main/java/de/dennisguse/opentracks/io/file/exporter/KmlTrackWriter.java +++ b/src/main/java/de/dennisguse/opentracks/io/file/exporter/KmlTrackWriter.java @@ -28,7 +28,7 @@ import java.util.List; import de.dennisguse.opentracks.R; import de.dennisguse.opentracks.content.ContentProviderUtils; import de.dennisguse.opentracks.content.DescriptionGenerator; -import de.dennisguse.opentracks.content.SensorDataSetLocation; +import de.dennisguse.opentracks.content.TrackPoint; import de.dennisguse.opentracks.content.data.Track; import de.dennisguse.opentracks.content.data.Waypoint; import de.dennisguse.opentracks.content.sensor.SensorDataSet; @@ -264,8 +264,8 @@ public class KmlTrackWriter implements TrackWriter { printWriter.println("" + getCoordinates(location, " ") + ""); - if (exportSensorData && location instanceof SensorDataSetLocation) { - SensorDataSet sensorDataSet = ((SensorDataSetLocation) location).getSensorDataSet(); + if (exportSensorData && location instanceof TrackPoint) { + SensorDataSet sensorDataSet = ((TrackPoint) location).getSensorDataSet(); if (sensorDataSet != null) { if (sensorDataSet.hasHeartRate()) { heartRateList.add(sensorDataSet.getHeartRate()); diff --git a/src/main/java/de/dennisguse/opentracks/io/file/importer/KmlFileTrackImporter.java b/src/main/java/de/dennisguse/opentracks/io/file/importer/KmlFileTrackImporter.java index 6af559b2e..5b7bd2ace 100644 --- a/src/main/java/de/dennisguse/opentracks/io/file/importer/KmlFileTrackImporter.java +++ b/src/main/java/de/dennisguse/opentracks/io/file/importer/KmlFileTrackImporter.java @@ -29,7 +29,7 @@ import org.xml.sax.SAXException; import java.util.ArrayList; import de.dennisguse.opentracks.content.ContentProviderUtils; -import de.dennisguse.opentracks.content.SensorDataSetLocation; +import de.dennisguse.opentracks.content.TrackPoint; import de.dennisguse.opentracks.content.sensor.SensorDataSet; import de.dennisguse.opentracks.io.file.exporter.KmlTrackWriter; @@ -248,7 +248,7 @@ public class KmlFileTrackImporter extends AbstractFileTrackImporter { if (!hasSensorData) { insertTrackPoint(location); } else { - SensorDataSetLocation sensorDataSetLocation = new SensorDataSetLocation(location, new SensorDataSet(heartrate, cadence, power, SensorDataSet.DATA_UNAVAILABLE, location.getTime())); + TrackPoint sensorDataSetLocation = new TrackPoint(location, new SensorDataSet(heartrate, cadence, power, SensorDataSet.DATA_UNAVAILABLE, location.getTime())); insertTrackPoint(sensorDataSetLocation); } } diff --git a/src/main/java/de/dennisguse/opentracks/services/TrackRecordingService.java b/src/main/java/de/dennisguse/opentracks/services/TrackRecordingService.java index d2dabc63d..34ebff4cf 100644 --- a/src/main/java/de/dennisguse/opentracks/services/TrackRecordingService.java +++ b/src/main/java/de/dennisguse/opentracks/services/TrackRecordingService.java @@ -46,7 +46,7 @@ import de.dennisguse.opentracks.content.ContentProviderUtils; import de.dennisguse.opentracks.content.CustomContentProvider; import de.dennisguse.opentracks.content.LocationFactory; import de.dennisguse.opentracks.content.LocationIterator; -import de.dennisguse.opentracks.content.SensorDataSetLocation; +import de.dennisguse.opentracks.content.TrackPoint; import de.dennisguse.opentracks.content.data.Track; import de.dennisguse.opentracks.content.data.Waypoint; import de.dennisguse.opentracks.content.sensor.SensorDataSet; @@ -612,7 +612,7 @@ public class TrackRecordingService extends Service { SensorDataSet sensorDataSet = getSensorDataSet(); if (sensorDataSet != null) { - location = new SensorDataSetLocation(location, sensorDataSet); + location = new TrackPoint(location, sensorDataSet); } // Always insert the first segment location