forked from upstream-mirrors/OpenTracks
Trying to track down the missing end of track bug.
This commit is contained in:
@@ -1001,29 +1001,36 @@ public class MyTracksMap extends MapActivity
|
|||||||
setSamplingFrequency(selectedTrack);
|
setSamplingFrequency(selectedTrack);
|
||||||
int bufferSize = 1024;
|
int bufferSize = 1024;
|
||||||
int points = 0;
|
int points = 0;
|
||||||
while (lastSeenLocationId < selectedTrack.getStopId()) {
|
long tailLocationId = selectedTrack.getStopId() - 10;
|
||||||
|
while (lastSeenLocationId < (selectedTrack.getStopId() + 10)) {
|
||||||
cursor = providerUtils.getLocationsCursor(
|
cursor = providerUtils.getLocationsCursor(
|
||||||
selectedTrack.getId(), lastSeenLocationId, bufferSize, false);
|
selectedTrack.getId(), lastSeenLocationId + 1, bufferSize, false);
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
final int idColumnIdx = cursor.getColumnIndexOrThrow(
|
final int idColumnIdx = cursor.getColumnIndexOrThrow(
|
||||||
TrackPointsColumns._ID);
|
TrackPointsColumns._ID);
|
||||||
while (cursor.moveToNext()) {
|
do {
|
||||||
points++;
|
points++;
|
||||||
Location location = providerUtils.createLocation(cursor);
|
Location location = providerUtils.createLocation(cursor);
|
||||||
lastSeenLocationId = cursor.getLong(idColumnIdx);
|
lastSeenLocationId = cursor.getLong(idColumnIdx);
|
||||||
// Include a point if it fits one of the following criteria:
|
// Include a point if it fits one of the following criteria:
|
||||||
// - Has the mod for the sampling frequency.
|
// - Has the mod for the sampling frequency.
|
||||||
// - Is the first point.
|
// - Is the first point.
|
||||||
// - Is the last point and we are not recording this track.
|
// - Is on of the last n points.
|
||||||
|
// => This is to make sure we draw the last points people are probably zoomed in to.
|
||||||
if (!MyTracksUtils.isValidLocation(location) ||
|
if (!MyTracksUtils.isValidLocation(location) ||
|
||||||
points % samplingFrequency == 0 ||
|
points % samplingFrequency == 0 ||
|
||||||
points == 0 ||
|
points == 0 ||
|
||||||
(recordingTrackId != selectedTrack.getId() &&
|
lastSeenLocationId > tailLocationId) {
|
||||||
points == (totalLocations - 1))) {
|
|
||||||
mapOverlay.addLocation(location);
|
mapOverlay.addLocation(location);
|
||||||
}
|
}
|
||||||
}
|
} while (cursor.moveToNext());
|
||||||
} else {
|
} else {
|
||||||
|
// TODO this is wrong sometimes. Should just return.
|
||||||
|
if (lastSeenLocationId >= selectedTrack.getStopId()) {
|
||||||
|
cursor.close();
|
||||||
|
mapView.postInvalidate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
lastSeenLocationId += bufferSize;
|
lastSeenLocationId += bufferSize;
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import android.graphics.Point;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -221,14 +222,31 @@ public class MyTracksOverlay extends Overlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the current viewing window:
|
// Get the current viewing window:
|
||||||
int w = mapView.getLongitudeSpan();
|
int w = mapView.getLongitudeSpan() * 2;
|
||||||
int h = mapView.getLatitudeSpan();
|
int h = mapView.getLatitudeSpan() * 2;
|
||||||
int cx = mapView.getMapCenter().getLongitudeE6();
|
int cx = mapView.getMapCenter().getLongitudeE6();
|
||||||
int cy = mapView.getMapCenter().getLatitudeE6();
|
int cy = mapView.getMapCenter().getLatitudeE6();
|
||||||
Rect rect = new Rect(cx - w, cy - h, cx + w, cy + h);
|
Rect rect = new Rect(cx - w, cy - h, cx + w, cy + h);
|
||||||
|
Log.i(MyTracksConstants.TAG,
|
||||||
|
"Found bounding box: " + rect);
|
||||||
|
|
||||||
Point pt = new Point();
|
Point pt = new Point();
|
||||||
|
GeoPoint upperLeft = new GeoPoint(rect.top, rect.left);
|
||||||
|
Point pUpperLeft = new Point();
|
||||||
|
mapView.getProjection().toPixels(upperLeft, pUpperLeft);
|
||||||
|
GeoPoint bottomRight = new GeoPoint(rect.bottom, rect.right);
|
||||||
|
Point pBottomRight = new Point();
|
||||||
|
mapView.getProjection().toPixels(upperLeft, pBottomRight);
|
||||||
|
Rect dispRect = new Rect(pUpperLeft.x, pUpperLeft.y,
|
||||||
|
pBottomRight.x, pBottomRight.y);
|
||||||
|
Log.i(MyTracksConstants.TAG,
|
||||||
|
"Found display box: " + rect);
|
||||||
|
canvas.drawRect(dispRect, selectedTrackPaint);
|
||||||
|
|
||||||
|
Rect displayRect;
|
||||||
GeoPoint geoPoint;
|
GeoPoint geoPoint;
|
||||||
|
|
||||||
|
|
||||||
Location loc;
|
Location loc;
|
||||||
Location lastValidLocation = null;
|
Location lastValidLocation = null;
|
||||||
Path path;
|
Path path;
|
||||||
|
|||||||
@@ -411,8 +411,8 @@ public class TripStatistics implements Parcelable {
|
|||||||
* @param bottomE6 the southmost latitude reached
|
* @param bottomE6 the southmost latitude reached
|
||||||
*/
|
*/
|
||||||
public void setBounds(int leftE6, int topE6, int rightE6, int bottomE6) {
|
public void setBounds(int leftE6, int topE6, int rightE6, int bottomE6) {
|
||||||
latitudeExtremities.set(bottomE6, topE6);
|
latitudeExtremities.set(bottomE6 / 1E6, topE6 / 1E6);
|
||||||
longitudeExtremities.set(leftE6, rightE6);
|
longitudeExtremities.set(leftE6 / 1E6, rightE6 / 1E6);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data manipulation methods
|
// Data manipulation methods
|
||||||
|
|||||||
Reference in New Issue
Block a user