forked from upstream-mirrors/OpenTracks
Removed TripStatistics from Waypoints.
This commit is contained in:
+8
-7
@@ -336,7 +336,6 @@ public class CustomContentProviderUtilsTest {
|
||||
public void testCreateContentValues_waypoint() {
|
||||
long trackId = System.currentTimeMillis();
|
||||
Track track = TestDataUtil.getTrack(trackId, 10);
|
||||
contentProviderUtils.insertTrack(track);
|
||||
// Bottom
|
||||
long startTime = 1000L;
|
||||
// AverageSpeed
|
||||
@@ -354,10 +353,13 @@ public class CustomContentProviderUtilsTest {
|
||||
statistics.setMaxGrade(15.0);
|
||||
statistics.setMinGrade(minGrade);
|
||||
statistics.setBounds(-10000, 20000, 30000, -40000);
|
||||
|
||||
track.setTripStatistics(statistics);
|
||||
contentProviderUtils.insertTrack(track);
|
||||
|
||||
// Insert at first.
|
||||
Waypoint waypoint = new Waypoint();
|
||||
waypoint.setDescription(TEST_DESC);
|
||||
waypoint.setTripStatistics(statistics);
|
||||
|
||||
Location location = new Location("test");
|
||||
location.setLatitude(22);
|
||||
@@ -375,8 +377,6 @@ public class CustomContentProviderUtilsTest {
|
||||
Assert.assertEquals(waypointId, contentValues.get(WaypointsColumns._ID));
|
||||
Assert.assertEquals(22 * 1000000, contentValues.get(WaypointsColumns.LONGITUDE));
|
||||
Assert.assertEquals(TEST_DESC, contentValues.get(WaypointsColumns.DESCRIPTION));
|
||||
Assert.assertEquals(startTime, contentValues.get(WaypointsColumns.STARTTIME));
|
||||
Assert.assertEquals(minGrade, contentValues.get(WaypointsColumns.MINGRADE));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -445,7 +445,6 @@ public class CustomContentProviderUtilsTest {
|
||||
public void testDeleteWaypoint_hasNextWayPoint() {
|
||||
long trackId = System.currentTimeMillis();
|
||||
Track track = TestDataUtil.getTrack(trackId, 10);
|
||||
contentProviderUtils.insertTrack(track);
|
||||
|
||||
TripStatistics statistics = new TripStatistics();
|
||||
statistics.setStartTime(1000L);
|
||||
@@ -461,17 +460,19 @@ public class CustomContentProviderUtilsTest {
|
||||
statistics.setMinGrade(-25.0);
|
||||
statistics.setBounds(-10000, 20000, 30000, -40000);
|
||||
|
||||
track.setTripStatistics(statistics);
|
||||
contentProviderUtils.insertTrack(track);
|
||||
|
||||
|
||||
// Insert at first.
|
||||
Waypoint waypoint1 = new Waypoint();
|
||||
waypoint1.setDescription(MOCK_DESC);
|
||||
waypoint1.setTrackId(trackId);
|
||||
waypoint1.setTripStatistics(statistics);
|
||||
long waypoint1Id = ContentUris.parseId(contentProviderUtils.insertWaypoint(waypoint1));
|
||||
|
||||
Waypoint waypoint2 = new Waypoint();
|
||||
waypoint2.setDescription(MOCK_DESC);
|
||||
waypoint2.setTrackId(trackId);
|
||||
waypoint2.setTripStatistics(statistics);
|
||||
long waypoint2Id = ContentUris.parseId(contentProviderUtils.insertWaypoint(waypoint2));
|
||||
|
||||
// Delete
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
import de.dennisguse.opentracks.stats.TripStatistics;
|
||||
import de.dennisguse.opentracks.util.StringUtils;
|
||||
|
||||
@@ -93,41 +92,6 @@ public class DescriptionGeneratorTest {
|
||||
Assert.assertEquals(expected, descriptionGenerator.generateTrackDescription(track, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link DescriptionGenerator#generateWaypointDescription(TripStatistics)}.
|
||||
*/
|
||||
@Test
|
||||
public void testGenerateWaypointDescription() {
|
||||
Waypoint waypoint = new Waypoint();
|
||||
TripStatistics stats = new TripStatistics();
|
||||
stats.setTotalDistance(20000);
|
||||
stats.setTotalTime(600000);
|
||||
stats.setMovingTime(300000);
|
||||
stats.setMaxSpeed(100);
|
||||
stats.setMaxElevation(550);
|
||||
stats.setMinElevation(-500);
|
||||
stats.setTotalElevationGain(6000);
|
||||
stats.setMaxGrade(0.42);
|
||||
stats.setMinGrade(0.11);
|
||||
stats.setStartTime(START_TIME);
|
||||
waypoint.setTripStatistics(stats);
|
||||
String expected = "Total distance: 20.00 km (12.4 mi)\n"
|
||||
+ "Total time: 10:00\n"
|
||||
+ "Moving time: 05:00\n"
|
||||
+ "Average speed: 120.00 km/h (74.6 mi/h)\n"
|
||||
+ "Average moving speed: 240.00 km/h (149.1 mi/h)\n"
|
||||
+ "Max speed: 360.00 km/h (223.7 mi/h)\n"
|
||||
+ "Average pace: 0:30 min/km (0:48 min/mi)\n"
|
||||
+ "Average moving pace: 0:15 min/km (0:24 min/mi)\n"
|
||||
+ "Fastest pace: 0:10 min/km (0:16 min/mi)\n"
|
||||
+ "Max elevation: 550 m (1804 ft)\n"
|
||||
+ "Min elevation: -500 m (-1640 ft)\n"
|
||||
+ "Elevation gain: 6000 m (19685 ft)\n"
|
||||
+ "Max grade: 42 %\n"
|
||||
+ "Min grade: 11 %\n"
|
||||
+ "Recorded: " + StringUtils.formatDateTime(context, START_TIME) + "\n";
|
||||
Assert.assertEquals(expected, descriptionGenerator.generateWaypointDescription(waypoint.getTripStatistics()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link DescriptionGenerator#writeDistance(double, StringBuilder, int, String)}.
|
||||
|
||||
@@ -250,7 +250,6 @@ public class TrackRecordingServiceTest {
|
||||
Assert.assertEquals(trackId, wpt.getTrackId());
|
||||
Assert.assertEquals(0.0, wpt.getLength(), 0.01);
|
||||
Assert.assertNotNull(wpt.getLocation());
|
||||
Assert.assertNull(wpt.getTripStatistics());
|
||||
|
||||
service.endCurrentTrack();
|
||||
}
|
||||
|
||||
@@ -403,12 +403,8 @@ public class ContentProviderUtils {
|
||||
int categoryIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.CATEGORY);
|
||||
int iconIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.ICON);
|
||||
int trackIdIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.TRACKID);
|
||||
int typeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.TYPE);
|
||||
int lengthIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.LENGTH);
|
||||
int durationIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.DURATION);
|
||||
int startTimeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.STARTTIME);
|
||||
int startIdIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.STARTID);
|
||||
int stopIdIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.STOPID);
|
||||
int longitudeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.LONGITUDE);
|
||||
int latitudeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.LATITUDE);
|
||||
int timeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.TIME);
|
||||
@@ -416,15 +412,6 @@ public class ContentProviderUtils {
|
||||
int accuracyIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.ACCURACY);
|
||||
int speedIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.SPEED);
|
||||
int bearingIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.BEARING);
|
||||
int totalDistanceIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.TOTALDISTANCE);
|
||||
int totalTimeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.TOTALTIME);
|
||||
int movingTimeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.MOVINGTIME);
|
||||
int maxSpeedIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.MAXSPEED);
|
||||
int minElevationIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.MINELEVATION);
|
||||
int maxElevationIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.MAXELEVATION);
|
||||
int elevationGainIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.ELEVATIONGAIN);
|
||||
int minGradeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.MINGRADE);
|
||||
int maxGradeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.MAXGRADE);
|
||||
int photoUrlIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.PHOTOURL);
|
||||
|
||||
Waypoint waypoint = new Waypoint();
|
||||
@@ -476,49 +463,6 @@ public class ContentProviderUtils {
|
||||
}
|
||||
waypoint.setLocation(location);
|
||||
|
||||
TripStatistics tripStatistics = new TripStatistics();
|
||||
boolean hasTripStatistics = false;
|
||||
if (!cursor.isNull(startTimeIndex)) {
|
||||
tripStatistics.setStartTime(cursor.getLong(startTimeIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
if (!cursor.isNull(totalDistanceIndex)) {
|
||||
tripStatistics.setTotalDistance(cursor.getFloat(totalDistanceIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
if (!cursor.isNull(totalTimeIndex)) {
|
||||
tripStatistics.setTotalTime(cursor.getLong(totalTimeIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
if (!cursor.isNull(movingTimeIndex)) {
|
||||
tripStatistics.setMovingTime(cursor.getLong(movingTimeIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
if (!cursor.isNull(maxSpeedIndex)) {
|
||||
tripStatistics.setMaxSpeed(cursor.getFloat(maxSpeedIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
if (!cursor.isNull(minElevationIndex)) {
|
||||
tripStatistics.setMinElevation(cursor.getFloat(minElevationIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
if (!cursor.isNull(maxElevationIndex)) {
|
||||
tripStatistics.setMaxElevation(cursor.getFloat(maxElevationIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
if (!cursor.isNull(elevationGainIndex)) {
|
||||
tripStatistics.setTotalElevationGain(cursor.getFloat(elevationGainIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
if (!cursor.isNull(minGradeIndex)) {
|
||||
tripStatistics.setMinGrade(cursor.getFloat(minGradeIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
if (!cursor.isNull(maxGradeIndex)) {
|
||||
tripStatistics.setMaxGrade(cursor.getFloat(maxGradeIndex));
|
||||
hasTripStatistics = true;
|
||||
}
|
||||
|
||||
if (!cursor.isNull(photoUrlIndex)) {
|
||||
waypoint.setPhotoUrl(cursor.getString(photoUrlIndex));
|
||||
}
|
||||
|
||||
@@ -72,15 +72,6 @@ public class DescriptionGenerator {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a waypoint description from a trip statistics.
|
||||
*
|
||||
* @param tripStatistics the trip statistics
|
||||
*/
|
||||
public String generateWaypointDescription(TripStatistics tripStatistics) {
|
||||
return generateTripStatisticsDescription(tripStatistics, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string to a string builder.
|
||||
*
|
||||
|
||||
@@ -59,17 +59,29 @@ public interface WaypointsColumns extends BaseColumns {
|
||||
String SPEED = "speed"; // speed
|
||||
String BEARING = "bearing"; // bearing
|
||||
|
||||
@Deprecated
|
||||
String TOTALDISTANCE = "totaldistance"; // total distance
|
||||
@Deprecated
|
||||
String TOTALTIME = "totaltime"; // total time
|
||||
@Deprecated
|
||||
String MOVINGTIME = "movingtime"; // moving time
|
||||
@Deprecated
|
||||
String AVGSPEED = "avgspeed"; // average speed
|
||||
String AVGMOVINGSPEED = "avgmovingspeed"; // average moving speed
|
||||
String MAXSPEED = "maxspeed"; // max speed
|
||||
String MINELEVATION = "minelevation"; // min elevation
|
||||
String MAXELEVATION = "maxelevation"; // max elevation
|
||||
String ELEVATIONGAIN = "elevationgain"; // elevation gain
|
||||
String MINGRADE = "mingrade"; // min grade
|
||||
String MAXGRADE = "maxgrade"; // max grade
|
||||
|
||||
@Deprecated
|
||||
String AVGMOVINGSPEED = "avgmovingspeed"; // average moving speed // TODO UNUSED
|
||||
@Deprecated
|
||||
String MAXSPEED = "maxspeed"; // max speed // TODO UNUSED
|
||||
@Deprecated
|
||||
String MINELEVATION = "minelevation"; // min elevation // TODO UNUSED
|
||||
@Deprecated
|
||||
String MAXELEVATION = "maxelevation"; // max elevation // TODO UNUSED
|
||||
@Deprecated
|
||||
String ELEVATIONGAIN = "elevationgain"; // elevation gain // TODO UNUSED
|
||||
@Deprecated
|
||||
String MINGRADE = "mingrade"; // min grade // TODO UNUSED
|
||||
@Deprecated
|
||||
String MAXGRADE = "maxgrade"; // max grade // TODO UNUSED
|
||||
|
||||
String PHOTOURL = "photoUrl"; // url for the photo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user