Fixing issue 148 - properly loading bounding boxes, and adding regression tests.

This commit is contained in:
Rodrigo Damazio
2010-09-07 16:32:46 -03:00
parent 2432b36f5d
commit 7781014cf7
4 changed files with 130 additions and 17 deletions
@@ -375,7 +375,6 @@ public class MyTracksMap extends MapActivity
}
}
@SuppressWarnings("deprecation")
protected void setupZoomControls() {
mapView.setBuiltInZoomControls(true);
}
@@ -640,14 +639,18 @@ public class MyTracksMap extends MapActivity
return;
}
TripStatistics stats = track.getStatistics();
int latSpanE6 = stats.getTop() - stats.getBottom();
int lonSpanE6 = stats.getRight() - stats.getLeft();
if (latSpanE6 > 0 && latSpanE6 < 180E6 && lonSpanE6 > 0
&& lonSpanE6 < 180E6) {
int bottom = stats.getBottom();
int left = stats.getLeft();
int latSpanE6 = stats.getTop() - bottom;
int lonSpanE6 = stats.getRight() - left;
if (latSpanE6 > 0
&& latSpanE6 < 180E6
&& lonSpanE6 > 0
&& lonSpanE6 < 360E6) {
keepMyLocationVisible = false;
GeoPoint center = new GeoPoint(
stats.getBottom() + latSpanE6 / 2,
stats.getLeft() + lonSpanE6 / 2);
bottom + latSpanE6 / 2,
left + lonSpanE6 / 2);
if (MyTracksUtils.isValidGeoPoint(center)) {
mapView.getController().setCenter(center);
mapView.getController().zoomToSpan(latSpanE6, lonSpanE6);
@@ -1026,9 +1029,6 @@ public class MyTracksMap extends MapActivity
cursor.close();
cursor = null;
}
if (cursor != null) {
cursor.close();
}
mapView.postInvalidate();
}
}
@@ -86,6 +86,13 @@ public class ExtremityMonitor {
* Sets the minimum and maximum values.
*/
public void set(double min, double max) {
// If the min is greater than the max and they were actually initialized to
// some values, then we have a problem.
if (min > max && !Double.isInfinite(max) && !Double.isInfinite(min)) {
throw new IllegalArgumentException(
"Invalid min: " + min + " vs max:" + max);
}
this.min = min;
this.max = max;
}
@@ -403,15 +403,16 @@ public class TripStatistics implements Parcelable {
/**
* Sets the bounding box for this trip.
* The unit for all parameters is signed decimal degrees (degrees * 1E6).
*
* @param left the westmost longitude reached
* @param top the northmost latitude reached
* @param right the eastmost longitude reached
* @param bottom the southmost latitude reached
* @param leftE6 the westmost longitude reached
* @param topE6 the northmost latitude reached
* @param rightE6 the eastmost longitude reached
* @param bottomE6 the southmost latitude reached
*/
public void setBounds(int left, int top, int right, int bottom) {
latitudeExtremities.set(bottom, top);
longitudeExtremities.set(left, right);
public void setBounds(int leftE6, int topE6, int rightE6, int bottomE6) {
latitudeExtremities.set(bottomE6 / 1E6, topE6 / 1E6);
longitudeExtremities.set(leftE6 / 1E6, rightE6 / 1E6);
}
// Data manipulation methods