[all] Remove redundant scale-related camera methods

We don't need to have two different measurement systems for map zoom.
This commit is contained in:
John Firebaugh
2017-04-11 13:30:03 -07:00
parent a2670336d4
commit f1c06f8d83
17 changed files with 76 additions and 271 deletions

View File

@@ -230,7 +230,7 @@ final class MapGestureDetector {
float scrollDist = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
// Scale the map by the appropriate power of two factor
transform.zoomBy(Math.pow(2.0, scrollDist), event.getX(), event.getY());
transform.zoomBy(scrollDist, event.getX(), event.getY());
return true;
@@ -479,17 +479,17 @@ final class MapGestureDetector {
// Scale the map
if (focalPoint != null) {
// arround user provided focal point
transform.zoomBy(detector.getScaleFactor(), focalPoint.x, focalPoint.y);
transform.zoomBy(Math.log(detector.getScaleFactor()) / Math.log(2), focalPoint.x, focalPoint.y);
} else if (quickZoom) {
// clamp scale factors we feed to core #7514
float scaleFactor = MathUtils.clamp(detector.getScaleFactor(),
MapboxConstants.MINIMUM_SCALE_FACTOR_CLAMP,
MapboxConstants.MAXIMUM_SCALE_FACTOR_CLAMP);
// around center map
transform.zoomBy(scaleFactor, uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
transform.zoomBy(Math.log(scaleFactor) / Math.log(2), uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
} else {
// around gesture
transform.zoomBy(detector.getScaleFactor(), detector.getFocusX(), detector.getFocusY());
transform.zoomBy(Math.log(detector.getScaleFactor()) / Math.log(2), detector.getFocusX(), detector.getFocusY());
}
return true;

View File

@@ -338,55 +338,6 @@ final class NativeMapView {
nativeSetPitch(pitch, duration);
}
public void scaleBy(double ds) {
if (isDestroyedOn("scaleBy")) {
return;
}
scaleBy(ds, Double.NaN, Double.NaN);
}
public void scaleBy(double ds, double cx, double cy) {
if (isDestroyedOn("scaleBy")) {
return;
}
scaleBy(ds, cx, cy, 0);
}
public void scaleBy(double ds, double cx, double cy, long duration) {
if (isDestroyedOn("scaleBy")) {
return;
}
nativeScaleBy(ds, cx / pixelRatio, cy / pixelRatio, duration);
}
public void setScale(double scale) {
if (isDestroyedOn("setScale")) {
return;
}
setScale(scale, Double.NaN, Double.NaN);
}
public void setScale(double scale, double cx, double cy) {
if (isDestroyedOn("setScale")) {
return;
}
setScale(scale, cx, cy, 0);
}
public void setScale(double scale, double cx, double cy, long duration) {
if (isDestroyedOn("setScale")) {
return;
}
nativeSetScale(scale, cx / pixelRatio, cy / pixelRatio, duration);
}
public double getScale() {
if (isDestroyedOn("getScale")) {
return 0;
}
return nativeGetScale();
}
public void setZoom(double zoom, PointF focalPoint, long duration) {
if (isDestroyedOn("setZoom")) {
return;
@@ -1025,12 +976,6 @@ final class NativeMapView {
private native void nativeSetPitch(double pitch, long duration);
private native void nativeScaleBy(double ds, double cx, double cy, long duration);
private native void nativeSetScale(double scale, double cx, double cy, long duration);
private native double nativeGetScale();
private native void nativeSetZoom(double zoom, double cx, double cy, long duration);
private native double nativeGetZoom();

View File

@@ -125,6 +125,6 @@ public class Projection {
* @return zoom level that fits the MapView.
*/
public double calculateZoom(float minScale) {
return Math.log(nativeMapView.getScale() * minScale) / Math.log(2);
return nativeMapView.getZoom() + Math.log(minScale) / Math.log(2);
}
}

View File

@@ -273,8 +273,8 @@ final class Transform implements MapView.OnMapChangedListener {
}
}
void zoomBy(double pow, float x, float y) {
mapView.scaleBy(pow, x, y);
void zoomBy(double z, float x, float y) {
mapView.setZoom(mapView.getZoom() + z, new PointF(x, y), 0);
}
void moveBy(double offsetX, double offsetY, long duration) {