forked from upstream-mirrors/OpenTracks
Removed TripStatists min/max latitude/longitude.
This also removed: search does not account for closer tracks (to current position).
This commit is contained in:
-2
@@ -352,7 +352,6 @@ public class CustomContentProviderUtilsTest {
|
||||
statistics.setMinElevation(1200.0);
|
||||
statistics.setMaxGrade(15.0);
|
||||
statistics.setMinGrade(minGrade);
|
||||
statistics.setBounds(-10000, 20000, 30000, -40000);
|
||||
|
||||
track.setTripStatistics(statistics);
|
||||
contentProviderUtils.insertTrack(track);
|
||||
@@ -458,7 +457,6 @@ public class CustomContentProviderUtilsTest {
|
||||
statistics.setMinElevation(1200.0);
|
||||
statistics.setMaxGrade(15.0);
|
||||
statistics.setMinGrade(-25.0);
|
||||
statistics.setBounds(-10000, 20000, 30000, -40000);
|
||||
|
||||
track.setTripStatistics(statistics);
|
||||
contentProviderUtils.insertTrack(track);
|
||||
|
||||
@@ -82,10 +82,6 @@ public class SearchEngineTest {
|
||||
stats.setStopTime(NOW);
|
||||
}
|
||||
|
||||
int latitude = (int) ((HERE.getLatitude() + distance) * 1E6);
|
||||
int longitude = (int) ((HERE.getLongitude() + distance) * 1E6);
|
||||
stats.setBounds(latitude, longitude, latitude, longitude);
|
||||
|
||||
Uri uri = providerUtils.insertTrack(track);
|
||||
return ContentUris.parseId(uri);
|
||||
}
|
||||
@@ -211,20 +207,6 @@ public class SearchEngineTest {
|
||||
assertWaypointResult(descriptionWaypointId, results.get(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchTrackDistance() {
|
||||
// All results match text, but they're at difference distances from the user.
|
||||
long farFarAwayId = insertTrack("aa", 0.3);
|
||||
long nearId = insertTrack("ab", 0.1);
|
||||
long farId = insertTrack("ac", 0.2);
|
||||
|
||||
SearchQuery query = new SearchQuery("a", HERE, -1, NOW);
|
||||
ArrayList<ScoredResult> results = new ArrayList<ScoredResult>(engine.search(query));
|
||||
|
||||
// Distance order.
|
||||
assertTrackResults(results, nearId, farId, farFarAwayId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWaypointDistance() {
|
||||
// All results match text, but they're at difference distances from the user.
|
||||
|
||||
@@ -34,15 +34,6 @@ public class TripStatisticsTest extends TestCase {
|
||||
statistics = new TripStatistics();
|
||||
}
|
||||
|
||||
public void testSetBounds() {
|
||||
// This is not a trivial setter, conversion happens in it
|
||||
statistics.setBounds(12345, -34567, 56789, -98765);
|
||||
assertEquals(12345, statistics.getLeft());
|
||||
assertEquals(-34567, statistics.getTop());
|
||||
assertEquals(56789, statistics.getRight());
|
||||
assertEquals(-98765, statistics.getBottom());
|
||||
}
|
||||
|
||||
public void testMerge() {
|
||||
TripStatistics statistics2 = new TripStatistics();
|
||||
statistics.setStartTime(1000L); // Resulting start time
|
||||
@@ -68,10 +59,6 @@ public class TripStatisticsTest extends TestCase {
|
||||
statistics2.setMaxGrade(35.0); // Resulting max grade
|
||||
statistics2.setMinGrade(0.0);
|
||||
|
||||
// Resulting bounds: -10000, 35000, 30000, -40000
|
||||
statistics.setBounds(-10000, 20000, 30000, -40000);
|
||||
statistics2.setBounds(-5000, 35000, 0, 20000);
|
||||
|
||||
statistics.merge(statistics2);
|
||||
|
||||
assertEquals(1000L, statistics.getStartTime());
|
||||
@@ -81,10 +68,6 @@ public class TripStatisticsTest extends TestCase {
|
||||
assertEquals(1100.0, statistics.getTotalDistance());
|
||||
assertEquals(900.0, statistics.getTotalElevationGain());
|
||||
assertEquals(statistics.getTotalDistance() / (statistics.getMovingTime() / 1000.0), statistics.getMaxSpeed());
|
||||
assertEquals(-10000, statistics.getLeft());
|
||||
assertEquals(30000, statistics.getRight());
|
||||
assertEquals(35000, statistics.getTop());
|
||||
assertEquals(-40000, statistics.getBottom());
|
||||
assertEquals(1200.0, statistics.getMinElevation());
|
||||
assertEquals(3575.0, statistics.getMaxElevation());
|
||||
assertEquals(-25.0, statistics.getMinGrade());
|
||||
|
||||
@@ -116,10 +116,6 @@ public class ContentProviderUtils {
|
||||
int totalDistanceIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALDISTANCE);
|
||||
int totalTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALTIME);
|
||||
int movingTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MOVINGTIME);
|
||||
int minLatIndex = cursor.getColumnIndexOrThrow(TracksColumns.MINLAT);
|
||||
int maxLatIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAXLAT);
|
||||
int minLonIndex = cursor.getColumnIndexOrThrow(TracksColumns.MINLON);
|
||||
int maxLonIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAXLON);
|
||||
int maxSpeedIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAXSPEED);
|
||||
int minElevationIndex = cursor.getColumnIndexOrThrow(TracksColumns.MINELEVATION);
|
||||
int maxElevationIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAXELEVATION);
|
||||
@@ -160,13 +156,6 @@ public class ContentProviderUtils {
|
||||
if (!cursor.isNull(movingTimeIndex)) {
|
||||
tripStatistics.setMovingTime(cursor.getLong(movingTimeIndex));
|
||||
}
|
||||
if (!cursor.isNull(minLatIndex) && !cursor.isNull(maxLatIndex) && !cursor.isNull(minLonIndex) && !cursor.isNull(maxLonIndex)) {
|
||||
int bottom = cursor.getInt(minLatIndex);
|
||||
int top = cursor.getInt(maxLatIndex);
|
||||
int left = cursor.getInt(minLonIndex);
|
||||
int right = cursor.getInt(maxLonIndex);
|
||||
tripStatistics.setBounds(left, top, right, bottom);
|
||||
}
|
||||
if (!cursor.isNull(maxSpeedIndex)) {
|
||||
tripStatistics.setMaxSpeed(cursor.getFloat(maxSpeedIndex));
|
||||
}
|
||||
@@ -350,10 +339,6 @@ public class ContentProviderUtils {
|
||||
values.put(TracksColumns.TOTALDISTANCE, tripStatistics.getTotalDistance());
|
||||
values.put(TracksColumns.TOTALTIME, tripStatistics.getTotalTime());
|
||||
values.put(TracksColumns.MOVINGTIME, tripStatistics.getMovingTime());
|
||||
values.put(TracksColumns.MINLAT, tripStatistics.getBottom());
|
||||
values.put(TracksColumns.MAXLAT, tripStatistics.getTop());
|
||||
values.put(TracksColumns.MINLON, tripStatistics.getLeft());
|
||||
values.put(TracksColumns.MAXLON, tripStatistics.getRight());
|
||||
values.put(TracksColumns.AVGSPEED, tripStatistics.getAverageSpeed());
|
||||
values.put(TracksColumns.AVGMOVINGSPEED, tripStatistics.getAverageMovingSpeed());
|
||||
values.put(TracksColumns.MAXSPEED, tripStatistics.getMaxSpeed());
|
||||
|
||||
@@ -247,7 +247,6 @@ public class SearchEngine {
|
||||
score *= getTitleBoost(query, track.getName(), track.getDescription(), track.getCategory());
|
||||
|
||||
TripStatistics statistics = track.getTripStatistics();
|
||||
score *= getDistanceBoost(query, statistics.getMeanLatitude(), statistics.getMeanLongitude());
|
||||
|
||||
long meanTimestamp = (statistics.getStartTime() + statistics.getStopTime()) / 2L;
|
||||
score *= getTimeBoost(query, meanTimestamp);
|
||||
|
||||
@@ -48,14 +48,18 @@ public interface TracksColumns extends BaseColumns {
|
||||
String TOTALDISTANCE = "totaldistance"; // total distance
|
||||
String TOTALTIME = "totaltime"; // total time
|
||||
String MOVINGTIME = "movingtime"; // moving time
|
||||
String MINLAT = "minlat"; // minimum latitude
|
||||
String MAXLAT = "maxlat"; // maximum latitude
|
||||
String MINLON = "minlon"; // minimum longitude
|
||||
String MAXLON = "maxlon"; // maximum longitude
|
||||
String AVGSPEED = "avgspeed"; // average speed
|
||||
|
||||
// average moving speed
|
||||
String AVGMOVINGSPEED = "avgmovingspeed";
|
||||
@Deprecated
|
||||
String MINLAT = "minlat"; // minimum latitude // TODO UNUSED
|
||||
@Deprecated
|
||||
String MAXLAT = "maxlat"; // maximum latitude // TODO UNUSED
|
||||
@Deprecated
|
||||
String MINLON = "minlon"; // minimum longitude //TODO UNUSED
|
||||
@Deprecated
|
||||
String MAXLON = "maxlon"; // maximum longitude //TODO UNUSED
|
||||
|
||||
String AVGSPEED = "avgspeed"; // average speed
|
||||
String AVGMOVINGSPEED = "avgmovingspeed"; // average moving speed
|
||||
String MAXSPEED = "maxspeed"; // maximum speed
|
||||
String MINELEVATION = "minelevation"; // minimum elevation
|
||||
String MAXELEVATION = "maxelevation"; // maximum elevation
|
||||
|
||||
@@ -26,10 +26,6 @@ import androidx.annotation.NonNull;
|
||||
*/
|
||||
public class TripStatistics {
|
||||
|
||||
// The min and max latitude seen in this trip.
|
||||
private final ExtremityMonitor latitudeExtremities = new ExtremityMonitor();
|
||||
// The min and max longitude seen in this trip.
|
||||
private final ExtremityMonitor longitudeExtremities = new ExtremityMonitor();
|
||||
// The min and max elevation (meters) seen on this trip.
|
||||
private final ExtremityMonitor elevationExtremities = new ExtremityMonitor();
|
||||
// The min and max grade seen on this trip.
|
||||
@@ -64,8 +60,6 @@ public class TripStatistics {
|
||||
totalDistance_m = other.totalDistance_m;
|
||||
totalTime_ms = other.totalTime_ms;
|
||||
movingTime_ms = other.movingTime_ms;
|
||||
latitudeExtremities.set(other.latitudeExtremities.getMin(), other.latitudeExtremities.getMax());
|
||||
longitudeExtremities.set(other.longitudeExtremities.getMin(), other.longitudeExtremities.getMax());
|
||||
maxSpeed_mps = other.maxSpeed_mps;
|
||||
elevationExtremities.set(other.elevationExtremities.getMin(), other.elevationExtremities.getMax());
|
||||
totalElevationGain_m = other.totalElevationGain_m;
|
||||
@@ -84,14 +78,6 @@ public class TripStatistics {
|
||||
totalDistance_m += other.totalDistance_m;
|
||||
totalTime_ms += other.totalTime_ms;
|
||||
movingTime_ms += other.movingTime_ms;
|
||||
if (other.latitudeExtremities.hasData()) {
|
||||
latitudeExtremities.update(other.latitudeExtremities.getMin());
|
||||
latitudeExtremities.update(other.latitudeExtremities.getMax());
|
||||
}
|
||||
if (other.longitudeExtremities.hasData()) {
|
||||
longitudeExtremities.update(other.longitudeExtremities.getMin());
|
||||
longitudeExtremities.update(other.longitudeExtremities.getMax());
|
||||
}
|
||||
maxSpeed_mps = Math.max(maxSpeed_mps, other.maxSpeed_mps);
|
||||
if (other.elevationExtremities.hasData()) {
|
||||
elevationExtremities.update(other.elevationExtremities.getMin());
|
||||
@@ -160,59 +146,6 @@ public class TripStatistics {
|
||||
movingTime_ms += time_ms;
|
||||
}
|
||||
|
||||
public double getTopDegrees() {
|
||||
return latitudeExtremities.getMax();
|
||||
}
|
||||
|
||||
public int getTop() {
|
||||
return (int) (latitudeExtremities.getMax() * 1E6);
|
||||
}
|
||||
|
||||
public double getBottomDegrees() {
|
||||
return latitudeExtremities.getMin();
|
||||
}
|
||||
|
||||
public int getBottom() {
|
||||
return (int) (latitudeExtremities.getMin() * 1E6);
|
||||
}
|
||||
|
||||
public double getLeftDegrees() {
|
||||
return longitudeExtremities.getMin();
|
||||
}
|
||||
|
||||
public int getLeft() {
|
||||
return (int) (longitudeExtremities.getMin() * 1E6);
|
||||
}
|
||||
|
||||
public double getRightDegrees() {
|
||||
return longitudeExtremities.getMax();
|
||||
}
|
||||
|
||||
public int getRight() {
|
||||
return (int) (longitudeExtremities.getMax() * 1E6);
|
||||
}
|
||||
|
||||
public double getMeanLatitude() {
|
||||
return (getBottomDegrees() + getTopDegrees()) / 2.0;
|
||||
}
|
||||
|
||||
public double getMeanLongitude() {
|
||||
return (getLeftDegrees() + getRightDegrees()) / 2.0;
|
||||
}
|
||||
|
||||
public void setBounds(int leftE6, int topE6, int rightE6, int bottomE6) {
|
||||
latitudeExtremities.set(bottomE6 / 1E6, topE6 / 1E6);
|
||||
longitudeExtremities.set(leftE6 / 1E6, rightE6 / 1E6);
|
||||
}
|
||||
|
||||
public void updateLatitudeExtremities(double latitude) {
|
||||
latitudeExtremities.update(latitude);
|
||||
}
|
||||
|
||||
public void updateLongitudeExtremities(double longitude) {
|
||||
longitudeExtremities.update(longitude);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the average speed in meters/second.
|
||||
* This calculation only takes into account the displacement until the last point that was accounted for in statistics.
|
||||
@@ -338,9 +271,7 @@ public class TripStatistics {
|
||||
public String toString() {
|
||||
return "TripStatistics { Start Time: " + getStartTime() + "; Stop Time: " + getStopTime()
|
||||
+ "; Total Distance: " + getTotalDistance() + "; Total Time: " + getTotalTime()
|
||||
+ "; Moving Time: " + getMovingTime() + "; Min Latitude: " + getBottomDegrees()
|
||||
+ "; Max Latitude: " + getTopDegrees() + "; Min Longitude: " + getLeftDegrees()
|
||||
+ "; Max Longitude: " + getRightDegrees() + "; Max Speed: " + getMaxSpeed()
|
||||
+ "; Moving Time: " + getMovingTime() + "; Max Speed: " + getMaxSpeed()
|
||||
+ "; Min Elevation: " + getMinElevation() + "; Max Elevation: " + getMaxElevation()
|
||||
+ "; Elevation Gain: " + getTotalElevationGain() + "; Min Grade: " + getMinGrade()
|
||||
+ "; Max Grade: " + getMaxGrade() + "}";
|
||||
|
||||
@@ -138,9 +138,6 @@ public class TripStatisticsUpdater {
|
||||
return;
|
||||
}
|
||||
|
||||
currentSegment.updateLatitudeExtremities(location.getLatitude());
|
||||
currentSegment.updateLongitudeExtremities(location.getLongitude());
|
||||
|
||||
//TODO Use Barometer to compute elevation gain.
|
||||
double elevationDifference = location.hasAltitude() ? updateElevation(location.getAltitude()) : 0.0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user